Check the formats of the input and output buffers for the format. Check to see if the input's sign is different from the outputs sign.
I had a problem where I wrote a WAV file player for the GBA, but the sounds were popping. I found out that my input wave was signed, and the GBA's output buffer was unsigned. I solved it by changing the wave file by subtracting 128 to each sample (it was an eight bit sample).
Look at the following code to see the -128 operation done to the final sample to be passed to the buffer (I mix 4 sounds into two different buffers).
CODE
void mix_sound()
{
// Play music
run_song;
// Go through all sound effects
cur_channel = 0;
sound_running = 0;
// Zero fill channels
set_dma3_loc((u32)(&zero_fill),(u32)(&mix_ladder[0][0]));
set_dma3((BUFFER_SIZE),dma_up,dma_fixed,0,1,dma_now,0,1);
for(x = 0;x < sound_used;x++)
{
if(sound_state[x] != 0) // The sound is playing!
{
memory_copy(&sound_data[x][sound_step[x]],&mix_ladder[cur_channel][0],BUFFER_SIZE/2);
sound_step[x] += BUFFER_SIZE;
if(sound_step[x] >= sound_length[x] || sound_step[x]+BUFFER_SIZE >= sound_length[x])
{
sound_step[x] = 0;
if(sound_state[x] == 1)
sound_state[x] = 0;
}
cur_channel++;
sound_running++;
if(cur_channel >= MAX_CHANNEL)
cur_channel = 0;
}
}
// Combine the mixing ladder for direct sound A and B
for(x = 0;x < BUFFER_SIZE;x++)
{
cur_mix_buffer_a[x] = ((mix_ladder[0][x]+mix_ladder[1][x])>>1)-128;
if(sound_running > 2)
cur_mix_buffer_b[x] = ((mix_ladder[2][x]+mix_ladder[3][x])>>1)-128;
}
}
This post has been edited by WolfCoder: 30 Oct, 2006 - 05:46 AM