background image
C H A P T E R 1 4
Using Sound
For an example that uses output from a view based on the
prototype, see the Newton DTS sample code on this topic.
Manipulating Sample Data
This section describes how to use the utility functions
to manipulate individual bytes in sound sample data. Because of
performance considerations, you'll want to manipulate sample data on the Newton
only when it's absolutely necessary. Even simple operations, like the example here,
can take a long time to perform on a relatively small sound sample.
The following example, extracts bytes from the end of the sample data and adds
them to its beginning, thus reassembling the samples in reverse order to create a
"backwards" sound.
// backwardSound is a slot in the app's base view
// if it's nil then create the backward sound
if (not backwardSound) then
// get a frame to work with
backwardSound := deepclone(ROM_funbeep);
// a var to store the modified sample data
local sampleHolder := Clone(backwardSound.samples);
local theSize := Length(sampleHolder) -1 ;
// Copy bytes from one end of the binary object
// to the other.
for i := 0 to theSize do
A better solution is to provide the backwards sound as a resource that can be
played just like any other sound; a number of sound editors are available to create
such a resource on a desktop computer.
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна