Microphone Component - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Document Tools : Embedded Components : MicrophoneComponent

Microphone Component

Insert a microphone in Standard Maple worksheet or document.

 

Description

Component Palette Image

Microphone Properties

Microphone Actions

Example

See Also

Description

• 

The microphone component is used to capture sound from a recording device.

• 

The microphone component is customized by setting options in the Microphone context panel. To display the Microphone 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 microphone component must be assigned to a microphone on your system. To do this, open the context panel and then select a microphone from Microphone Device.

• 

Each microphone component must be assigned its own Microphone Device. That is, if you have two microphone components on your worksheet, you cannot assign the same microphone to both components.

Component Palette Image

Microphone Properties

 

• 

The following table describes the control and use of the microphone 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

device

x

x

string

enabled

x

x

true or false

record

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

  

 

  

device 

  

The microphone device to use for recording sound.

  

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.

  

record 

  

Whether the microphone is recording. Set this property to true to start capturing sound.

  

samplerate 

  

The sample rate for recording sound in Hz. 44100Hz is CD quality.

  

stereo

  

Whether audio is captured using one channel (mono) or two channels (stereo).

  

tooltip 

  

The text that appears when the user hovers the mouse over the microphone component.

  

type 

  

The type of the component. This returns "Microphone".

  

value

  

A buffer that stores input from the microphone. When this is programmatically queried, the values for the buffer are returned, and the current buffer is emptied.

  

visible 

  

Specifies if the microphone component is visible. By default, the value is true.

Microphone Actions

The Maple code in the "Recording Start Action" is called when a recording is started, either by clicking on the microphone icon or by setting the record property to true.

The Maple code in the "Recording End Action" is called when a recording is stopped, either by clicking on the microphone icon or by setting the record property to false.

Example

 

 

with(DocumentTools):

The microphone can start recording using either a programmatic command, or by just clicking on the component.

SetProperty("Microphone0", record, true);

 

Once the microphone is recording, its "value" is a storage buffer that holds up to the microphone's sample rate divided by 2 values. In order to record a sound, this buffer needs to be continually emptied into another storage table.

R := GetProperty("Microphone0", value);

R:= 1 .. 8000 ArrayData Type: float8Storage: rectangularOrder: Fortran_order

(5.1)

 

The microphone can be turned off either programmatically or by clicking on the microphone component again.

SetProperty("Microphone0", record, false);

 

Certain properties of the microphone can be set or retrieved from the microphone:

rate := GetProperty("Microphone0", samplerate);

rate:=16000

(5.2)

 

The AudioTools:-Record command can be used to capture a sample of a given duration:

Recording := AudioTools:-Record(2*Unit('s'), "Microphone0");

 

Recording:= 1 .. 32000 ArrayData Type: float8Storage: rectangularOrder: C_order

(5.3)

If a speaker component is present, this rtable can be played back, otherwise the AudioTools:-Preview command can display the dynamics of this sound.

AudioTools:-Preview(Recording, output = embed);

   

See Also

Application: Interaural Time Delay, AudioTools, AudioTools[Record], DocumentTools, DocumentTools[GetProperty], DocumentTools[SetProperty], EmbeddedComponents, SpeakerComponent