| WaveFormat.nAvgBytesPerSec = WaveFormat.nBlockAlign*WaveFormat.nBlockAlign;
|
This line is wrong. It should be:
| WaveFormat.nAvgBytesPerSec = WaveFormat.nSamplesPerSec * WaveFormat.nBlockAlign;
|
Also this:
| *sampleOut = (int16)region2;
|
is supposed to be:
| sampleOut = (int16*) region2;
|
and this should be obvious:
| uint8 Blue ;
uint8 Green ;
uint8 Red = 0;
|
In general your code is very inconsistent and completely full of typos. This
will come and bite you later on and result in really strange bugs or just straight up crashes like it did this time. People might be unwilling to help you if half of the variables are misspelled and randomly have different capitalisation in different parts of the program. Eventually even you will have trouble reading your own code.
And it's not just about names, there are also multiple numerical constants that are wrong just like the sample rate, as mmozeiko pointed out. Variable names "only" impact code readability, but this is actual broken functionality.