# HG changeset patch # User Justin Salamon # Date 1389977989 18000 # Node ID d2c13ec0f1482e003d86c0ba3f7c5e5fbae6de08 # Parent 8e44c7302cf37ad78a0610d5cec38a261f61b396 scale gain of synth wave, replace tabs with spaces diff -r 8e44c7302cf3 -r d2c13ec0f148 audioio/ContinuousSynth.cpp --- a/audioio/ContinuousSynth.cpp Fri Jan 17 08:40:01 2014 +0000 +++ b/audioio/ContinuousSynth.cpp Fri Jan 17 11:59:49 2014 -0500 @@ -48,8 +48,8 @@ bool nowOn = (f0 > 0.f); if (!nowOn && !wasOn) { - m_phase = 0; - return; + m_phase = 0; + return; } int fadeLength = 100; // samples @@ -57,11 +57,11 @@ float *levels = new float[m_channels]; for (int c = 0; c < m_channels; ++c) { - levels[c] = gain; + levels[c] = gain * 0.5; // scale gain otherwise too loud compared to source } if (pan != 0.0 && m_channels == 2) { - levels[0] *= 1.0 - pan; - levels[1] *= pan + 1.0; + levels[0] *= 1.0 - pan; + levels[1] *= pan + 1.0; } // cerr << "ContinuousSynth::mix: f0 = " << f0 << " (from " << m_prevF0 << "), phase = " << m_phase << endl; @@ -82,7 +82,7 @@ int harmonics = (m_sampleRate / 4) / fHere - 1; if (harmonics < 1) harmonics = 1; - switch (m_wavetype) { + switch (m_wavetype) { case 1: harmonics = 1; break; @@ -93,7 +93,7 @@ default: harmonics = 3; break; - } + } for (int h = 0; h < harmonics; ++h) { @@ -140,7 +140,7 @@ toBuffers[c][i] += levels[c] * v; } } - } + } m_prevF0 = f0; diff -r 8e44c7302cf3 -r d2c13ec0f148 audioio/ContinuousSynth.h --- a/audioio/ContinuousSynth.h Fri Jan 17 08:40:01 2014 +0000 +++ b/audioio/ContinuousSynth.h Fri Jan 17 11:59:49 2014 -0500 @@ -45,9 +45,9 @@ * sound switches on and off cleanly. */ void mix(float **toBuffers, - float gain, - float pan, - float f0); + float gain, + float pan, + float f0); private: int m_channels;