Apple Newton Utilities User's Guide Page 559

  • Download
  • Add to my manuals
  • Print
  • Page
    / 942
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 558
CHAPTER 14
Sound
Using Sound 14-5
Creating Sound Frames Procedurally 14
To create a sound frame, you usually need to create a copy of the sound frame you
wish to modify. Because you cannot modify sound frames in ROM, you must copy
the sound frame in order to modify the binary
sample data.
Cloning the original version of a sound frame you want to modify also allows you
to reset values to their original state and provides a means of recovering the original
sound frame easily if an operation fails.
Cloning Sound Frames 14
You can use the Clone function to make a modiable copy of the sound frame by
passing the frame or its reference to
Clone and saving the result in a variable, as in
the following example:
clonedSound := clone(ROM_simpleBeep);
This technique is an extremely efcient means of creating a modiable sound
frame, because the copy created is a shallow clone; that is, the cloned frame
clonedSound does not actually store a copy of the ROM_simpleBeep binary
data. Instead, the
clonedSound frame stores a pointer to the ROM data in its
samples slot. Thus, the clonedSound frame is fairly lightweight in terms of
overhead in the NewtonScript heap.
Playing Sound 14
Newton system software plays sound in two ways. The rst is to use the global
sound functions
PlaySoundAtVolume or PlaySoundIrregardless. The
other way is to instantiate a sound playback channel and send messages to it. Each
approach has benets and drawbacks. Using the global functions is the simplest
and most efcient approach, but it offers less control than sending messages to a
sound channel.
Sound channels are appropriate for applications that require greater control over
playback, such as one that allows pausing playback and sound completion. Sound
channels are also useful for games, which might require having many sounds
available on short notice or playing multiple sounds at the same time.
Using a Sound Channel to Play Sound 14
Using a sound channel to play a sound is accomplished by creating a sound
channel and sending the
Start message to it.
Page view 558
1 2 ... 554 555 556 557 558 559 560 561 562 563 564 ... 941 942

Comments to this Manuals

No comments