Speaker Component - Maple Help

Speaker Component

Insert a speaker in a Standard Maple worksheet or document.

Description

 • 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.
 Component Palette Image

Speaker Properties

 • 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 x true or false device x x string mute x x true or false samplerate x x positive integer stereo x x true or false tooltip x x string type x string value x Matrix visible x x true or false volume x x positive integer

 enabled
 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.
 device
 The speaker device to use for playing sound.
 mute
 Whether the speaker is muted or not.
 samplerate
 The sample rate for playing sound (in Hz). 44100Hz is CD quality.
 stereo
 Whether audio is played using one channel (mono) or two channels (stereo).
 tooltip
 The text that appears when the user hovers the mouse over the speaker component.
 type
 The type of the component. This returns "Speaker".
 value
 Audio data sent to the speaker.
 visible
 Whether the speaker component is visible. By default, the value is true.
 volume
 The volume of the speaker. By default, the value is 5.

Example



 > with(DocumentTools):

The following lines store the data from an audio file in the Array, R:

 ${R}{:=}\left[\begin{array}{c}{\mathrm{1..64724 x 1..2}}{\mathrm{Array}}\\ {\mathrm{Data Type:}}{{\mathrm{float}}}_{{8}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{C_order}}\end{array}\right]$ (4.1)

Certain properties of the speaker can be set or retrieved from the speaker component:

 > SetProperty("Speaker0", stereo, true);
 > srate := attributes(R)[1];
 ${\mathrm{srate}}{:=}{44100}$ (4.2)
 > 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);