~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/palmunits/soundmgr.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{$MACRO ON}
 
2
{$define Rsc := }
 
3
(******************************************************************************
 
4
 *
 
5
 * Copyright (c) 1995-2000 Palm, Inc. or its subsidiaries.
 
6
 * All rights reserved.
 
7
 *
 
8
 * File: SoundMgr.h
 
9
 *
 
10
 * Release: Palm OS SDK 4.0 (63220)
 
11
 *
 
12
 * Description:
 
13
 *    Include file for Sound Manager
 
14
 *
 
15
 * History:
 
16
 *    4/11/95  VMK - Created by Vitaly Kruglikov
 
17
 *
 
18
 *****************************************************************************)
 
19
 
 
20
unit soundmgr;
 
21
 
 
22
interface
 
23
 
 
24
uses palmos, coretraps, errorbase, preferences;
 
25
 
 
26
(************************************************************
 
27
 * Sound Manager constants
 
28
 *
 
29
 *************************************************************)
 
30
 
 
31
const
 
32
// Sound Manager max and default volume levels
 
33
  sndMaxAmp         = 64;
 
34
//sndVolumeMask     = $ff;
 
35
  sndDefaultAmp     = sndMaxAmp;
 
36
 
 
37
  sndMidiNameLength = 32; // MIDI track name length *including* NULL terminator
 
38
 
 
39
(************************************************************
 
40
 * Sound Manager data structures
 
41
 *
 
42
 *************************************************************)
 
43
 
 
44
//
 
45
// Command numbers for SndCommandType's cmd field
 
46
//
 
47
type
 
48
  SndCmdIDType = Enum;
 
49
 
 
50
const
 
51
  sndCmdFreqDurationAmp = 1;                // play a sound, blocking for the entire duration (except for zero amplitude)
 
52
                                            // param1 = frequency in Hz
 
53
                                            // param2 = duration in milliseconds
 
54
                                            // param3 = amplitude (0 - sndMaxAmp); if 0, will return immediately
 
55
 
 
56
    // Commands added in PilotOS v3.0
 
57
    // ***IMPORTANT***
 
58
    // Please note that SndDoCmd() in PilotOS before v3.0 will Fatal Error on unknown
 
59
    // commands (anything other than sndCmdFreqDurationAmp).  For this reason,
 
60
    // applications wishing to take advantage of these new commands while staying
 
61
    // compatible with the earlier version of the OS, _must_ avoid using these commands
 
62
    // when running on OS versions less thatn v3.0 (see sysFtrNumROMVersion in SystemMgr.h).
 
63
    // Beginning with v3.0, SndDoCmd has been fixed to return sndErrBadParam when an
 
64
    // unknown command is passed.
 
65
 
 
66
  sndCmdNoteOn = Succ(sndCmdFreqDurationAmp); // start a sound given its MIDI key index, max duration and velocity;
 
67
                                            // the call will not wait for the sound to complete, returning imeediately;
 
68
                                            // any other sound play request made before this one completes will interrupt it.
 
69
                                            // param1 = MIDI key index (0-127)
 
70
                                            // param2 = maximum duration in milliseconds
 
71
                                            // param3 = velocity (0 - 127) (will be interpolated as amplitude)
 
72
 
 
73
  sndCmdFrqOn = Succ(sndCmdNoteOn);         // start a sound given its frequency in Hz, max duration and amplitude;
 
74
                                            // the call will not wait for the sound to complete, returning imeediately;
 
75
                                            // any other sound play request made before this one completes will interrupt it.
 
76
                                            // param1 = frequency in Hz
 
77
                                            // param2 = maximum duration in milliseconds
 
78
                                            // param3 = amplitude (0 - sndMaxAmp)
 
79
 
 
80
  sndCmdQuiet = Succ(sndCmdFrqOn);          // stop current sound
 
81
                                            // param1 = 0
 
82
                                            // param2 = 0
 
