summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@thinkpad.(none)>2011-02-04 16:29:08 +0100
committerFlorian Jung <flo@thinkpad.(none)>2011-02-04 16:29:08 +0100
commit080ddd252d94b9304db3858bc3b7f79cf2f89f33 (patch)
tree994f2b85138dc1f944481abc4d1e505cecf04bb8
parent6ea25018546ebc099845158de7fef29c1c4fb28d (diff)
factor[foo] now accepts semitones instead of a factor
However, internally, factor still behaves as usual. Only all functions which can set/change .factor do the calculation from semitones to the real factor.
-rw-r--r--synth/note.cpp2
-rw-r--r--synth/parser.cpp3
-rw-r--r--synth/programs.cpp3
3 files changed, 5 insertions, 3 deletions
diff --git a/synth/note.cpp b/synth/note.cpp
index 57d8302..d208ae8 100644
--- a/synth/note.cpp
+++ b/synth/note.cpp
@@ -178,7 +178,7 @@ void Note::set_param(const parameter_t &p, fixed_t v) //ACHTUNG:
case KSR: oscillator[p.osc].ksr=float(v)/ONE; break;
case KSL: oscillator[p.osc].ksl=float(v)/ONE; break;
- case FACTOR: orig.oscillator[p.osc].factor=v; oscillator[p.osc].factor=v*freqfactor_factor[p.osc]; break;
+ case FACTOR: orig.oscillator[p.osc].factor=pow(2.0, (double)v/12.0/ONE)*ONE; oscillator[p.osc].factor=v*freqfactor_factor[p.osc]; break;
case MODULATION: orig.oscillator[p.osc].fm_strength[p.index]=v; apply_pfactor(); break;
case OUTPUT: orig.oscillator[p.osc].output=v; apply_pfactor(); break;
case TREMOLO: oscillator[p.osc].tremolo_depth=v; break;
diff --git a/synth/parser.cpp b/synth/parser.cpp
index 174e0ee..1b8befb 100644
--- a/synth/parser.cpp
+++ b/synth/parser.cpp
@@ -1,5 +1,6 @@
#include <cstdlib>
#include <fstream>
+#include <cmath>
#include "parser.h"
#include "defines.h"
@@ -413,7 +414,7 @@ program_t parse(string fn)
}
break;
case FACTOR:
- osc[ind].factor=val*ONE;
+ osc[ind].factor=pow(2.0,val/12.0) *ONE;
break;
case TREMOLO:
osc[ind].tremolo_depth=int(val);
diff --git a/synth/programs.cpp b/synth/programs.cpp
index 23da924..5dae4ed 100644
--- a/synth/programs.cpp
+++ b/synth/programs.cpp
@@ -1,6 +1,7 @@
#include <string>
#include <cstring>
#include <dlfcn.h>
+#include <cmath>
#include "programs.h"
#include "globals.h"
@@ -157,7 +158,7 @@ void program_t::set_param(const parameter_t &p, fixed_t v) //ACHTUNG:
case KSR: osc_settings[p.osc].ksr=float(v)/ONE; break;
case KSL: osc_settings[p.osc].ksl=float(v)/ONE; break;
- case FACTOR: osc_settings[p.osc].factor=v; break;
+ case FACTOR: osc_settings[p.osc].factor=pow(2.0, (double)v/12.0/ONE)*ONE; break;
case MODULATION: osc_settings[p.osc].fm_strength[p.index]=v; break;
case OUTPUT: osc_settings[p.osc].output=v; break;
case TREMOLO: osc_settings[p.osc].tremolo_depth=v; break;