opening 32 bit wave file

Status
Not open for further replies.

neutron7

Well-known member
I am trying to load some wavetables from SD to the external PSRAM on teensy 4.1, they are wavetables created with "serum" synthesizer. they are mono 32 bit wav files up to 524288 samples.

I have got the waves "loading" but they are malformed, it looks like the polarity bit is missing or in the wrong place, and the level is overflowing.

from what i understand, 32 bit float wav files are not really floats, they have a maximum value of 1 and minimum of -1

I can open the wave files in winamp or audacity and they play right, so i don't think there is any special encoding going on.

here is the bit of code i have to read the 32 bit words in to the PSRAM table (LARGE0[])

i have previously done this with 2 bytes and 16 bit "floats" created with "synthesis technology waveedit" and it worked fine.

Code:
void openTable(){
  uint32_t sizecounter = 0;
  int32_t inbuf = 0;
  byte bytes[4];
   myFile = SD.open("/SERUM/BOTTLE~1.WAV",FILE_READ);
  if (myFile) {
    Serial.println("OPENED /SERUM/BOTTLE~1.WAV");
    myFile.seek(99);//these serum wavetables have an additional 56 bytes before the sound data. 
//later, check for start of wav "data" instead of hardcoding 99.
     while (myFile.available()) {
       bytes[0] = myFile.read();
       bytes[1] = myFile.read();
       bytes[2] = myFile.read();
       bytes[3] = myFile.read();
       inbuf = (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];
       
       LARGE0[sizecounter] = inbuf;       
       inbuf = 0;       
      sizecounter ++;
      
     }
     Serial.println(sizecounter);
}else {
    // if the file didn't open, print an error:
    Serial.println("error opening /SERUM/BOTTLE~1.WAV");
  }
  myFile.close();
}
 
Last edited:
No, you were right, but i had to start at byte 100, not 99 and also multiply the float by 2147483648 before saving it as int32.

Thank you i have wasted a lot of time on that!
 
Status
Not open for further replies.
Back
Top