diff options
| author | Ray <[email protected]> | 2016-12-20 00:33:45 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2016-12-20 00:33:45 +0100 |
| commit | 4a9b77dd705790ec1c15fb139afdcc7093c8e2ad (patch) | |
| tree | 04fd9acc56b140c765847565f055ca4d5f604774 /src/audio.c | |
| parent | 814507906f56f346d35ca95e7d9888213d3e5974 (diff) | |
| download | raylib-4a9b77dd705790ec1c15fb139afdcc7093c8e2ad.tar.gz raylib-4a9b77dd705790ec1c15fb139afdcc7093c8e2ad.zip | |
Corrected bug sound playing twice
Samples count was not properly calculated on WAV loading
Diffstat (limited to 'src/audio.c')
| -rw-r--r-- | src/audio.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/audio.c b/src/audio.c index 4435b760..a9c07c39 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1083,11 +1083,13 @@ static Wave LoadWAV(const char *fileName) // Read in the sound data into the soundData variable fread(wave.data, waveData.subChunkSize, 1, wavFile); - // Now we set the variables that we need later - wave.sampleCount = waveData.subChunkSize; + // Store wave parameters wave.sampleRate = waveFormat.sampleRate; wave.sampleSize = waveFormat.bitsPerSample; wave.channels = waveFormat.numChannels; + + // NOTE: subChunkSize comes in bytes, we need to translate it to number of samples + wave.sampleCount = waveData.subChunkSize/(waveFormat.bitsPerSample/8); TraceLog(INFO, "[%s] WAV file loaded successfully (SampleRate: %i, SampleSize: %i, Channels: %i)", fileName, wave.sampleRate, wave.sampleSize, wave.channels); } |
