NXC
Version 1.2.1 r5
|
Constants and functions related to the Sound module. More...
Modules | |
Sound module constants | |
Constants that are part of the NXT firmware's Sound module. | |
Sound module functions | |
Functions for accessing and modifying sound module features. | |
Sound module types | |
Types used by various sound module functions. | |
Constants and functions related to the Sound module.
The NXT sound module encompasses all sound output features. The NXT provides support for playing basic tones as well as two different types of files.
Sound files (.rso) are like .wav files. They contain thousands of sound samples that digitally represent an analog waveform. With sounds files the NXT can speak or play music or make just about any sound imaginable.
Melody files are like MIDI files. They contain multiple tones with each tone being defined by a frequency and duration pair. When played on the NXT a melody file sounds like a pure sine-wave tone generator playing back a series of notes. While not as fancy as sound files, melody files are usually much smaller than sound files.
When a sound or a file is played on the NXT, execution of the program does not wait for the previous playback to complete. To play multiple tones or files sequentially it is necessary to wait for the previous tone or file playback to complete first. This can be done via the Wait API function or by using the sound state value within a while loop.
The NXC API defines frequency and duration constants which may be used in calls to PlayTone or PlayToneEx. Frequency constants start with TONE_A3 (the 'A' pitch in octave 3) and go to TONE_B7 (the 'B' pitch in octave 7). Duration constants start with MS_1 (1 millisecond) and go up to MIN_1 (60000 milliseconds) with several constants in between. See NBCCommon.h for the complete list.