C H A P T E R 1 4
Sound
About Newton Sound
14-3
For example, to play a sound in ROM when the view opens, place its name in the
view's
showSound
slot.
In fact, all
ROM_
soundName constants are pointers to Newton sound frames stored
in ROM. Instead of using one of these constants; however, you can store a Newton
sound frame in a slot, causing the sound stored in that frame to play in
accompaniment to the event associated with that slot. The next section describes
the format of a Newton sound frame.
Sound Data Structures
14
Three data structures are related to sounds: a sound frame, a sound result frame,
and a
protoSoundChannel
.
A sound frame stores sound sample data and additional information used internally
by the system. A sound result frame returns information to the sound frame when
the sound channel stops or pauses. Like any other frame, a sound frame and sound
result frame cannot be greater than 32 KB in size. See "Sound Data Structures"
(page 11-1) in the Newton Programmer's Reference, for a complete list of slots
required by for both types of frames.
The
protoSoundChannel
provides methods that implement pause and playback
of sounds and completion callbacks. It also provides query methods that return
whether the sound is running or paused.
If you are providing custom sounds, you can store them as virtual binary objects.
An example of storing a sound as a VBO is given in Chapter 11, "Data Storage and
Retrieval.".
Compatibility
14
Sound frames have been extended so that those in version 1.x can be played
without modification by devices based on version 2.0 of the Newton ROM. Not all
Newton 2.0 sound frames can be played by older Newton devices.
Two new functions have been added:
PlaySoundAtVolume
and
PlaySoundIrregardless
.
PlaySoundAtVolume
plays a sound specified by
the sound frame at a specific volume level.
PlaySoundIrregardless
plays a
sound no matter what the user's settings are.