83
                                            // param3 = 0
 
84
 
 
85
//
 
86
// SndCommandType: used by SndDoCmd()
 
87
//
 
88
 
 
89
type
 
90
  SndCommandType = record
 
91
    cmd: SndCmdIDType;             // command id
 
92
    reserved: UInt8;
 
93
    param1: Int32;                 // first parameter
 
94
    param2: UInt16;                // second parameter
 
95
    param3: UInt16;                // third parameter
 
96
  end;
 
97
 
 
98
  SndCommandPtr = ^SndCommandType;
 
99
 
 
100
//
 
101
// Beep numbers used by SndSysBeep()
 
102
//
 
103
 
 
104
type
 
105
  SndSysBeepType = Enum;
 
106
 
 
107
const
 
108
  sndInfo = 1;
 
109
  sndWarning = Succ(sndInfo);
 
110
  sndError = Succ(sndWarning);
 
111
  sndStartUp = Succ(sndError);
 
112
  sndAlarm = Succ(sndStartUp);
 
113
  sndConfirmation = Succ(sndAlarm);
 
114
  sndClick = Succ(sndConfirmation);
 
115
 
 
116
(************************************************************
 
117
 * Standard MIDI File (SMF) support structures
 
118
 *************************************************************)
 
119
 
 
120
// Structure of records in the MIDI sound database:
 
121
//
 
122
// Each MIDI record consists of a record header followed immediately by the
 
123
// Standard MIDI File (SMF) data stream.  Only SMF format #0 is presently supported.
 
124
// The first byte of the record header is the byte offset from the beginning of the record
 
125
// to the SMF data stream.  The name of the record follows the byte offset
 
126
// field.  sndMidiNameLength is the limit on name size (including NULL).
 
127
 
 
128
const
 
129
  sndMidiRecSignature = Rsc('PMrc');
 
130
 
 
131
type
 
132
  SndMidiRecHdrType = record
 
133
    signature: UInt32;             // set to sndMidiRecSignature
 
134
    bDataOffset: UInt8;            // offset from the beginning of the record
 
135
                                   // to the Standard Midi File data stream
 
136
    reserved: UInt8;               // set to zero
 
137
  end;
 
138
 
 
139
  SndMidiRecType = record
 
140
    hdr: SndMidiRecHdrType;            // offset from the beginning of the record
 
141
                                       // to the Standard Midi File data stream
 
142
    name: array [0..2-1] of Char;      // Track name: 1 or more chars including NULL terminator.
 
143
                                       // If a track has no name, the NULL character must still
 
144
                                       // be provided.
 
145
                                       // Set to 2 to pad the structure out to a word boundary.
 
146
  end;
 
147
 
 
148
// Midi records found by SndCreateMidiList.
 
149
  SndMidiListItemType = record
 
150
    name: array [0..sndMidiNameLength-1] of Char; // including NULL terminator
 
151
    uniqueRecID: UInt32;
 
152
    dbID: LocalID;
 
153
    cardNo: UInt16;
 
154
  end;
 
155
 
 
156
// Commands for SndPlaySmf
 
157
  SndSmfCmdEnum = Enum;
 
158
 
 
159
const
 
160
  sndSmfCmdPlay = 1;                       // play the selection
 
161
  sndSmfCmdDuration = Succ(sndSmfCmdPlay); // get the duration in milliseconds of the entire track
 
162
 
 
163
type
 
164
  SndComplFuncType = procedure(chanP: Pointer; dwUserData: UInt32);
 
165
  SndComplFuncPtr = SndComplFuncType;
 
166
 
 
167
// Return true to continue, false to abort
 
168
  SndBlockingFuncType = function(chanP: Pointer; dwUserData: UInt32; sysTicksAvailable: Int32): Boolean;
 
169
  SndBlockingFuncPtr = SndBlockingFuncType;
 
170
 
 
171
type
 
172
  SndCallbackInfoType = record
 
