Public Member Functions | Protected Member Functions | Protected Attributes

AudioIODevice Class Reference

Base class for an audio device with synchronised input and output channels. More...

List of all members.

Public Member Functions

virtual ~AudioIODevice ()
 Destructor.
const StringgetName () const noexcept
 Returns the device's name, (as set in the constructor).
const StringgetTypeName () const noexcept
 Returns the type of the device.
virtual StringArray getOutputChannelNames ()=0
 Returns the names of all the available output channels on this device.
virtual StringArray getInputChannelNames ()=0
 Returns the names of all the available input channels on this device.
virtual int getNumSampleRates ()=0
 Returns the number of sample-rates this device supports.
virtual double getSampleRate (int index)=0
 Returns one of the sample-rates this device supports.
virtual int getNumBufferSizesAvailable ()=0
 Returns the number of sizes of buffer that are available.
virtual int getBufferSizeSamples (int index)=0
 Returns one of the possible buffer-sizes.
virtual int getDefaultBufferSize ()=0
 Returns the default buffer-size to use.
virtual const String open (const BigInteger &inputChannels, const BigInteger &outputChannels, double sampleRate, int bufferSizeSamples)=0
 Tries to open the device ready to play.
virtual void close ()=0
 Closes and releases the device if it's open.
virtual bool isOpen ()=0
 Returns true if the device is still open.
virtual void start (AudioIODeviceCallback *callback)=0
 Starts the device actually playing.
virtual void stop ()=0
 Stops the device playing.
virtual bool isPlaying ()=0
 Returns true if the device is still calling back.
virtual const String getLastError ()=0
 Returns the last error that happened if anything went wrong.
virtual int getCurrentBufferSizeSamples ()=0
 Returns the buffer size that the device is currently using.
virtual double getCurrentSampleRate ()=0
 Returns the sample rate that the device is currently using.
virtual int getCurrentBitDepth ()=0
 Returns the device's current physical bit-depth.
virtual const BigInteger getActiveOutputChannels () const =0
 Returns a mask showing which of the available output channels are currently enabled.
virtual const BigInteger getActiveInputChannels () const =0
 Returns a mask showing which of the available input channels are currently enabled.
virtual int getOutputLatencyInSamples ()=0
 Returns the device's output latency.
virtual int getInputLatencyInSamples ()=0
 Returns the device's input latency.
virtual bool hasControlPanel () const
 True if this device can show a pop-up control panel for editing its settings.
virtual bool showControlPanel ()
 Shows a device-specific control panel if there is one.

Protected Member Functions

 AudioIODevice (const String &deviceName, const String &typeName)
 Creates a device, setting its name and type member variables.

Protected Attributes

String name
String typeName

Detailed Description

Base class for an audio device with synchronised input and output channels.

Subclasses of this are used to implement different protocols such as DirectSound, ASIO, CoreAudio, etc.

To create one of these, you'll need to use the AudioIODeviceType class - see the documentation for that class for more info.

For an easier way of managing audio devices and their settings, have a look at the AudioDeviceManager class.

See also:
AudioIODeviceType, AudioDeviceManager

Constructor & Destructor Documentation

virtual AudioIODevice::~AudioIODevice (  ) [virtual]

Destructor.

AudioIODevice::AudioIODevice ( const String deviceName,
const String typeName 
) [protected]

Creates a device, setting its name and type member variables.


Member Function Documentation

const String& AudioIODevice::getName (  ) const

Returns the device's name, (as set in the constructor).

const String& AudioIODevice::getTypeName (  ) const

Returns the type of the device.

E.g. "CoreAudio", "ASIO", etc. - this comes from the AudioIODeviceType that created it.

virtual StringArray AudioIODevice::getOutputChannelNames (  ) [pure virtual]

Returns the names of all the available output channels on this device.

To find out which of these are currently in use, call getActiveOutputChannels().

virtual StringArray AudioIODevice::getInputChannelNames (  ) [pure virtual]

Returns the names of all the available input channels on this device.

To find out which of these are currently in use, call getActiveInputChannels().

virtual int AudioIODevice::getNumSampleRates (  ) [pure virtual]

Returns the number of sample-rates this device supports.

To find out which rates are available on this device, use this method to find out how many there are, and getSampleRate() to get the rates.

See also:
getSampleRate
virtual double AudioIODevice::getSampleRate ( int  index ) [pure virtual]

Returns one of the sample-rates this device supports.

To find out which rates are available on this device, use getNumSampleRates() to find out how many there are, and getSampleRate() to get the individual rates.

