aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com/jsyn/unitgen/PitchToFrequency.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/jsyn/unitgen/PitchToFrequency.java')
-rw-r--r--src/main/java/com/jsyn/unitgen/PitchToFrequency.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/com/jsyn/unitgen/PitchToFrequency.java b/src/main/java/com/jsyn/unitgen/PitchToFrequency.java
new file mode 100644
index 0000000..9086749
--- /dev/null
+++ b/src/main/java/com/jsyn/unitgen/PitchToFrequency.java
@@ -0,0 +1,26 @@
+package com.jsyn.unitgen;
+
+import com.softsynth.math.AudioMath;
+
+public class PitchToFrequency extends PowerOfTwo {
+
+ public PitchToFrequency() {
+ input.setup(0.0, 60.0, 127.0);
+ }
+
+ /**
+ * Convert from MIDI pitch to an octave offset from Concert A.
+ */
+ @Override
+ public double adjustInput(double in) {
+ return (in - AudioMath.CONCERT_A_PITCH) * (1.0/12.0);
+ }
+
+ /**
+ * Convert scaler to a frequency relative to Concert A.
+ */
+ @Override
+ public double adjustOutput(double out) {
+ return out * AudioMath.getConcertAFrequency();
+ }
+}