173
    funcP: MemPtr;          // pointer to the callback function (NULL = no function)
 
174
    dwUserData: UInt32;     // value to be passed in the dwUserData parameter of the callback function
 
175
  end;
 
176
 
 
177
  SndSmfCallbacksType = record
 
178
    completion: SndCallbackInfoType;     // completion callback function (see SndComplFuncType)
 
179
    blocking: SndCallbackInfoType;       // blocking hook callback function (see SndBlockingFuncType)
 
180
    reserved: SndCallbackInfoType;       // RESERVED -- SET ALL FIELDS TO ZERO BEFORE PASSING
 
181
  end;
 
182
  SndSmfCallbacksPtr = ^SndSmfCallbacksType;
 
183
 
 
184
const
 
185
  sndSmfPlayAllMilliSec = $FFFFFFFF;
 
186
 
 
187
type
 
188
  SndSmfOptionsType = record
 
189
    // dwStartMilliSec and dwEndMilliSec are used as inputs to the function for sndSmfCmdPlay and as
 
190
    // outputs for sndSmfCmdDuration
 
191
    dwStartMilliSec: UInt32;                // 0 = "start from the beginning"
 
192
    dwEndMilliSec: UInt32;                  // sndSmfPlayAllMilliSec = "play the entire track";
 
193
                                            // the default is "play entire track" if this structure
 
194
                                            // is not passed in
 
195
 
 
196
    // The amplitude and interruptible fields are used only for sndSmfCmdPlay
 
197
    amplitude: UInt16;                      // relative volume: 0 - sndMaxAmp, inclusively;  the default is
 
198
                                            // sndMaxAmp if this structure is not passed in; if 0, the play will
 
199
                                            // be skipped and the call will return immediately
 
200
 
 
201
    interruptible: Boolean;                 // if true, sound play will be interrupted if
 
202
                                            // user interacts with the controls (digitizer, buttons, etc.);
 
203
                                            // if false, the paly will not be interrupted; the default behavior
 
204
                                            // is "interruptible" if this structure is not passed in
 
205
 
 
206
    reserved1: UInt8;
 
207
    reserved: UInt32;                       // RESERVED! -- MUST SET TO ZERO BEFORE PASSING
 
208
  end;
 
209
  SndSmfOptionsPtr = ^SndSmfOptionsType;
 
210
 
 
211
  SndSmfChanRangeType = record
 
212
    bFirstChan: UInt8;                         // first MIDI channel (0-15 decimal)
 
213
    bLastChan: UInt8;                          // last MIDI channel (0-15 decimal)
 
214
  end;
 
215
  SndSmfChanRangePtr = ^SndSmfChanRangeType;
 
216
 
 
217
(************************************************************
 
218
 * Sound Manager result codes
 
219
 * (sndErrorClass is defined in SystemMgr.h)
 
220
 *************************************************************)
 
221
 
 
222
const
 
223
  sndErrBadParam    = sndErrorClass or 1;
 
224
  sndErrBadChannel  = sndErrorClass or 2;
 
225
  sndErrMemory      = sndErrorClass or 3;
 
226
  sndErrOpen        = sndErrorClass or 4;
 
227
  sndErrQFull       = sndErrorClass or 5;
 
228
  sndErrQEmpty      = sndErrorClass or 6; // internal
 
229
  sndErrFormat      = sndErrorClass or 7; // unsupported data format
 
230
  sndErrBadStream   = sndErrorClass or 8; // invalid data stream
 
231
  sndErrInterrupted = sndErrorClass or 9; // play was interrupted
 
232
 
 
233
(********************************************************************
 
234
 * Sound Manager Routines
 
235
 * These are define as syscall calls only under emulation mode or
 
236
 *  under native mode from the module that actually installs the trap
 
237
 *  vectors
 
238
 ********************************************************************)
 
239
 
 
240
//-------------------------------------------------------------------
 
241
// Initialization
 