The sample rate is set by the open() method.

(Note that for DirectSound some rates might not work, depending on combinations of i/o channels that are being opened).

See also:
getNumSampleRates
virtual int AudioIODevice::getNumBufferSizesAvailable (  ) [pure virtual]

Returns the number of sizes of buffer that are available.

See also:
getBufferSizeSamples, getDefaultBufferSize
virtual int AudioIODevice::getBufferSizeSamples ( int  index ) [pure virtual]

Returns one of the possible buffer-sizes.

Parameters:
indexthe index of the buffer-size to use, from 0 to getNumBufferSizesAvailable() - 1
Returns:
a number of samples
See also:
getNumBufferSizesAvailable, getDefaultBufferSize
virtual int AudioIODevice::getDefaultBufferSize (  ) [pure virtual]

Returns the default buffer-size to use.

Returns:
a number of samples
See also:
getNumBufferSizesAvailable, getBufferSizeSamples
virtual const String AudioIODevice::open ( const BigInteger inputChannels,
const BigInteger outputChannels,
double  sampleRate,
int  bufferSizeSamples 
) [pure virtual]

Tries to open the device ready to play.

Parameters:
inputChannelsa BigInteger in which a set bit indicates that the corresponding input channel should be enabled
outputChannelsa BigInteger in which a set bit indicates that the corresponding output channel should be enabled
sampleRatethe sample rate to try to use - to find out which rates are available, see getNumSampleRates() and getSampleRate()
bufferSizeSamplesthe size of i/o buffer to use - to find out the available buffer sizes, see getNumBufferSizesAvailable() and getBufferSizeSamples()
Returns:
an error description if there's a problem, or an empty string if it succeeds in opening the device
See also:
close
virtual void AudioIODevice::close (  ) [pure virtual]

Closes and releases the device if it's open.

virtual bool AudioIODevice::isOpen (  ) [pure virtual]

Returns true if the device is still open.

A device might spontaneously close itself if something goes wrong, so this checks if it's still open.

virtual void AudioIODevice::start ( AudioIODeviceCallback callback ) [pure virtual]

Starts the device actually playing.

This must be called after the device has been opened.

Parameters:
callbackthe callback to use for streaming the data.
See also:
AudioIODeviceCallback, open
virtual void AudioIODevice::stop (  ) [pure virtual]

Stops the device playing.

Once a device has been started, this will stop it. Any pending calls to the callback class will be flushed before this method returns.

virtual bool AudioIODevice::isPlaying (  ) [pure virtual]

Returns true if the device is still calling back.

The device might mysteriously stop, so this checks whether it's still playing.

virtual const String AudioIODevice::getLastError (  ) [pure virtual]

Returns the last error that happened if anything went wrong.

virtual int AudioIODevice::getCurrentBufferSizeSamples (  ) [pure virtual]

Returns the buffer size that the device is currently using.

If the device isn't actually open, this value doesn't really mean much.

virtual double AudioIODevice::getCurrentSampleRate (  ) [pure virtual]

Returns the sample rate that the device is currently using.

If the device isn't actually open, this value doesn't really mean much.

virtual int AudioIODevice::getCurrentBitDepth (  ) [pure virtual]

Returns the device's current physical bit-depth.

If the device isn't actually open, this value doesn't really mean much.

virtual const BigInteger AudioIODevice::getActiveOutputChannels (  ) const [pure virtual]

Returns a mask showing which of the available output channels are currently enabled.

See also:
getOutputChannelNames
virtual const BigInteger AudioIODevice::getActiveInputChannels (  ) const [pure virtual]

Returns a mask showing which of the available input channels are currently enabled.

See also:
getInputChannelNames
virtual int AudioIODevice::getOutputLatencyInSamples (  ) [pure virtual]

Returns the device's output latency.

This is the delay in samples between a callback getting a block of data, and that data actually getting played.

virtual int AudioIODevice::getInputLatencyInSamples (  ) [pure virtual]

Returns the device's input latency.

This is the delay in samples between some audio actually arriving at the soundcard, and the callback getting passed this block of data.

virtual bool AudioIODevice::hasControlPanel (  ) const [virtual]

True if this device can show a pop-up control panel for editing its settings.

This is generally just true of ASIO devices. If true, you can call showControlPanel() to display it.

virtual bool AudioIODevice::showControlPanel (  ) [virtual]

Shows a device-specific control panel if there is one.

This should only be called for devices which return true from hasControlPanel().


Member Data Documentation


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines