© 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.

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

1 Streams and Input/Output Files Part I. 2 Introduction So far we have used variables and arrays for storing data inside the programs. This approach poses.
Jan Java I/O Yangjun Chen Dept. Business Computing University of Winnipeg.
A Phonetician ’ s Guide to Audio Formats Chilin Shih University of Illinois at Urbana Champaign LSA 2006January 5-8, 2006.
Digital Audio Teppo Räisänen LIIKE/OAMK. General Information Auditive information is transmitted by vibrations of air molecules The speed of sound waves.
Audio Programming With Python Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See
Investigating the sound quality of different audio file formats In this activity, we are going to record a short voice sample with a sound recording tool,
4.1Different Audio Attributes 4.2Common Audio File Formats 4.3Balancing between File Size and Audio Quality 4.4Making Audio Elements Fit Our Needs.
Sound Engine Evaluation for Computer Games Case Study: fmod Jyun-Ming Chen.
Part A Multimedia Production Rico Yu. Part A Multimedia Production Ch.1 Text Ch.2 Graphics Ch.3 Sound Ch.4 Animations Ch.5 Video.
Int 2 Multimedia Revision. Digitised Sound Analogue sound recorded from person, or real instruments.
III. Streams. Introduction Often a program needs to bring in information from an external source or to send out information to an external destination.
I Power Higher Computing Multimedia technology Audio.
Audio Programming in Java
Java Sound API Medialogy, Semester 7, 2010 Aalborg University, Aalborg David Meredith
LEFT CLICK OR PRESS SPACE BAR TO ADVANCE, PRESS P BUTTON TO GO BACK, PRESS ESC BUTTON TO END LEFT CLICK OR PRESS SPACE BAR TO ADVANCE, PRESS P BUTTON.
Image and Sound Editing Raed S. Rasheed Digital Sound Digital sound types – Monophonic sound – Stereophonic sound – Quadraphonic sound – Surround.
Digital audio recording Kimmo Tukiainen. My background playing music since I was five first time in a studio at fourteen recording on my own for six months.
Audio Basic Concepts. Audio in Multimedia Digital Audio: Sound that has been captured or created electronically by a computer In a multimedia production,
1 Digital Audio Storage Formats. 2 Formats  There are many different formats for storing and communicating digital audio:  CD audio  Wav  Aiff  Au.
Java Audio.
Implementing 3D Digital Sound In “Virtual Table Tennis” By Alexander Stevenson.
1 Manipulating Digital Audio. 2 Digital Manipulation  Extremely powerful manipulation techniques  Cut and paste  Filtering  Frequency domain manipulation.
Algorithm Programming Exercise 1 Bar-Ilan University תשס"ח by Moshe Fresko.
Week 8: Audio Processing 1.  Light and sound are both transmitted in waves 2.
/t/ / I d/ /d/ Try Again Go on /t/ / I d/ /d/
Introduction to Digital Audio
 Continuous sequence of vibrations of air  (Why no sound in space? Contrary to Star Wars etc.)  Abstraction of an audio wave:  Ear translates vibrations.
