Repository navigation
Trouble wit embedding .wav as header #6327
|
Hello! I get in trouble with embedding my .wav file into binary as C-header. Few words about my surroundings: ` ` Then, I include fresh header to project, then #include it inside .c file and rewrite code: ` ` I start investigate, what happens: So my question is: how to store resource in binary for minimalistic projects? If you want to experiment with my data: my wav Thank you for wasting your time for my little trouble! |
Replies: 2 comments
|
Hi @Scuf-235B5ECE, The 53,260 bytes in your exported array match the WAV's audio data exactly. After Wave tempW = { 0 };
tempW.frameCount = _FRAME_COUNT;
tempW.sampleRate = _SAMPLE_RATE;
tempW.sampleSize = _SAMPLE_SIZE;
tempW.channels = _CHANNELS;
tempW.data = RotateSoundData;
Sound testZap = LoadSoundFromWave(tempW);
PlaySound(testZap);Skip If you'd rather keep |
|
Thank you @benitoalba ! unsigned int readByes = 0;
unsigned char* memfile = LoadFileData("RotateState.wav", &readByes);
tempW = LoadWaveFromMemory(".wav", memfile, readByes);
ExportDataAsCode(memfile, readByes, "RotateSound.h"); //this header can satisfy LoadWaveFromMemory()And now tempW = LoadWaveFromMemory(".wav", RotateSoundData, sizeof(RotateSoundData));
testZap = LoadSoundFromWave(tempW); //now sound is ready
UnloadWave(tempW);
PlaySound(testZap);//playing!Work as planned. |

Hi @Scuf-235B5ECE,
ExportWaveAsCode()saves raw PCM samples, so its array isn't a complete WAV file.LoadWaveFromMemory(".wav", ...)expects the RIFF/WAV header too.The 53,260 bytes in your exported array match the WAV's audio data exactly. After
InitAudioDevice(), you can build aWavedirectly using the names in your attached header:Skip
UnloadWave(tempW)here, it would try to free the header's static array. UseUnloadSound(testZap)when you're finis…