Hi Simon,
Thanks for answering.
mrmixer
create a wav file that only contains a sine wave at a known frequency and amplitude, and when you read the file, make sure the samples make sens (should start at zero, go up to maximum amplitude, than back to zero).
I have done that with audacity (the audio tool),
and the results are confusing:
In the watch window I can see the following
| GameState->TestSound.Samples[0][0]: 1
GameState->TestSound.Samples[0][1]: 1884
GameState->TestSound.Samples[0][2]: 3770
GameState->TestSound.Samples[0][3]: 7484
...
GameState->TestSound.Samples[0][33]: 31001
GameState->TestSound.Samples[0][34]: 30339
GameState->TestSound.Samples[0][35]: 29576
...
|
Which makes sense for the sine wave I'm assuming, however, at the same very watch window, at the very same time, I get the following:
SampleValue will have -31945 in it always even after I just seen the correct numbers in TestSound.Samples right before reading it into SampleValue:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | GAME_GET_SOUND_SAMPLES(GameGetSoundSamples)
{
game_state *GameState = (game_state *)Platform->Memory->PermanentStorage;
if (GameState->TestSound.SampleCount)
{
i16 *SampleOut = Platform->SoundBuffer->Samples;
i32 SampleIndex;
for (SampleIndex = 0;
SampleIndex < Platform->SoundBuffer->SampleCount;
++SampleIndex)
{
u32 SampleIndex = (GameState->TestSampleIndex + SampleIndex) %
GameState->TestSound.SampleCount;
i16 SampleValue = GameState->TestSound.Samples[0][SampleIndex];
*SampleOut++ = SampleValue;
*SampleOut++ = SampleValue;
}
GameState->TestSampleIndex += Platform->SoundBuffer->SampleCount;
}
}
|
So, I'm confused... The values are there and they seem correct, but they wont go into "SampleValue" variable correctly... They all turn into -31945.
About posting the entire code, I can't do that unfortunately since my code isn't exactly handmade hero's code, and it's quite big.
I can post my loadwav function but that is exactly as Day 138 from handmade hero.