1 Replies - 2062 Views - Last Post: 30 October 2006 - 06:43 AM Rate Topic: -----

#1 dprasad  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-October 06

Audio Quality problem while using waveOut* SDK functions

Posted 30 October 2006 - 05:33 AM

Hi ,

I am using waveOut* API functions to play sound. I am taking the data from one system using sockets
and i am playing that data in the other system.

I have followed all the steps which i got from msdn.
Like : 1.Initialized the WAVEFORMATEX structure..
2.Called ::waveOutOpen()....with CALLBACK_FUNCTION.
3.Initialized the WaveHeader .
4.Called the functions to play sounds.

But i am getting some disturbance in the audio with compared to original one.

Plz let me know,if you want any explanation...how i am using... and all.

If you have any idea, plz let me know.


Thanks in Advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Audio Quality problem while using waveOut* SDK functions

#2 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 784
  • View blog
  • Posts: 7,613
  • Joined: 05-May 05

Re: Audio Quality problem while using waveOut* SDK functions

Post icon  Posted 30 October 2006 - 06:43 AM

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).

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 October 2006 - 06:46 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1