getting audio data from WAV file into PROGMEM array

If anyone can help please, many thanks.

To cut and paste data into a PROGMEM array, it needs to be 8 bit unsigned integers.
With the Arduino IDE text-based, the values need converting to eg 123, 4, …etc.

The code I have tried from the Web, either will not run due to java issues, or the compiled c++ Windows console or Windows API applications fail to recognise any input.

I tried this additional converter, it compiles but I’ve no idea what is meant by ‘command line arguments’. There is not enough explanation for my level of understanding.

//
// Convert a signed 8-bit mono RAW audio file to C language
//

// Author:  P.J. Drongowski
// Version: 1.0
// Date:    16 July 2016
//
// Copyright (c) 2016 Paul J. Drongowski
//               Permission granted to modify and distribute

// This program takes two command line arguments, i.e.,
//     raw2c rawfile arrayname
//         rawfile is the path to a RAW audio file (signed 8-bit mono).
//         arrayname is the name of the C array to be generated
// The program generates a C-language array definition into a file
// named "output.h". I recommend running this program from a command
// script which renames "output.h" to something else.

#include <sys/stat.h>
#include <stdio.h>
#include <string.h>

char arrayName[1024] ;
char arraySize[1024] ;

int main(int argc, char* argv[])
{
  FILE* rawFile = NULL ;
  FILE* cFile = NULL ;
  int fd = 0 ;
  struct stat statStruct ;
  int rawValue = 0 ;
  int itemCount = 0 ;
  size_t statusValue = 0 ;
  unsigned int rawCount = 0 ;
  unsigned int fileLength = 0 ;

  if (argc < 2) {
    fprintf(stderr, "*fatal* Missing command line arguments\n") ;
    fprintf(stderr, "Usage: raw2c file.raw arrayname\n") ;
    return( 1 ) ;
  }

  if ((rawFile = fopen(argv[1], "rb")) == NULL) {
    fprintf(stderr, "*fatal* Cannot open raw audio file\n") ;
    return( 1 ) ;
  }
  fd = fileno(rawFile) ;
  fstat(fd, &statStruct) ;
  fileLength = (unsigned int) statStruct.st_size ;

  if ((cFile = fopen("output.c", "w")) == NULL) {
    fprintf(stderr, "*fatal* Cannot create C table file\n") ;
    if (rawFile != NULL) fclose(rawFile) ;
    return( 1 ) ;
  }

  if (argv[2] != NULL) {
    strncpy(arrayName, argv[2], 1023) ;
    strncpy(arraySize, arrayName, 1023) ;
    strupr(arraySize) ;
  } else {
    strncpy(arrayName, "table", 1023) ;
    strncpy(arraySize, arrayName, 1023) ;
    strupr(arraySize) ;
  }

  // fprintf(cFile, "#include <avr/pgmspace.h>\n\n") ;
  fprintf(cFile, "// C table file: %s\n\n", argv[1]) ;
  fprintf(cFile, "#define %sSIZE %d\n", arraySize, fileLength) ;
  fprintf(cFile, "const int8_t PROGMEM %s[%sSIZE] = {\n", 
	  arrayName, arraySize) ;

  rawCount = 0 ;
  itemCount = 0 ;

  do {
    statusValue = fread(&rawValue, 1, 1, rawFile) ;
    if (statusValue > 0) {
      rawCount++ ;
      if (itemCount == 0) {
	fprintf(cFile, "  %3hhd", (signed char)rawValue) ;
	itemCount++  ;
      } else {
	fprintf(cFile, ",%3hhd", (signed char)rawValue) ;
	if (itemCount >= 14) {
	  fprintf(cFile, ",\n") ;
	  itemCount = 0 ;
	} else {
	  itemCount++ ;
	}
      }
    }
  } while (statusValue > 0) ;

  fprintf(cFile, "\n} ;\n\n") ;

  if (fileLength != rawCount) {
    fprintf(stderr, "*warning* Raw count does not equal file length\n") ;
  }

  fclose(rawFile) ;
  fclose(cFile) ;

  return( 0 ) ;
}

it compiles

Where? That is a PC application.

There is not enough explanation for my level of understanding.

You need a new hobby then. Perhaps knitting is more your speed.

You need to compile the code you presented and then run it from CMD with Command Line Arguments like location of designated file.

It shows in the beginning of you’r code: int main(int argc, char* argv)

So after compilation you can run:
c:\CompiledExecutable.exe “Argument1” “Argument2” “ect”

My suggestion, though, is to use this online converter. After all you don’t need the conversion done at run time if you are using PROGMEM as storage.

Thanks Misha,
I now found this link also, which does the whole conversion online to a PROGMEM array, just have to paste it in the sketch.

http://bitluni.net/wp-content/uploads/2016/12/bin2h8bit.html

Although the array values from that link above are 'signed' 8 bit, the IDE compiler deals with that.
The audio is working fine.