KS3 – Grade8, Yew Wah. Main controls at the left top. It’s a standard media player.
Problem Solving with Data Structures using Java: A Multimedia Approach Chapter 5: Arrays: A Static Data Structure for Sounds.
1 Week 10: Audio Recording. 2 Overview  What is sound?  What does analogue mean?  Analogue-to-Digital conversion  Key terms in digital audio  Compression.
Echolocation II Sonar Radar Who launches first? Sonar “Ping” Who finds the other first? SONAR in ships works like echolocation in whales and bats. The.
Linux Audio Mangler Project Design Presentation Yu Chong Hector Urtubia Tony Zuliani.
AUDIO MEDIA 1 Created } “Borrowed” } Microphone MIDI keyboard CD’s & flash drives Internet Audio Sources 2.
Sound and audio. Table of Content 1.Introduction 2.Properties of sound 3.Characteristics of digital sound 4.Calculate audio data size 5.Benefits of using.
Signal Digitization Analog vs Digital Signals An Analog Signal A Digital Signal What type of signal do we encounter in nature?
COSC 1P02 Introduction to Computer Science 4.1 Cosc 1P02 Week 4 Lecture slides “Programs are meant to be read by humans and only incidentally for computers.
3rd Workshop on Power Converters for Particle Accelerators (POCPA) 2012 Digital Regulation by Emulating Analogue Controllers: Implementation The sound.
Games Development Practices Sound Effects & OpenAL CO2301 Games Development 1 Week 15.
Sound element Week - 11.
Digital Sound Actual representation of sound Stored in form of thousands of individual numbers (called samples) Not device dependent Stored in bits.
Semaphores, Locks and Monitors By Samah Ibrahim And Dena Missak.
Georgia Institute of Technology Introduction to Processing Digital Sounds part 1 Barb Ericson Georgia Institute of Technology Sept 2005.
MICROCOMPUTER SYSTEMS 1 SulTan BINHUMOOD Final Project Presentation.
ITEC Final Presentation For Fall 2011 Table of Content –Basic Requirements  Audacity  Inskcape  GIMP  Blender  Animation of 2D and 3D.
© M. Winter COSC 3P91 – Advanced Object-Oriented Programming Sound effects and music Java Sound API: javax.sound.sampled 8- or 16-bit samples from.
Digital Music to Sheet Music Hugh Smith. Abstract Electronic music has been steadily expand- ing over the past years. Many file formats have come into.
Sound in Multimedia Psychology of sound what do you use it for? what techniques for its communication exist? Science of sound why does it exist? how it.
Digital Audio. Acknowledgement Some part of this lecture note has been taken from multimedia course made by Asst.Prof.Dr. William Bares and from Paul.
Intro-Sound-part1 Introduction to Processing Digital Sounds part 1 Barb Ericson Georgia Institute of Technology Oct 2009.
– Advanced Programming P ROGRAMMING IN Lecture 22 Input and Output System.
1 Sound in Java Summary: r Sound API Basics r MIDI JavaSound - Part of the UIT User Interface Toolkit.
SOUND SECONDARY 3 PHYSICS. NATURE AND PRODUCTION OF SOUND Sound is….. A form of energy an example of longitudinal wave Produced by vibrating sources placed.
PROG Mobile Java Application Development PROG Mobile Java Application Development Data Storage, Continued.
Week 7 - Friday.  What did we talk about last time?  Array examples  Sound.
Digital Audio II. Volume Scaling The volume of a digitized audio source may be increased or decreased by multiplying each sample value by an appropriate.
Interactive Multimedia Sound Mikael Fernström. Data sources Microphones and transducers –Sample acoustic reality Synthesis –Simulate reality (and beyond.
Audio Streaming © Nanda Ganesan, Ph.D.. Audio File Features Audio file is a record of captured sound that can be played back –The WAV File is an example.
1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
PJV25 1 javax.sound.midi try { Sequencer seq = MidiSystem.getSequencer( ); seq.open( ); Sequence z = MidiSystem.getSequence( new File( "res/song.mid" )
Week 7 - Wednesday.  What did we talk about last time?  Introduction to arrays  Lab 6.
Java Programming: Advanced Topics 1 Input/Output and Serialization.
1 Section 5.4 Digital Sound Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Yongchang, Kai, Justin, Rama
Convert Sounds to the IIGS from Windows, Mac, Linux, Solaris,
null, true, and false are also reserved.
Sound effects and music
Sound Review 2017 Answers.
Games Development Practices Sound Effects
Creating Sounds and MIDI
Presentation transcript:

© 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 8,000Hz to 48,000Hz mono or stereo sound file formats: AIFF, AU, WAV (Examples: 16-bit, mono, 44,100Hz, WAV) ‏

© M. Winter COSC 3P40 – Advanced Object-Oriented Programming 10.2 Loading and playing a sound try { File file = new File(“…”); AudioInputStream stream = AudioSystem.getAudioInputStream(file); AudioFormat format = stream.getFormat(); } catch(Exception ex) { // IOException or UnsupportedAudioFileException } try { DataLine info = new DataLine.Info(SourceDataLine,format); line = (SourceDataLine) AudioSystem.getLine(info); line.open(format,bufferSize); } catch(Exception ex) { // LineUnavailableException }

© M. Winter COSC 3P40 – Advanced Object-Oriented Programming 10.3 try { int numBytesRead = 0; while (numBytesRead != -1) { numBytesRead = stream.read(buffer, 0, buffer.length); if (numBytesRead != -1) { line.write(buffer, 0, numBytesRead); } } catch (Exception ex) { // IOException }; line.drain(); line.close();

© M. Winter COSC 3P40 – Advanced Object-Oriented Programming 10.4 Sound filter Examples: echo filter simulated 3D sound filter SoundFilter class (abstract class): filter(byte[] buffer, int offset, int length) – Filters an array of samples. getRemainingSize() – Gets the remaining size, in bytes, that this filter can play after the sound is finished. reset() – Resets the filter so that it can be used again on a different sound.

© M. Winter COSC 3P40 – Advanced Object-Oriented Programming 10.5 FilteredSoundStream public class FilteredSoundStream extends FilterInputStream { … public int read(byte[] samples, int offset, int length) throws IOException { int bytesRead = super.read(samples, offset, length); if (bytesRead > 0) { soundFilter.filter(samples, offset, bytesRead); return bytesRead; }; if (remainingSize == REMAINING_SIZE_UNKNOWN) { remainingSize = soundFilter.getRemainingSize(); remainingSize = remainingSize / 4 * 4; };

© M. Winter COSC 3P40 – Advanced Object-Oriented Programming 10.6 if (remainingSize > 0) { length = Math.min(length, remainingSize); for (int i=offset; i<offset+length; i++) { samples[i] = 0; }; soundFilter.filter(samples, offset, length); remainingSize-=length; return length; } else { return -1; }; }

© M. Winter COSC 3P40 – Advanced Object-Oriented Programming 10.7 Echo filter delay : numbers of samples to delay (44,100Hz sound, 1 sec delay = 44,100 samples) ‏ decay : value from 0 to 1 –0 means no echo –1 means the echo is the same volume as the original sound Delay Original sound First echo Second echo

© M. Winter COSC 3P40 – Advanced Object-Oriented Programming 10.8 Emulating 3D sound Many different effects are used to create 3D sounds. Make sound diminish with distance so the farther away a sound source is, the quieter it is. Pan sounds to the appropriate speaker. Apply room effects so sound waves bounce off walls, creating echoes and reverberation. Apply the Doppler effect so a sound source movement affect its pitch.

© M. Winter COSC 3P40 – Advanced Object-Oriented Programming 10.9 SoundManager The SoundManager class has the following features: provides a common interface for loading and playing sounds (including filters), extends the ThreadPool class, each thread in the thread pool has its own buffer and line object (thread-local variables).