Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,392 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,124 people online right now. Registration is fast and FREE... Join Now!




Audio Quality problem while using waveOut* SDK functions

 
Reply to this topicStart new topic

Audio Quality problem while using waveOut* SDK functions

dprasad
30 Oct, 2006 - 04:33 AM
Post #1

New D.I.C Head
*

Joined: 30 Oct, 2006
Posts: 1


My Contributions
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.
User is offlineProfile CardPM
+Quote Post

WolfCoder
RE: Audio Quality Problem While Using WaveOut* SDK Functions
30 Oct, 2006 - 05:43 AM
Post #2

ギュウ~
Group Icon

Joined: 5 May, 2005
Posts: 3,618



Thanked: 8 times
Dream Kudos: 1450
My Contributions
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
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 02:36AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month