Introduction to sound - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Introduction to sound

Description:

Sound is represented by sine waves which have two characteristics, frequency and ... sounds using the Sound Properties dialog box, or define settings for all sounds ... – PowerPoint PPT presentation

Number of Views:172
Avg rating:3.0/5.0
Slides: 20
Provided by: socSta
Category:

less

Transcript and Presenter's Notes

Title: Introduction to sound


1
Introduction
  • Introduction to sound
  • The Sound Object
  • The methods built into the Sound Object
  • Events fired by the Sound Object
  • Quirks of sounds
  • Example Code
  • More examples
  • Conclusion

2
What is Sound?
  • Sound is movement or vibration of molecules in
    the air. When the wave meets the eardrum you
    experience changes of pressure, the auditory
    nerves vibrate and you hear the sound.
  • Sound is represented by sine waves which have two
    characteristics, frequency and amplitude.
  • Sound waves vary in frequency (or pitch)
  • frequency is measured in HERTZ or Hz
  • Sound waves vary in amplitude (loudness or
    volume)
  • loudness is measured in DECIBELS or dB

3
What is Digitized sound?
  • Is sampled sound. Every so often a sample of
    sound is taken and stored as digital information
    - in bits and bytes.
  • How often these samples are taken is the sample
    rate described in Kilohertz shown like this
    11.025 KHz
  • The amount of information stored about each
    sample is the sample size and is described in
    bits.
  • Sample sizes are either 16 bit or 8 bit. The
    larger the sample size the better it describes
    the recorded sound

4
Digitized sound
  • Sound waves are not simple
    sine waves but complex waves
  • When you record a sound it is changed from an
    analog (continuous) signal to a digital signal
    using an analog to digital converter (ADC)

each dot a sample taken
5
Determining the size of digital recordings
How do we know we will have enough space to save
a recorded sound?
  • Mono
  • duration in secs x sampling rate x bit
    resolution / 8 x 1
  • e.g. 40 seconds of mono recording _at_ 11 KHz _at_ 8bit
    resolution
  • 40 x 11000 x 8/8 x 1 444,000 bytes
  • Stereo
  • duration in secs x sampling rate x bit
    resolution / 8 x 2
  • e.g. 10 seconds of stereo recording _at_ 44 KHz _at_
    16bit resolution
  • 10 x 44100 x 16/8 x 2 1,764,000 bytes
  • to obtain maximum quality, notice the vast
    difference in size

6
The Sound Object
  • The Sound object is for loading, monitoring and
    controlling sound
  • It can control individual sounds or all sounds in
    the Flash movie
  • Sounds are limited to mono or stereo
  • Often you will use sounds which have been
    imported into the library
  • but you can load larger files dynamically which
    avoids having a large initial SWF download

7
The Sound Object
  • There are two types of sounds in Flash event
    sounds and stream sounds.
  • An event sound must download completely before it
    begins playing, and it continues playing until
    explicitly stopped.
  • Stream sounds begin playing as soon as enough
    data for the first few frames has been
    downloaded stream sounds are synchronized to the
    Timeline for playing on a Web site.

8
Sound Compression
  • Select compression options to control the quality
    and size of sounds in exported movies.
  • Select compression options for individual sounds
    using the Sound Properties dialog box, or define
    settings for all sounds in the movie in the
    Publish Settings dialog box.

9
Sound Formats
  • WAV (Windows only)
  • AIFF (Macintosh only)
  • MP3 (Windows or Macintosh)

10
Sound Methods
  • Sound.loadSound(URL, streaming)
  • Loads an MP3 from a URL, streaming or file-based
  • Sound.setPan(value)
  • Simple left/right balance of the sound
  • Sound.setTransform(object)
  • Complex left/right mix and balance of the sound
  • Sound.setVolume(value)
  • Sets the volume level for a sound

11
Sound Methods
  • Sound.start(optional value, value)
  • Starts playing a sound from the beginning, or
    from an offset point (really handy why?)
  • Sound.stop(optional sound name)
  • Stops the specified sound (or all sounds)
    currently playing
  • Sound.attachSound(Linkage-name)
  • Attaches the library sound specified

12
Sound Methods
  • Sound.getVolume()
  • Returns the current value of the volume
  • Sound.getBytesTotal()
  • Returns the total size of the sound in bytes
  • Sound.getBytesLoaded()
  • Gets the number of bytes loaded so far. Why is
    this useful?

13
Event Handlers
  • When a sound finishes loading, the Sound.onLoad
    event fires good time to start playing it
  • When a sound stops playing, the
    Sound.onSoundComplete event fires, so you know
    that a new sound can be played safely
  • Each time a new ID3 data block has loaded, the
    Sound.onID3 event fires.
  • Useful for loading MP3 files and giving more
    details to the user (like the genre, full title,
    recording date and so on)

14
Quirks of sounds
  • You can load and play multiple sounds
    simultaneously
  • But if the combined volume level tries to exceed
    100, youll get clipping noise
  • Great for heavy metal guitars, bad for everything
    else
  • You can control sound volume to avoid swamping
    the sound output device
  • Or ensure that you play a limited number of
    simultaneous sounds

15
Example Code
  • // Creates a sound-handling object
  • var mySoundSound new Sound()
  • // Starts loading a simple MP3
  • // Note - file is not on a streaming server
  • mySound.loadSound("touch01.mp3", false)

16
Example Code
  • // Starts the sound as soon as it has loaded
  • mySound.onLoad function(bOkayBoolean)
  • if(bOkay true)
  • mySound.start()
  • // Could do other things here

17
Example Code
  • // The sound has finished
  • mySound.onSoundComplete function()
  • trace(Sound has finished.")
  • // Could do other things here
  • //

18
More examples
  • To control all sounds in a movie, create a Sound
    object
  • var all_soundSound new Sound()
  • all_sound.setVolume(75)
  • Sets the volume level of all the sounds playing
    to 75 of maximum

19
Conclusion
  • Flash has relatively simple sound capabilities
  • Easy to use but limited to stereo
  • Embedded sound or dynamically loaded
  • Supports streaming sounds over the network
  • Good control of balance and volume
  • Simple event interface
  • See Flash help for more details
Write a Comment
User Comments (0)
About PowerShow.com