Download presentation
Presentation is loading. Please wait.
Published byEileen Tyler Modified over 9 years ago
1
PJV25 1 javax.sound.midi try { Sequencer seq = MidiSystem.getSequencer( ); seq.open( ); Sequence z = MidiSystem.getSequence( new File( "res/song.mid" ) ); seq.setSequence( z ); System.out.println( seq.getMicrosecondLength( ) ); seq.start( ); // PLAY Thread.sleep( 1000 ); seq.stop( ); // PAUSE System.out.println( seq.getMicrosecondPosition( ) ); Thread.sleep( 1000 ); seq.start( ); // CONTINUE seq.close( ); // SUDDEN END } catch ( IOException | InterruptedException | MidiUnavailableException | InvalidMidiDataException ex ) { System.out.println( ex ); }
2
PJV25 2 javax.sound.midi Sequencer Cloneable MidiDevice Meta Message Midi Message SoundBank Resource java.util Instrument Short Message Sysex Message Midi System Midi Event Midi FileFormat Patch Sequence Track Voice Status AutoCloseable Synthetizer MidiDevice Receiver MidiDevice Tranmitter Transmitter SoundBank MidiChannel EventListener Controller EventListener Meta EventListener MidiDevice Provider MidiFile Reader MidiFile Writer SoundBank Reader sound.midi.spil
3
PJV25 3 javax.sound.sampled DataLine Line Reverb Type Control AudioFile Format Audio Format Audio InputStream Audio Permission Audio System Guard Clip Source DataLine Target DataLine Mixer InputStream Boolean Control Compound Control Enum Control Float Control Port java.util EventListener LineListener java.io Basic Permission java.security Permission java.security Serializable java.io AutoCloseable Mixer Provider AudioFile Reader AudioFile Writer FomatConvertor Provider sound.midi.spil
4
javax.sound.sampled File fi = new File( "C://Evalcik/Trojfazova.wav" ); // pro: aif, au, wav AudioInputStream ais = AudioSystem.getAudioInputStream( fi ); AudioFormat af = ais.getFormat( ); DataLine.Info info = new DataLine.Info( Clip.class, af, ( int ) ais.getFrameLength( ) * af.getFrameSize( ) ); final Thread m = Thread.currentThread( ); Clip cl = ( Clip ) AudioSystem.getLine( info ); cl.addLineListener( new LineListener( ) { public void update( LineEvent ev ) { if ( ev.getType( ) == LineEvent.Type.START ) { } if ( ev.getType( ) == LineEvent.Type.STOP ) { m.interrupt( ); } } ); cl.open( ais ); cl.start( ); Object x = new Object( ); synchronized( x ) { try{ x.wait( ); } catch( InterruptedException ex ) { } }; PJV2 4
5
simple import sun.audio.*; // nalézá se v rt.jar, bez docletů i zdrojů try { InputStream is = new FileInputStream("C://Evalcik/Trojfazova.wav"); AudioStream as = new AudioStream(is); AudioPlayer.player.start(as); Thread.sleep(3000); AudioPlayer.player.stop(as); } catch( Exception e ) { System.out.println(e); } PJV2 5
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.