Contents > Library Reference > Sound

Sound

Functions for generating sounds. The playWave function is implemented in the OrbSound native add-in. To use it, you must #include "OrbSound.oc". The source code is available in the samples directory.

Functions

void beep(int type) Generate one of the pre-defined system beeps.
void tone(int freq, int dur, int vol) Synchronously play a tone of frequency freq, at volume vol, for duration dur. An application should play the sound at the volume specified by the system preferences by first calling UIApp.getSysPref().
void tonea(int freq, int dur, int vol) Asynchronously play a tone of frequency freq, at volume vol, for duration dur. An application should play the sound at the volume specified by the system preferences by first calling UIApp.getSysPref().
void tonema(int key, int dur, int vel) Asynchronously play the note key, at velocity (volume) vel, for duration dur.
void playWave(int resID, int volume, bool async) Plays the WAVE resource with resource ID resID at the specified volume. If async is false, the function will not return until the WAVE is completely played.

Contents > Library Reference > Sound > beep

beep

void beep(int type)

Parameters:

type beep type

Generate one of the pre-defined system beeps.

Note: Available beeps are beepInfo, beepWarning, beepError, beepStartUp, beepAlarm, beepConfirmation, beepClick.
Contents > Library Reference > Sound > tone

tone

void tone(int freq, int dur, int vol)

Parameters:

freq frequency in Hz
dur duration in milliseconds
vol volume (0-64)

Synchronously play a tone of frequency freq, at volume vol, for duration dur. An application should play the sound at the volume specified by the system preferences by first calling UIApp.getSysPref().


Contents > Library Reference > Sound > tonea

tonea

void tonea(int freq, int dur, int vol)

Parameters:

freq frequency in Hz
dur duration in milliseconds
vol volume (0-64)

Asynchronously play a tone of frequency freq, at volume vol, for duration dur. An application should play the sound at the volume specified by the system preferences by first calling UIApp.getSysPref().


Contents > Library Reference > Sound > tonema

tonema

void tonema(int key, int dur, int vel)

Parameters:

key MIDI key value
dur duration in milliseconds
vel velocity (0-127)

Asynchronously play the note key, at velocity (volume) vel, for duration dur.


Contents > Library Reference > Sound > playWave

playWave

void playWave(int resID, int volume, bool async)

Parameters:

resID resource ID of WAVE resource
volume volume (0-1024) or a value below
async true to play asynchronously

Plays the WAVE resource with resource ID resID at the specified volume. If async is false, the function will not return until the WAVE is completely played.

Note: A volume of 1024 plays the WAVE at the original volume. Special volumes are sndSystemVolume, sndGameVolume, sndAlarmVolume.

Example:

Embed a WAVE file in the app, and play it.

@resource {
  type = "WAVE";
  id = 1000;
  file = "blink.wav";
}

handler playButton.onselect() {
  playWave(1000, sndSystemVolume, true);
}