1300 Java Media Framework and Java Sound (on (Web site counters)
1300 Java Media Framework and Java Sound (on CD) Chapter 22 // Fig. 22.10: MidiDemo.java // Simulates a musical keyboard with various // instruments to play, also featuring recording, MIDI file // playback and simulating MIDI playback with the keyboard // Java core packages import java.awt.*; import java.awt.event.*; import java.io.*; // Java extension packages import javax.swing.*; import javax.swing.event.*; import javax.sound.midi.*; public class MidiDemo extends JFrame { // recording MIDI data private MidiRecord midiRecord; // synthesize MIDI functioning private MidiSynthesizer midiSynthesizer; // MIDI data in MIDI file private MidiData midiData; // timer for simulating MIDI on piano private Timer pianoTimer; // piano keys private JButton noteButton[]; // volume, tempo sliders private JSlider volumeSlider, resolutionSlider; // containers and panels holding GUI private Container container; private JPanel controlPanel, buttonPanel; // instrument selector and buttons GUI private JComboBox instrumentBox; private JButton playButton, recordButton, saveButton, pianoPlayerButton, listenButton; // tempo, last piano key invoked, volume of MIDI private int resolution, lastKeyOn = -1, midiVolume = 40; // boolean value indicating if program is in recording mode private boolean recording = false; // first note number of first piano key, max number of keys private static int FIRST_NOTE = 32, MAX_KEYS = 64; Fig. 22.10 MidiDemoprovides the GUI than enables users to interact with the application (part 1 of 14).
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.