SoundMgr.h
declares the API that this chapter describes. For more information on the sound manager, see the section "Sound" in the Palm OS Programmer's Companion.
SndCallbackInfoType
structure wraps the sound manager callback functions that you implement. See "Application-Defined Functions" for more information.
typedef struct SndCallbackInfoType {
    MemPtr funcP;
    UInt32 dwUserData;
} SndCallbackInfoType;
funcP
|
Pointer to the callback function (NULL = no function).
|
dwUserData
|
Value to pass in dwUserData parameter of callback function.
|
SndCmdIDType
enumerated type defines the commands that may be specified in the cmd
field of the
SndCommandType
. Each command defines its own specific use of the param1
, param2
, and param3
fields.
typedef enum SndCmdIDType {
    sndCmdFreqDurationAmp = 1,
    sndCmdNoteOn,
sndCmdFrqOn,
sndCmdQuiet
} SndCmdIDType;
IMPORTANT:SndDoCmd
in versions of Palm OS before 3.0 will generate a fatal error on anything other thansndCmdFreqDurationAmp
. For this reason, applications wishing to take advantage of these new commands while staying compatible with the earlier version of the OS, must avoid using these commands when running on OS versions less than v3.0. Beginning with v3.0,SndDoCmd
returnssndErrBadParam
when an unknown command is passed.
SndCommandType
structure is passed as the value of the cmdP
parameter to the
SndDoCmd
function. Its parameters are defined by the
SndCmdIDType
.
typedef struct SndCommandType {
    SndCmdIDType cmd;
UInt8 reserved;
Int32 param1;
UInt16 param2;
UInt16 param3;
} SndCommandType;
cmd
| Command ID. |
reserved
| Reserved for future use. |
param1 , param2 , param3
|
Use varies according to value of cmd .
|
SndCreateMidiList
function returns true
, its entHP
parameter holds a handle to a memory chunk containing an array of SndMidiListItemType
structures.
typedef struct SndMidiListItemType{
    Char name[sndMidiNameLength];
UInt32 uniqueRecID;
LocalID dbID;
UInt16 cardNo;
} SndMidiListItemType;
name
|
MIDI name including NULL terminator.
|
uniqueRecID
| Unique ID of the record containing the MIDI file. |
dbID
| Database (file) ID. |
cardNo
| Number of the memory card on which the MIDI file resides. |
SndMidiRecHdrType
structure defines the fixed-size portion of a Palm OS MIDI record. (See
SndCallbackInfoType
.)
typedef struct SndMidiRecHdrType {
    UInt32 signature;
UInt8 bDataOffset;
UInt8 reserved;
} SndMidiRecHdrType;
signature
|
Set to sndMidiRecSignature .
|
bDataOffset
| Offset from the beginning of the record to the Standard MIDI File data stream. |
reserved
| Set to zero. |
SndMidiRecType
structure defines a variable-length header precedes the actual MIDI data in a Palm OS MIDI record. It consists of a fixed-size MIDI record header followed by the name of the MIDI track.
typedef struct SndMidiRecType {
    SndMidiRecHdrType hdr;
    Char name[1];
} SndMidiRecType;
SndSmfCallbacksType
structure is passed as the value of the callbacksP
parameter to the
SndPlaySmf
function.
typedef struct SndSmfCallbacksType {
    SndCallbackInfoType completion;
    SndCallbackInfoType blocking;
    SndCallbackInfoType reserved;
} SndSmfCallbacksType;
completion
|
Completion callback function (see SndComplFuncType ).
|
blocking
|
Blocking hook callback function (see SndBlockingFuncType ).
|
reserved
| Reserved. Set to 0 before passing. |
SndSmfChanRangeType
structure is passed as the value of the chanRangeP
parameter to the
SndPlaySmf
function. It specifies a range of enabled channels. Events for channels outside this range are ignored.
typedef struct SndSmfChanRangeType {
    UInt8 bFirstChan;
UInt8 bLastChan;
} SndSmfChanRangeType;
SndSmfOptionsType
structure is passed as the value of the selP
parameter to the
SndPlaySmf
function.
typedef struct SndSmfOptionsType {
    UInt32 dwStartMilliSec;
    UInt32 dwEndMilliSec;
    UInt16 amplitude;
Boolean interruptible;
UInt8 reserved1;
UInt32 reserved;
} SndSmfOptionsType;
Boolean SndCreateMidiList (UInt32 creator, Boolean multipleDBs, UInt16* wCountP, MemHandle *entHP)
  |
-> |
Creator of database in which to find MIDI records. Pass 0 for wildcard. |
  |
-> |
Pass true to search multiple databases for MIDI records. Pass false to search only in the first database found that meets search criteria. |
  |
<-> |
When the function returns, contains the number of MIDI records found. |
  |
<-> |
When the function returns, this handle holds a a memory chunk containing an array of SndMidiListItemType if MIDI records were found. |
false
if no MIDI records were found, true
if MIDI records were found. When this function returns true
, it updates the wCountP
parameter to hold the number of MIDI records found and updates the entHP
parameter to hold a handle to an array of SndMidiListItemType
structures. Each record of this type holds the name, record ID, database ID, and card number of a MIDI record.
3.0 New Feature Set
is present.
DmFindRecordByID
,
DmOpenDatabase
,
DmQueryRecord
,
DmOpenDatabaseByTypeCreator
,"Rock Music" sample code
Err SndDoCmd (void* channelP, SndCommandPtr cmdP, Boolean noWait)
  |
