Skip to contentSkip to conversation

Fundamental principle of audio mixing?

DISCUSSION Nobin Mathew 3 participants 4 messages Sep 24, 2007

lore
Share & tools
lore
#0 lore raw

Can any body throw some lights on how audio mixing is done in software? Basic principle?
Or Any link to web pages expianing this?

Thanks & Regards
Nobin Mathew

#1 lore raw
Quoted 2 lines · Nobin Mathew

Can any body throw some lights on how audio mixing is done in software? Basic principle?

Basically you add the PCM samples (if they are at the same resolution and sampling rate) and renormalize if needed. The sampling rate conversion can be tricky tho.

#2 lore raw
Quoted 7 lines · Claudio Matsuoka
Quoted 2 lines · Nobin Mathew

Can any body throw some lights on how audio mixing is done in software? Basic principle?

Basically you add the PCM samples (if they are at the same resolution and sampling rate) and renormalize if needed. The sampling rate conversion can be tricky tho.

I was about to say the same; multiply each sample by the applicable gain and add - as in this extract from Audacity/src/AudioIO.cpp:

{

     if (vt->GetChannel() == Track::LeftChannel ||
         vt->GetChannel() == Track::MonoChannel)
     {
       float gain = vt->GetChannelGain(0);

       if (gAudioIO->mEmulateMixerOutputVol)
                   gain *= gAudioIO->mMixerOutputVol;

        for(i=0; i<len; i++)
           outputFloats[numPlaybackChannels*i] += gain*tempFloats[i];
     }

     if (vt->GetChannel() == Track::RightChannel ||
         vt->GetChannel() == Track::MonoChannel)
     {
        float gain = vt->GetChannelGain(1);

        if (gAudioIO->mEmulateMixerOutputVol)
           gain *= gAudioIO->mMixerOutputVol;

        for(i=0; i<len; i++)
           outputFloats[numPlaybackChannels*i+1] += gain*tempFloats[i];
     }
}

I guess implementing it is always more complicated, though!

Alan

#3 lore raw

Thanks a lot

Something like Z = A + B -A.B/normaliztion value

Quoted 43 lines · Alan Horstmann
Quoted 7 lines · Claudio Matsuoka
Quoted 2 lines · Nobin Mathew

Can any body throw some lights on how audio mixing is done in software? Basic principle?

Basically you add the PCM samples (if they are at the same resolution and sampling rate) and renormalize if needed. The sampling rate conversion can be tricky tho.

I was about to say the same; multiply each sample by the applicable gain and add - as in this extract from Audacity/src/AudioIO.cpp:

{

    if (vt->GetChannel() == Track::LeftChannel ||
        vt->GetChannel() == Track::MonoChannel)
    {
      float gain = vt->GetChannelGain(0);

      if (gAudioIO->mEmulateMixerOutputVol)
                  gain *= gAudioIO->mMixerOutputVol;

       for(i=0; i<len; i++)
          outputFloats[numPlaybackChannels*i] += gain*tempFloats[i];
    }

    if (vt->GetChannel() == Track::RightChannel ||
        vt->GetChannel() == Track::MonoChannel)
    {
       float gain = vt->GetChannelGain(1);

       if (gAudioIO->mEmulateMixerOutputVol)
          gain *= gAudioIO->mMixerOutputVol;

       for(i=0; i<len; i++)
          outputFloats[numPlaybackChannels*i+1] += gain*tempFloats[i];
    }
}

I guess implementing it is always more complicated, though!

Alan