1294 Java Media Framework (Web design portfolio) and Java Sound (on
Tuesday, September 25th, 20071294 Java Media Framework and Java Sound (on CD) Chapter 22 102 103 // set track to recording-enabled and default channel 104 sequencer.recordEnable( track, 0 ); 105 106 sequencer.startRecording(); 107 } 108 109 // sequence contains bad MIDI data 110 catch ( InvalidMidiDataException badMidiException ) { 111 badMidiException.printStackTrace(); 112 113 } 114 115 } // end method startRecord 116 117 // stop MIDI recording 118 public void stopRecord() 119 { 120 sequencer.stopRecording(); 121 } 122 123 // save MIDI sequence to file 124 public void saveSequence( File file ) 125 { 126 // get all MIDI supported file types 127 int[] fileTypes = MidiSystem.getMidiFileTypes( sequence ); 128 129 if ( fileTypes.length == 0 ) { 130 System.err.println( “No supported MIDI file format!” ); 131 return; 132 } 133 134 // write recorded sequence into MIDI file 135 try { 136 MidiSystem.write( sequence, fileTypes[ 0 ], file ); 137 } 138 139 // error writing to file 140 catch ( IOException ioException ) { 141 ioException.printStackTrace(); 142 } 143 144 } // end method saveSequence 145 146 } // end class MidiRecord Fig. 22.8 MidiRecordenables a program to record a MIDI sequence (part 3 of 3). The first step of recording MIDI data is similar to the playback mechanism in class MidiData. In addition to obtaining an empty sequence and a sequencer, a MIDI recording program needs to connect the transmitters and receivers. After successfully wiring the sequencer s receiver as the IN PORT, the recorder loads the empty sequence into the sequencer to start recording to a new track in the sequence. The following discussion covers these steps.
We recommend high quality webhost to host and run your jsp application: christian web host services.