PJV25 1 javax.sound.midi try { Sequencer seq = MidiSystem.getSequencer( ); seq.open( ); Sequence z = MidiSystem.getSequence( new File( "res/song.mid" )

Slides:



Advertisements
Similar presentations
A Guide to Advanced Java Faculty:Nguyen Ngoc Tu. 2 Operating System Application #1 Application #2 Java Virtual Machine #1 Local Memory Shared Memory Threads.
Advertisements

Jan Java I/O Yangjun Chen Dept. Business Computing University of Winnipeg.
Cosc 5/4730 Multimedia Part 1: Audio media. PLAYING AUDIO Android android.media.
Audio Programming in Java
Java Sound API Medialogy, Semester 7, 2010 Aalborg University, Aalborg David Meredith
4.3. S OUND Use of sound within games. In lecture exploration of answers to frequently asked student questions.
Java Exception Very slightly modified from K.P. Chow University of Hong Kong (some slides from S.M. Yiu)
Concurrency (3) CSE 132. iClicker/WUTexter Question The following four numbers are in 8-bit 2’s complement form: Which.
1 Digital Audio Storage Formats. 2 Formats  There are many different formats for storing and communicating digital audio:  CD audio  Wav  Aiff  Au.
Shlomo Hershkop1 Introduction to java Class 1 Fall 2003 Shlomo Hershkop.
Exception examples. import java.io.*; import java.util.*; class IO { private String line; private StringTokenizer tokenizer; public void newline(DataInputStream.
Overview of Java I/O. Stream A Program often needs to read/write information from/to outer source/destination. Outer source/destination can be : –A File.
Files and Streams CS 21a Chapter 11 of Horstmann.
Java Audio.
ISE 582 Making Music (with MIDI) November 6, 2003 Arpi Mardirossian.
Sound in PowerPoint Demonstration Sound File Inserted in PPT  Requires existing file (wav, mp3, wma, or mid)  Insert >Movies & Sounds >Sound from file.
Chapter 22 From Performance to MIDI. Motivation  Abstractly, an MDL program denotes a Performance.  But a Performance is just a Haskell data structure.
SELECTION CSC 171 FALL 2004 LECTURE 8. Sequences start end.
MIDI ISE 599 Yun-Ching Chen. Overview Musical Instrument Digital Interface Came in 1983, conceived by a consortium of synthesizer manufacturers A serial.
Tirgul 1 Today’s subject - Java reminders and additions: –Inner classes –Packages –I/O streams –Command Line Arguments –Primitive and Reference Data Types.
Concurrency Concurrency is the rule not the exception! e.g. M.S. Word responding to the keyboard, reformatting the document, making a backup copy, checking.
Click to edit Master title style Click to edit Master text styles Second level Third level Fourth level Fifth level 1 Files.
More Multithreaded Programming in Java David Meredith Aalborg University.
16-Aug-15 Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter.
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
Cosc 5/4730 A little on threads and Messages: Handler class.
 2002 Prentice Hall, Inc. All rights reserved. Chapter 22 – Java Media Framework and Java Sound Outline 22.1 Introduction 22.2 Playing Media 22.3 Formatting.
Midi files Here we look at another way of dealing with sound on a computer the use of Midi files. The the Midi file differs from the “wav” file, because.
CSC – Java Programming II Lecture 9 January 30, 2002.
(c) 2008 E.S.Boese All Rights Reserved. Threads and Media Chapter 8 - Lecture Slides 1.
1 Lecture 12 More on Hashing Multithreading. 2 Speakers!
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
Program data (instance variables, local variables, and parameters) is transient, because its lifetime ends with the program...if not, before. Sometimes.
Based on OOP with Java, by David J. Barnes Input-Output1 The java.io Package 4 Text files Reader and Writer classes 4 Byte stream files InputStream, FileInputStream,
Unit 1 – setup and operate a digital audio workstation.
Threads in Java. Processes and Threads Processes –A process has a self-contained execution environment. –Has complete set of runtime resources including.
Chapter 2: Java Fundamentals
Digital Audio IV MIDI Overview. Sending MIDI Information I. Serial Transmission A. Single cable to move data B. Slower than parallel, but is less expensive.
© M. Winter COSC 3P91 – Advanced Object-Oriented Programming Sound effects and music Java Sound API: javax.sound.sampled 8- or 16-bit samples from.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
Input/output Input in java is stream based.A stream represents sequence of bytes or characters. Stream provides an abstract view of I/O. Stream can be.
Sound DirectMusic & DirectSound. Sound Formats Wav Midi (Musical Instrument Digital Interface) DLS (Downloadable Sounds) DirectMusic Producer Segments.
Using Plug-Ins Adding Multimedia to an HTML Document.
CS101 Lab “File input/Output”. File input, output File : binary file, text file READ/WRITE class of “text file” - File Reading class : FileReader, BufferedReader.
Files and Streams CS /02/05 L7: Files Slide 2 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved.
1 Software Construction and Evolution - CSSE 375 Exception Handling – Chaining & Threading Steve Chenoweth Office: Moench Room F220 Phone: (812)
FINAL CUT PRO X. FINAL CUT PRO LAYOUT BROWSER  View thumbnails of your clips in this window.  Change the name of clips here and set in and.
1 Sound in Java Summary: r Sound API Basics r MIDI JavaSound - Part of the UIT User Interface Toolkit.
Java Producer-Consumer Monitor From: Concurrent Programming: The Java Programming Language By Steven J. Hartley Oxford University Press, 1998.
For use with WJEC Performing Arts GCSE Unit 1 and Unit 3 Task 1 Music Technology Technical issues.
Semaphores CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Prepared by Dr. Jiying Zhao University of Ottawa Canada.
Threads b A thread is a flow of control in a program. b The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.
© M. Winter COSC 3P40 – Advanced Object-Oriented Programming 10.1 Sound effects and music Java Sound API: javax.sound.sampled 8- or 16-bit samples from.
Files and Serialization. Files Used to transfer data to and from secondary storage.
Music and Audio Computing I A Prof. Marcelo M. Wanderley Week 8.
1 CSE 331 Memento Pattern and Serialization slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
1 CSE 331 Summary of remaining Java features slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Objects, Classes, Program Constructs
Lecture 7 Announcements.
Chapter 22 – Java Media Framework and Java Sound
پروتكل آموزش سلامت به مددجو
null, true, and false are also reserved.
Condition Variables and Producer/Consumer
Sound effects and music
Condition Variables and Producer/Consumer
JavaScript Reserved Words
I/O and Applet from Chapter 12
Tutorial MutliThreading.
Use of sound within games
Presentation transcript:

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 ); }

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

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

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

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