changeset 327:d2c13ec0f148 tonioni

scale gain of synth wave, replace tabs with spaces
author Justin Salamon <justin.salamon@nyu.edu>
date Fri, 17 Jan 2014 11:59:49 -0500
parents 8e44c7302cf3
children 28c17ce7a6e9 f72d58d1ccb0
files audioio/ContinuousSynth.cpp audioio/ContinuousSynth.h
diffstat 2 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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;
 
--- 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;