diff options
author | Phil Burk <[email protected]> | 2016-08-02 07:52:17 -0700 |
---|---|---|
committer | Phil Burk <[email protected]> | 2016-10-24 08:29:20 -0700 |
commit | 580fea450ec0982d0bd8be589f00566267e7b0d1 (patch) | |
tree | 0420f768fc7c63208b1720232c447e17af9017af /src/com/jsyn/unitgen/PitchToFrequency.java | |
parent | a6583e89166f7477a675cf3094a91b303ba7850a (diff) |
Instruments: add better synth, pitch control
Diffstat (limited to 'src/com/jsyn/unitgen/PitchToFrequency.java')
-rw-r--r-- | src/com/jsyn/unitgen/PitchToFrequency.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/com/jsyn/unitgen/PitchToFrequency.java b/src/com/jsyn/unitgen/PitchToFrequency.java new file mode 100644 index 0000000..9086749 --- /dev/null +++ b/src/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(); + } +} |