beautypg.com

Using sound 14, Creating and using custom sound frames 14 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 558

background image

C H A P T E R 1 4

Sound

14-4

Using Sound

Using Sound

14

This section describes how to use sound to perform specific tasks. See

Newton

Toolkit User’s Guide

for descriptions of the functions and methods discussed in

this section.

Creating and Using Custom Sound Frames

14

The following information applies to the Mac OS version of NTK. The Windows
version differs; see the

Newton Toolkit User’s Guide

for details.

The compile-time functions

GetSound

and

GetSound11

allow you to use the

Newton Toolkit to create Newton sound frames from Mac OS

'snd '

resource

data. This section summarizes the main steps required to create custom sound
frames from Mac OS

'snd '

resources in NTK; for a complete discussion of this

material, see the

Newton Toolkit User’s Guide

.

Follow these steps to add a custom sound to your application:

1. Include the sound resource file in your application’s NTK project.

2. In your application, create an evaluate slot to reference the sound frame through

a compile-time variable.

3. In your Project Data file

Open the sound resource file with

OpenResFile

or

OpenResFileX

.

If using

OpenResFileX

, store the file reference it returns.

Use the functions

GetSound11

or

GetSound

to obtain the sound frame.

Use a compile-time variable to store the sound frame returned by

GetSound

or

GetSound11

.

Use the function

CloseResFile

or

CloseResFileX

, as appropriate, to

close the sound resource file. If you use the

CloseResFileX

function, you

need to pass as its argument the saved file reference originally returned by

OpenResFileX

.

4. In your application

Set the value of the evaluate slot to the name of the compile-time variable
that stores the sound frame.

Pass the name of the evaluate slot as the argument to the

PlaySoundSync

function. These run-time functions play sound from anywhere in your code.