242
//-------------------------------------------------------------------
 
243
 
 
244
// Initializes the Sound Manager.  Should only be called by
 
245
// Pilot initialization code.
 
246
function SndInit: Err; syscall sysTrapSndInit;
 
247
 
 
248
// Frees the Sound Manager.
 
249
//procedure SndFree; syscall sysTrapSndFree;
 
250
 
 
251
//-------------------------------------------------------------------
 
252
// API
 
253
//-------------------------------------------------------------------
 
254
 
 
255
// Sets default sound volume levels
 
256
//
 
257
// Any parameter may be passed as NULL
 
258
procedure SndSetDefaultVolume(var alarmAmpP, sysAmpP, defAmpP: UInt16); syscall sysTrapSndSetDefaultVolume;
 
259
 
 
260
// Gets default sound volume levels
 
261
//
 
262
// Any parameter may be passed as NULL
 
263
procedure SndGetDefaultVolume(var alarmAmpP, sysAmpP, masterAmpP: UInt16); syscall sysTrapSndGetDefaultVolume;
 
264
 
 
265
// Executes a sound command on the given sound channel (pass
 
266
// channelP = 0 to use the shared channel).
 
267
function SndDoCmd({SndChanPtr} channelP: Pointer; cmdP: SndCommandPtr; noWait: Boolean): Err; syscall sysTrapSndDoCmd;
 
268
 
 
269
// Plays one of several defined system beeps/sounds (see sndSysBeep...
 
270
// constants).
 
271
procedure SndPlaySystemSound(beepID: SndSysBeepType); syscall sysTrapSndPlaySystemSound;
 
272
 
 
273
// NEW FOR v3.0
 
274
// Performs an operation on a Standard MIDI File (SMF) Format #0
 
275
function SndPlaySmf(chanP: Pointer; cmd: SndSmfCmdEnum; var smfP: UInt8; selP: SndSmfOptionsPtr;
 
276
                    chanRangeP: SndSmfChanRangePtr; callbacksP: SndSmfCallbacksPtr;
 
277
                    bNoWait: Boolean): Err; syscall sysTrapSndPlaySmf;
 
278
 
 
279
// NEW FOR v3.0
 
280
// Creates a list of all midi records.  Useful for displaying in lists.
 
281
// For creator wildcard, pass creator=0;
 
282
function SndCreateMidiList(creator: UInt32; multipleDBs: Boolean; var wCountP: UInt16; var entHP: MemHandle): Boolean; syscall sysTrapSndCreateMidiList;
 
283
 
 
284
// NEW FOR v3.2
 
285
// Plays a MIDI sound which is read out of an open resource database
 
286
function SndPlaySmfResource(resType: UInt32; resID: Int16; volumeSelector: SystemPreferencesChoice): Err; syscall sysTrapSndPlaySmfResource;
 
287
 
 
288
 
 
289
// NEW FOR v4.0
 
290
// Plays MIDI sounds regardless of the how the interruptible flag is set
 
291
function SndPlaySmfIrregardless(chanP: Pointer; cmd: SndSmfCmdEnum; var smfP: UInt8;
 
292
                                var selP: SndSmfOptionsType; var chanRangeP: SndSmfChanRangeType;
 
293
                                var callbacksP: SndSmfCallbacksType; bNoWait: Boolean): Err; syscall sysTrapSndPlaySmfIrregardless;
 
294
 
 
295
function SndPlaySmfResourceIrregardless(resType: UInt32; resID: Int16; volumeSelector: SystemPreferencesChoice): Err; syscall sysTrapSndPlaySmfResourceIrregardless;
 
296
 
 
297
function SndInterruptSmfIrregardless: Err; syscall sysTrapSndInterruptSmfIrregardless;
 
298
 
 
299
(************************************************************
 
300
 * Sound Manager Macros
 
301
 *
 
302
 *************************************************************)
 
303
 
 
304
implementation
 
305
 
 
306
end.