class MAGES::WebMicrophone::WebMicrophone¶
Overview¶
Web microphone implementation. More…
class WebMicrophone: public MAGES::LocalMicrophone::IApi { public: // properties IEnumerableDevices; // methods bool JS_Microphone_InitOrResumeContext(); int JS_Microphone_GetSampleRate(int deviceIndex); int JS_Microphone_GetPosition(int deviceIndex); bool JS_Microphone_IsRecording(int deviceIndex); int JS_Microphone_GetBufferInstanceOfLastAudioClip(); void JS_Microphone_Start( int deviceIndex, int bufferInstance, int samplesPerUpdate ); void JS_Microphone_End(int deviceIndex); void End(string deviceName); void GetDeviceCaps(string deviceName, out int minFreq, out int maxFreq); int GetPosition(string deviceName); bool IsRecording(string deviceName = null); AudioClip Start(string deviceName, bool loop, int lengthSec, int frequency); };
Inherited Members¶
public: // properties IEnumerableDevices; // methods AudioClip Start(string deviceName, bool loop, int lengthSec, int frequency); void End(string deviceName); void GetDeviceCaps(string deviceName, out int minFreq, out int maxFreq); int GetPosition(string deviceName); bool IsRecording(string deviceName = null);
Detailed Documentation¶
Web microphone implementation.
Properties¶
IEnumerableDevices
Gets a list of available microphone devices.
Methods¶
void End(string deviceName)
Stop recording from the microphone.
If you pass a null or empty string for the device name then the default microphone is used. You can get a list of available microphone devices from the devices property.
Parameters:
deviceName |
The name of the device. |
void GetDeviceCaps(string deviceName, out int minFreq, out int maxFreq)
Get the frequency capabilities of a device.
Passing null or an empty string for the device name will select the default device. You can use the devices property to get a list of all available microphones. When a value of zero is returned in the minFreq and maxFreq parameters, this indicates that the device supports any frequency. </remarks
Parameters:
deviceName |
The name of the device. |
minFreq |
Returns the minimum sampling frequency of the device. |
maxFreq |
Returns the maximum sampling frequency of the device. |
int GetPosition(string deviceName)
Gets the position in samples of the recording.
If you pass a null or empty string for the device name then the default microphone will be used. You can get a list of available microphone devices from the devices property. You can use this to control latency. If you want a 30ms latency, poll GetPosition() until 30ms (in samples) has gone and then start the audio.
Parameters:
deviceName |
The name of the device. |
Returns:
The position in samples of the recording.
bool IsRecording(string deviceName = null)
Query if a device is currently recording.
If you pass a null or empty string for the device name then the default microphone will be used. You can get a list of available microphone devices from the devices property.
Parameters:
deviceName |
The name of the device. |
Returns:
Value indicating whether the device is recording.
AudioClip Start(string deviceName, bool loop, int lengthSec, int frequency)
Start recording from the microphone.
If you pass a null or empty string for the device name then the default microphone is used. You can get a list of available microphone devices from the devices property and the range of sample rates supported by a microphone from the GetDeviceCaps property.
Parameters:
deviceName |
The name of the device. |
loop |
Indicates whether the recording should continue recording if lengthSec is reached, and wrap around and record from the beginning of the AudioClip. |
lengthSec |
Is the length of the AudioClip produced by the recording. |
frequency |
The sample rate of the AudioClip produced by the recording. |
Returns:
AudioClip The function returns null if the recording fails to start.