Audio 1 - Binus Repository

Download Report

Transcript Audio 1 - Binus Repository

Audio 1
Subject
Session
Tahun
Versi
:
:
:
:
T0934 / Multimedia Programming Foundation
8
2009
1/0
Learning Outcomes
In the end of this session, students must be
able to:
– Understand the basic principal of
audio digitization and enhancement
– Identify Java Sound API syntax to
manipulate basic audio properties
Bina Nusantara
Outline
•
•
•
•
Audio Digitization
MIDI
Audio Quantization and Transmission
Java Sound API
Bina Nusantara
A Typical Audio Architecture
Bina Nusantara
http://java.sun.com/docs/books/tutorial/sound/index.html
Sound
• Sound are rapid vibrations that are transmitted
as variations in air pressure
• To use sound digitally, we must digitize
(converse to a stream of numbers) the analog
sound first
Amplitude
Analog signal
of sound
Bina Nusantara
Time
Sound Digitization
Quantization
• To fully digitize the sound, we have to
sample in Time (Sampling) and in
Amplitude (Quantization)
Sampling
Bina Nusantara
Sampling
• Sampling
– Measuring at evenly spaced intervals
• Sampling Rate
– Known as sampling frequency, measured in Hertz (Hz)
• Nyquist Rate
– To have a correct sampling, sampling rate should equal to at
least twice the maximum frequency
– If sampling rate is lower than Nyquist rate, it will result in false
(alias) frequency
Bina Nusantara
Quantization
• Sampling in the amplitude dimension, represented in
fixed numbers of bits (8, 12, or 16 bits)
• Results in a loss of precision
which is called distortion (or
called quantization noise)
• Dithering (adding random
noise to quantized audio) can
be used to remove some of
the distortion
Original
audio wave
Bina Nusantara
Quantization
error wave
Quantized
audio wave
Common Rates
Quality
Sample Rate
Quantization
Mono/Stereo
Frequency
Telephone
8
8
Mono
200-3400
AM Radio
11,025
8
Mono
100-5500
FM Radio
22,05
16
Stereo
20-11000
CD
44,1
16
Stereo
5-20000
DAT
48
16
Stereo
5-20000
192 (max)
24 (max)
Up to 6
96000 (max)
DVD audio
Bina Nusantara
Sampled Audio Format
File
Acronym
Originally
Type of Compression
Platforms
.aiff
Audio
File Format
Apple, adopted
Silicon Graphics
usually not
compressed version
Apple Macintosh and Silicon
and now also on Windows
.wav
IBM and Microsoft supports a number of
compression formats
primarily for Windows, but can be
systems
.au and Also called
.snd
or Sun muformat
Sun and NeXT
mu-law encoding
file at a ratio of 2:1;
decompression
Sun, NeXT, Unix or Linux operating
.mp3
Moving Pictures
Group
good compression rate
quality sound
cross-platform
Bina Nusantara
MPEG audio
3
Synthesizing Sounds
• Frequency Modulation (FM)
– Producing new audio signal using a source waveform’s
frequency is changed by a modulating frequency
– Based on the same principles used for FM radio trasmission
– Used in low-end versions of Creative Sound Blaster PC sound
card
• Wave-Table
– More accurate way reproducing sound
– Using actual samples of real instruments
– More expensive than FM synthesis (partly because of larger data
storage)
Bina Nusantara
MIDI
• Musical Instrument Digital Interface
• A scripting language that codes events
(MIDI messages + timings)
• Enable computers, synthesizers,
keyboards, and other musical devices to
communicate with each others.
Bina Nusantara
A Possible MIDI Configuration
Bina Nusantara
http://java.sun.com/docs/books/tutorial/sound/index.html
Synthesizers
• A sound generator that can vary pitch,
loudness, and tone color.
• Now included on PC sound cards. The
units that generate sound are called
tone/sound modules.
Bina Nusantara
Sequencers
• In the beginning, a special hardware
device for storing and editing a sequence
of musical events (MIDI data)
• Now, a software music editor on the
computer
Bina Nusantara
MIDI keyboards
• A keyboard that produces MIDI messages,
not sound
Bina Nusantara
MIDI Messages
• Sequences of MIDI instructions
Channel
messages
MIDI
messages
Voice
messages
Mode
messages
Common
messages
System
messages
Real-time
messages
Exclusive
messages
Bina Nusantara
Channel Messages
• Voice Messages
– Sends information of which note to play
– Used to control sustain, vibrato, tremolo, and pitch
• Mode Messages
– Determines how an instrument processes MIDI voice messages
(to respond all messages, respond just to correct channel, don’t
respond at all, etc)
Bina Nusantara
System Messages
• For commands that are not channelspecific
• Common messages
– Relates to timing or positioning
• Real-time messages
– Relates to synchronization
• Exclusive messages
– Included so manufacturers can extend the MIDI standard
Bina Nusantara
MIDI standard
• General MIDI (GM1)
– Standard for assigning instruments to patch numbers so MIDI
music can sound more or less the same on every machine
– Ex : patch no.1 = piano
• General MIDI level 2 (GM2)
– Extended General Midi, with SMF (Standard MIDI File) format
defined.
– Includes extra character of information such as karaoke lyrics
– Increases the number of available sounds
– Increases the amount of control available for sound editing and
musical performance
• General MIDI Lite (GML)
– For mobile applications
Bina Nusantara
Standard MIDI Files
• a digital file that contains MIDI events
• was developed in 1990 for file exchange
between MIDI sequencers
• The information in a standard MIDI file is
referred to as a sequence
• contains one or more tracks which each
typically contains the notes of a single
instrument
Bina Nusantara
Java Sound API
• Supports both sampled audio and MIDI
data
• javax.sound.sampled
– This package specifies interfaces for capture, mixing, and
playback of digital (sampled) audio.
• javax.sound.midi
– This package provides interfaces for MIDI synthesis,
sequencing, and event transport.
Bina Nusantara
Playing Sound
Full code downloadable in Additional Materi.
Bina Nusantara
Playing MP3
Create mp3 player
Open MP3 file and start player
Bina Nusantara
Playing MP3
Getting controller component
Result
Note : This program use JMF to play MP3 file.
Bina Nusantara
Full code is downloadable in Additional Materi
Playing WAV
Create player from file
Open WAV file
Getting music length
Bina Nusantara
Playing WAV
Setting control for control the music
Bina Nusantara
Playing MIDI
Bina Nusantara
Full code downloadable in Additional Materi.
References
• Basics of Digital Audio. 2001.
http://www.cs.cf.ac.uk/Dave/Multimedia/node143.html
• Developing a Strategy for Creating and Assessing Digital
Media Curriculum Material. 2004.
http://imej.wfu.edu/articles/2004/1/01/
• Midi. 2008. http://www.midi.org/
• Trail: Sound. 2008.
http://java.sun.com/docs/books/tutorial/sound/index.html
• The Java Sound API. 2009.
http://onjava.com/onjava/excerpt/jenut3_ch17/
• Sound. 2009. http://en.wikipedia.org/wiki/Sound
Bina Nusantara