diff options
author | Phil Burk <[email protected]> | 2015-01-02 13:23:30 -0800 |
---|---|---|
committer | Phil Burk <[email protected]> | 2015-04-29 08:11:10 -0700 |
commit | 7aec269a333d43cc226a0c9c30986e4b50bafa28 (patch) | |
tree | 8029f57340ef5211586ea21d8a63614cfb1a9ae9 /tests/com/jsyn/examples | |
parent | d3c74876db36598813068ce0bb8ea887e41a1c71 (diff) |
Use AudioMath for pitch to frequency conversion.
Fix ListDevices default.
Cleanup interpolator in AutoCorrelator.
Remove empty string from SubtractiveSynth library.
Diffstat (limited to 'tests/com/jsyn/examples')
-rw-r--r-- | tests/com/jsyn/examples/ListAudioDevices.java | 2 | ||||
-rw-r--r-- | tests/com/jsyn/examples/PlayChords.java | 12 |
2 files changed, 3 insertions, 11 deletions
diff --git a/tests/com/jsyn/examples/ListAudioDevices.java b/tests/com/jsyn/examples/ListAudioDevices.java index 6c5372d..dceaa0d 100644 --- a/tests/com/jsyn/examples/ListAudioDevices.java +++ b/tests/com/jsyn/examples/ListAudioDevices.java @@ -33,7 +33,7 @@ public class ListAudioDevices { int maxInputs = audioManager.getMaxInputChannels(i); int maxOutputs = audioManager.getMaxInputChannels(i); boolean isDefaultInput = (i == audioManager.getDefaultInputDeviceID()); - boolean isDefaultOutput = (i == audioManager.getDefaultInputDeviceID()); + boolean isDefaultOutput = (i == audioManager.getDefaultOutputDeviceID()); System.out.println("#" + i + " : " + deviceName); System.out.println(" max inputs : " + maxInputs + (isDefaultInput ? " (default)" : "")); diff --git a/tests/com/jsyn/examples/PlayChords.java b/tests/com/jsyn/examples/PlayChords.java index 0b1ae2e..28cab5f 100644 --- a/tests/com/jsyn/examples/PlayChords.java +++ b/tests/com/jsyn/examples/PlayChords.java @@ -22,6 +22,7 @@ import com.jsyn.instruments.SubtractiveSynthVoice; import com.jsyn.unitgen.LineOut; import com.jsyn.unitgen.UnitVoice; import com.jsyn.util.VoiceAllocator; +import com.softsynth.math.AudioMath; import com.softsynth.shared.time.TimeStamp; /** @@ -167,21 +168,12 @@ public class PlayChords { } private void noteOn(double time, int noteNumber) { - double frequency = convertPitchToFrequency(noteNumber); + double frequency = AudioMath.pitchToFrequency(noteNumber); double amplitude = 0.2; TimeStamp timeStamp = new TimeStamp(time); allocator.noteOn(noteNumber, frequency, amplitude, timeStamp); } - /** - * Calculate frequency in Hertz based on MIDI pitch. Middle C is 60.0. You can use fractional - * pitches so 60.5 would give you a pitch half way between C and C#. - */ - double convertPitchToFrequency(double pitch) { - final double concertA = 440.0; - return concertA * Math.pow(2.0, ((pitch - 69) * (1.0 / 12.0))); - } - public static void main(String[] args) { new PlayChords().test(); } |