changeset 143:0f0c9cf65d5e

* Add Hz tuning dial to sample player plugin. Need to figure out the best way to get this passed through from the main program's configuration. * Add ConfigFile class to deal with configuration load/save * Add an organ sample (it's a bit big, though)
author Chris Cannam
date Wed, 26 Jul 2006 15:32:10 +0000
parents 0ba66b160a02
children a9c3ba1777e1
files plugin/plugins/SamplePlayer.cpp plugin/plugins/SamplePlayer.h
diffstat 2 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugin/plugins/SamplePlayer.cpp	Mon Jul 24 14:36:35 2006 +0000
+++ b/plugin/plugins/SamplePlayer.cpp	Wed Jul 26 15:32:10 2006 +0000
@@ -36,6 +36,7 @@
     "Output",
     "Tuned (on/off)",
     "Base Pitch (MIDI)",
+    "Tuning of A (Hz)",
     "Sustain (on/off)",
     "Release time (s)"
 };
@@ -58,6 +59,8 @@
       LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE, 0, 1 },
     { LADSPA_HINT_DEFAULT_MIDDLE | LADSPA_HINT_INTEGER |
       LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE, 0, 120 },
+    { LADSPA_HINT_DEFAULT_440 | LADSPA_HINT_LOGARITHMIC |
+      LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE, 220, 880 },
     { LADSPA_HINT_DEFAULT_MINIMUM | LADSPA_HINT_INTEGER |
       LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE, 0, 1 },
     { LADSPA_HINT_DEFAULT_MINIMUM | LADSPA_HINT_LOGARITHMIC |
@@ -122,6 +125,7 @@
     m_output(0),
     m_retune(0),
     m_basePitch(0),
+    m_concertA(0),
     m_sustain(0),
     m_release(0),
     m_sampleData(0),
@@ -168,6 +172,7 @@
 	&player->m_output,
 	&player->m_retune,
 	&player->m_basePitch,
+        &player->m_concertA,
 	&player->m_sustain,
 	&player->m_release
     };
@@ -529,13 +534,16 @@
 void
 SamplePlayer::addSample(int n, unsigned long pos, unsigned long count)
 {
-    float ratio = 1.0;
-    float gain = 1.0;
+    float ratio = 1.f;
+    float gain = 1.f;
     unsigned long i, s;
 
     if (m_retune && *m_retune) {
+        if (m_concertA) {
+            ratio *= *m_concertA / 440.f;
+        }
 	if (m_basePitch && n != *m_basePitch) {
-	    ratio = powf(1.059463094, n - *m_basePitch);
+	    ratio *= powf(1.059463094f, n - *m_basePitch);
 	}
     }
 
--- a/plugin/plugins/SamplePlayer.h	Mon Jul 24 14:36:35 2006 +0000
+++ b/plugin/plugins/SamplePlayer.h	Wed Jul 26 15:32:10 2006 +0000
@@ -39,9 +39,10 @@
 	OutputPort    = 0,
 	RetunePort    = 1,
 	BasePitchPort = 2,
-	SustainPort   = 3,
-	ReleasePort   = 4,
-	PortCount     = 5
+        ConcertAPort  = 3,
+	SustainPort   = 4,
+	ReleasePort   = 5,
+	PortCount     = 6
     };
 
     enum {
@@ -79,6 +80,7 @@
     float *m_output;
     float *m_retune;
     float *m_basePitch;
+    float *m_concertA;
     float *m_sustain;
     float *m_release;