Skip to content

Commit

Permalink
Add FrenchHornDemo to test sound on the conference
Browse files Browse the repository at this point in the history
(cherry picked from commit 1adcaf4)
  • Loading branch information
jonatan-ivanov committed May 22, 2024
1 parent a1b188c commit d282c57
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.example.teahouse.tea;

import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Synthesizer;

public class FrenchHornDemo {
public static void main(String[] args) throws MidiUnavailableException, InterruptedException {
Synthesizer synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
MidiChannel channel = synthesizer.getChannels()[0];
// French Horn is bank #0 preset #60
channel.programChange(synthesizer.getAvailableInstruments()[60].getPatch().getProgram());

// C4 (middle C)
int note = 60;
try {
channel.noteOn(note, 90);
Thread.sleep(1_000);
}
finally {
channel.noteOff(note);
}
}
}

0 comments on commit d282c57

Please sign in to comment.