From 2d96196d254a6199b3aca29957e7970ac1cfbbaa Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 15 Sep 2020 13:17:10 +0200 Subject: [PATCH] REVIEWED: SaveWAV() to use memory write insted of file --- src/raudio.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/raudio.c b/src/raudio.c index b18a9383..f2fd5dcf 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1940,20 +1940,20 @@ static int SaveWAV(Wave wave, const char *fileName) { drwav wav = { 0 }; drwav_data_format format = { 0 }; - format.container = drwav_container_riff; // <-- drwav_container_riff = normal WAV files, drwav_container_w64 = Sony Wave64. - format.format = DR_WAVE_FORMAT_PCM; // <-- Any of the DR_WAVE_FORMAT_* codes. + format.container = drwav_container_riff; + format.format = DR_WAVE_FORMAT_PCM; format.channels = wave.channels; format.sampleRate = wave.sampleRate; format.bitsPerSample = wave.sampleSize; - drwav_init_file_write(&wav, fileName, &format, NULL); - //drwav_init_memory_write(&wav, &fileData, &fileDataSize, &format, NULL); // TODO: Memory version + unsigned char *fileData = NULL; + unsigned int fileDataSize = 0; + drwav_init_memory_write(&wav, &fileData, &fileDataSize, &format, NULL); drwav_write_pcm_frames(&wav, wave.sampleCount/wave.channels, wave.data); - drwav_uninit(&wav); - // SaveFileData(fileName, fileData, fileDataSize); - //drwav_free(fileData, NULL); + SaveFileData(fileName, fileData, fileDataSize); + drwav_free(fileData, NULL); return true; }