Speaker Component
Insert a speaker in a Standard Maple worksheet or document.
Description
Component Palette Image
Speaker Properties
Example
The speaker component is used to play sound.
The speaker component is customized by setting options in the Speaker context panel. To display the Speaker context panel, click the embedded component. Actions are associated with components using routines in the DocumentTools package.
The Name property is used to reference the component when using routines from the DocumentTools package.
The following table describes the control and use of the speaker component options:
An x in the Get column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.
An x in the Set column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.
Option
Get
Set
Option Type
enabled
x
true or false
device
string
mute
samplerate
positive integer
stereo
tooltip
type
value
Matrix
visible
volume
Whether the component is enabled. If enabled is set to false, the component is dimmed and any action associated with it cannot be initiated. By default, the value is true.
The speaker device to use for playing sound.
Whether the speaker is muted or not.
The sample rate for playing sound (in Hz). 44100Hz is CD quality.
Whether audio is played using one channel (mono) or two channels (stereo).
The text that appears when the user hovers the mouse over the speaker component.
The type of the component. This returns "Speaker".
Audio data sent to the speaker.
Whether the speaker component is visible. By default, the value is true.
The volume of the speaker. By default, the value is 5.
with(DocumentTools):
The following lines store the data from an audio file in the Array, R:
audiofile := cat(kernelopts(datadir), "/audio/ViolinThreePosVibrato.wav");
R := AudioTools:-Read(audiofile);
Certain properties of the speaker can be set or retrieved from the speaker component:
SetProperty("Speaker0", stereo, true);
srate := attributes(R)[1];
srate:=44100
SetProperty("Speaker0", samplerate, srate);
The speaker can start playing using either a programmatic command, or by using the AudioTools:-Play command:
SetProperty("Speaker0", value, R);
AudioTools:-Play(R);
See Also
AudioTools
AudioTools[Play]
DocumentTools
DocumentTools[GetProperty]
DocumentTools[SetProperty]
EmbeddedComponents
MicrophoneComponent
Download Help Document