class MAGES::LocalMicrophone¶
Overview¶
LocalMicrophone is a utility class that provides a simple interface to record audio from the microphone. More…
class LocalMicrophone
{
public:
// interfaces
interface IApi;
// classes
class StubMicrophone;
// properties
IEnumerable Devices;
// methods
static AudioClip Start(
string deviceName,
bool loop,
int lengthSec,
int frequency
);
static void End(string deviceName);
static void GetDeviceCaps(string deviceName, out int minFreq, out int maxFreq);
static int GetPosition(string deviceName);
static bool IsRecording(string deviceName = null);
};
Detailed Documentation¶
LocalMicrophone is a utility class that provides a simple interface to record audio from the microphone.
Properties¶
IEnumerableDevices
Gets a list of available microphone devices.
Methods¶
static 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.
static 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. |
static 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. |
static 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.
static 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.