-> |
Pointer to sound channel. Present implementation doesn't support multiple channels. Must be NULL . |
  |
|
Passing NULL for the channel pointer causes the command to be sent to the shared sound channel; currently, this is the only option. |
  |
-> |
Pointer to a SndCommandType holding a parameter block that specifies the note to play, its duration, and amplitude. |
  |
-> |
Because asynchronous mode is not yet supported for all commands, you must pass 0 for this value. |
  |
|
In the future, pass 0 to await completion (synchronous) and pass a nonzero value to specify immediate return (asynchronous). |
  |
0 |
No error. |
  |
|
Invalid parameter. |
  |
|
Invalid channel pointer. |
  |
|
Sound queue is full. |
SndCmdIDType
) other than sndCmdFreqDurationAmp
are implemented only if
3.0 New Feature Set
is present.
SndPlaySmf
void SndGetDefaultVolume (UInt16* alarmAmpP, UInt16* sysAmpP, UInt16* masterAmpP)
  |
<-> a |
Pointer to storage for alarm amplitude. |
  |
<-> |
Pointer to storage for system sound amplitude. |
  |
<-> |
Pointer to storage for master amplitude. |
NULL
. In that case, the corresponding setting is not returned.
cmd
parameter: play the specified standard MIDI file (SMF) or return the number of milliseconds required to play the entire SMF.
Err SndPlaySmf (void* chanP, SndSmfCmdEnum cmd, UInt8* smfP, SndSmfOptionsType* selP, SndSmfChanRangeType* chanRangeP, SndSmfCallbacksType* callbacksP, Boolean bNoWait)
  |
|
The sound channel used to play the sound. This value must always be NULL because current versions of Palm OS provide only one sound channel that all applications share. |
  |
|
The operation to perform, as specified by one of the following selectors: |
  |
|
Play the selection synchronously. |
  |
|
Return the duration of the entire SMF, expressed in milliseconds. |
  |
-> |
Pointer to the SMF data in memory. This pointer can reference a valid SndCallbackInfoType followed by MIDI data, or it can point directly to the beginning of the SMF data. |
  |
-> |
NULL or a pointer to a SndSmfChanRangeType specifying a continuous range of MIDI channels 0 -15 to use for playback. If this value is NULL , all tracks are played. |
  |
-> |
NULL or a pointer to a SndSmfCallbacksType that holds your callback functions. Functions of type SndBlockingFuncType execute periodically while a note is playing, and functions of type SndComplFuncType execute after playback of the SMF completes. For more information, see the "Application-Defined Functions" section. |
  |
|
This value is ignored. This function always finishes playing the SMF selection before returning; however, you can execute a callback function while the SMF is playing. |
0
if no error. When an error occurs, this function returns one of the following values; for more information see the SoundMgr.h
file included with the Palm OS 3.X SDK:
SndPlaySmfResource
,
SndDoCmd
,
SndCreateMidiList
Err SndPlaySmfResource (UInt32 resType, Int16 resID, SystemPreferencesChoice volumeSelector)
  |
-> |
Card number of the database containing the SMF resource. |
  |
-> |
Resource ID of the SMF resource. |
  |
-> |
Volume setting to use. The volume is read out of the system preferences. Possible values for this parameter are: |
  |
|
prefSysSoundVolumeprefGameSoundVolumeprefAlarmSoundVolume |
SndPlaySmf
. It plays an SMF sound stored in a resource database. This function plays the entire sound on all MIDI channels at the volume specified and allows the sound to be interrupted by a key down event or a digitizer event. No callbacks are specified.
void SndPlaySystemSound (SndSysBeepType beepID)
SndSysBeepType
enum is defined in SoundMgr.h
as follows:
typedef enum SndSysBeepType {
    sndInfo = 1,
    sndWarning,
    sndError,
    sndStartUp,
    sndAlarm,
    sndConfirmation,
    sndClick
    } SndSysBeepType;
sndAlarm
still blocks, but the rest of these system sounds are implemented asynchronously.
SndPlaySmf
function.
void SndComplFuncType (void* chanP, UInt32 dwUserData)
  |
-> |
The sound channel used to play the sound. This value must always be NULL because current versions of Palm OS provide only one sound channel that all applications share. |
  |
-> |
Application-defined data that this function needs to access, or NULL . |
SndSmfCallbacksType
Boolean SndBlockingFuncType (void* chanP, UInt32 dwUserData, Int32 sysTicksAvailable)
  |
-> |
The sound channel used to play the sound. This value must always be NULL because current versions of Palm OS provide only one sound channel that all applications share. |
  |
-> |
Application-defined data that this function needs to access. |
  |
-> |
The maximum amount of time available for completion of this function, or NULL . |
true
to continue playback, or false
to cancel playback.
SndSmfCallbacksType
,
SndPlaySmf
  |   |