|
From: <man...@us...> - 2013-04-22 23:15:45
|
Revision: 1955
http://sourceforge.net/p/modplug/code/1955
Author: manxorist
Date: 2013-04-22 23:15:37 +0000 (Mon, 22 Apr 2013)
Log Message:
-----------
[Imp] Add CSoundFile::ApplyFinalOutputGain(). This is not used in the tracker.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-22 22:59:36 UTC (rev 1954)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-22 23:15:37 UTC (rev 1955)
@@ -737,6 +737,10 @@
#endif // MODPLUG_TRACKER
void ApplyGlobalVolume(int SoundBuffer[], int RearBuffer[], long lTotalSampleCount);
+#ifndef MODPLUG_TRACKER
+ void ApplyFinalOutputGain(int SoundBuffer[], int RearBuffer[], long lCount); // lCount meaning the number of frames, totally independet from the numer of channels
+#endif
+
// System-Dependant functions
public:
static void *AllocateSample(UINT nbytes);
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-22 22:59:36 UTC (rev 1954)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-22 23:15:37 UTC (rev 1955)
@@ -319,6 +319,10 @@
nStat++;
+#ifndef MODPLUG_TRACKER
+ ApplyFinalOutputGain(MixSoundBuffer, MixRearBuffer, lCount);
+#endif
+
#ifndef NO_AGC
// Automatic Gain Control
if (m_MixerSettings.DSPMask & SNDDSP_AGC) m_AGC.Process(MixSoundBuffer, lSampleCount, m_MixerSettings.gdwMixingFreq, m_MixerSettings.gnChannels);
@@ -2274,3 +2278,43 @@
}
}
}
+
+
+#ifndef MODPLUG_TRACKER
+void CSoundFile::ApplyFinalOutputGain(int SoundBuffer[], int RearBuffer[], long lCount) {
+ if(m_MixerSettings.m_FinalOutputGain == (1<<16))
+ {
+ // nothing to do, gain == +/- 0dB
+ return;
+ }
+ // no clipping prevention is done here
+ int32 factor = m_MixerSettings.m_FinalOutputGain;
+ int * buf = SoundBuffer;
+ int * rbuf = RearBuffer;
+ if(m_MixerSettings.gnChannels == 1)
+ {
+ for(int i=0; i<lCount; ++i)
+ {
+ *buf = Util::muldiv(*buf, factor, 1<<16);
+ buf++;
+ }
+ } else if(m_MixerSettings.gnChannels == 2)
+ {
+ for(int i=0; i<lCount*2; ++i)
+ {
+ *buf = Util::muldiv(*buf, factor, 1<<16);
+ buf++;
+ }
+ } else if(m_MixerSettings.gnChannels == 4)
+ {
+ for(int i=0; i<lCount*2; ++i)
+ {
+ *buf = Util::muldiv(*buf, factor, 1<<16);
+ *rbuf = Util::muldiv(*rbuf, factor, 1<<16);
+ buf++;
+ rbuf++;
+ }
+ }
+}
+#endif
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|