aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com/jsyn/unitgen/PitchToFrequency.java
blob: 9086749bb64ff75bdb7e95cf601e8d164f0dace8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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();
    }
}