Click or drag to resize
WaveInput Class
Represents a wave input device.
Inheritance Hierarchy
SystemObject
  StreamCoders.WaveWaveInput

Namespace: StreamCoders.Wave
Assembly: MediaSuite (in MediaSuite.dll) Version: 2.0.5.0 (2.0.5.0)
Syntax
public class WaveInput : IDisposable

The WaveInput type exposes the following members.

Constructors
  NameDescription
Public methodWaveInput
Default constructor.
Top
Properties
  NameDescription
Public propertyBitsPerSample
Get/Set the Bits per sample.
Public propertyBytesAvailable
Gets the BytesAvailable property.
Public propertyChannelMask
Gets or sets the channel mask present in the multichannel stream. Audio interleave channel numbers start from lowest to highest value in channel mask bit-flags. (Stereo: Interleave 0 -> Left (0x1), Interleave 1 -> Right (0x2))
Public propertyChannels
Get/Set the number of channels.
Public propertyDevices
Gets all available audio input devices. This includes the default device mapper in position zero.
Public propertySampleRate
Get/Set the Sample rate.
Public propertySamplesAvailable
Indicates whether audio samples are enqueued and ready to be read.
Public propertyTransferBufferCount
Gets or sets the number of Transfer buffers.
Public propertyTransferBufferSize
Gets or sets the size of each of the buffers used to transfer data from the sound device to the application.
Top
Methods
  NameDescription
Public methodClearBuffers
Removes all pending buffers from the audio device.
This call is functionally equivalent to calling SamplesAvailable and GetAllData, but is more efficient.
Public methodCloseDevice
Close previously opened device
Should be called after calling Stop()
Public methodDispose
Destructor.
Public methodFindDeviceByIndex
Public methodFindDeviceByName
Find audio Device provided its name.
Public methodGetNextSamples
Gets the next samples in the wave input devices queue. Calling this method and events cannot be mixed.
Public methodInit
Initializes WaveInput object.
Public methodOpenDevice
Open default audio input device.
Public methodOpenDevice(String)
Opens an audio input device.
Public methodOpenDevice(AudioDeviceInfo)
Opens an audio input device.
Public methodSetTransferBufferSizeMilliseconds
Sets transfer buffer size given milliseconds using Formula: SR * CH * BPS * milliseconds / 1000.
This function must be called after setting SampleRate, Channels and BitsPerSample, but before Init().
Public methodStart
Start recording and queueing data.
Public methodStop
Stop recording and queueing data.
Public methodCode exampleWaitSamplesAvailable
Uses internal semaphore to wait for samples to become available.
Top
Events
  NameDescription
Public eventOnSamplesAvailable
Event that is raised whenever a sample is available. Events and polling (GetNextSamples) cannot be mixed.
Top
Extension Methods
  NameDescription
Public Extension MethodCopyOverloaded.
Creates a copy of the object.
(Defined by ObjectExtensions.)
Public Extension MethodCopy(Object)Overloaded.
Creates a deep copy of the object using the supplied object as a target for the copy operation.
(Defined by ObjectExtensions.)
Top
Examples
WaveOutput wout = new WaveOutput();
wout.BitsPerSample = audioBitsPerSample;
wout.Channels = audioChannels;
wout.SampleRate = audioSampleFreq;
wout.Init();
wout.OpenDevice();

WaveInput win = new WaveInput();
win.BitsPerSample = audioBitsPerSample;
win.Channels = audioChannels;
win.SampleRate = audioSampleFreq;
win.Init();
win.OpenDevice();
win.Start();

while(true)
{
    if (win.SamplesAvailable)
    {
        byte[] samples = win.GetAllData();
        wout.Enqueue(samples);
    }
}
See Also