JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::AudioIODevice Class Referenceabstract

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

#include <juce_AudioIODevice.h>

Inheritance diagram for juce::AudioIODevice:
Collaboration diagram for juce::AudioIODevice:

Public Member Functions

virtual ~AudioIODevice ()
 Destructor. More...
 
virtual void close ()=0
 Closes and releases the device if it's open. More...
 
virtual BigInteger getActiveInputChannels () const =0
 Returns a mask showing which of the available input channels are currently enabled. More...
 
virtual BigInteger getActiveOutputChannels () const =0
 Returns a mask showing which of the available output channels are currently enabled. More...
 
virtual Array< intgetAvailableBufferSizes ()=0
 Returns the set of buffer sizes that are available. More...
 
virtual Array< double > getAvailableSampleRates ()=0
 Returns the set of sample-rates this device supports. More...
 
virtual int getCurrentBitDepth ()=0
 Returns the device's current physical bit-depth. More...
 
virtual int getCurrentBufferSizeSamples ()=0
 Returns the buffer size that the device is currently using. More...
 
virtual double getCurrentSampleRate ()=0
 Returns the sample rate that the device is currently using. More...
 
virtual int getDefaultBufferSize ()=0
 Returns the default buffer-size to use. More...
 
virtual StringArray getInputChannelNames ()=0
 Returns the names of all the available input channels on this device. More...
 
virtual int getInputLatencyInSamples ()=0
 Returns the device's input latency. More...
 
virtual String getLastError ()=0
 Returns the last error that happened if anything went wrong. More...
 
const StringgetName () const noexcept
 Returns the device's name, (as set in the constructor). More...
 
virtual StringArray getOutputChannelNames ()=0
 Returns the names of all the available output channels on this device. More...
 
virtual int getOutputLatencyInSamples ()=0
 Returns the device's output latency. More...
 
const StringgetTypeName () const noexcept
 Returns the type of the device. More...
 
virtual int getXRunCount () const noexcept
 Returns the number of under- or over runs reported by the OS since playback/recording has started. More...
 
virtual bool hasControlPanel () const
 True if this device can show a pop-up control panel for editing its settings. More...
 
virtual bool isOpen ()=0
 Returns true if the device is still open. More...
 
virtual bool isPlaying ()=0
 Returns true if the device is still calling back. More...
 
virtual String open (const BigInteger &inputChannels, const BigInteger &outputChannels, double sampleRate, int bufferSizeSamples)=0
 Tries to open the device ready to play. More...
 
virtual bool setAudioPreprocessingEnabled (bool shouldBeEnabled)
 On devices which support it, this allows automatic gain control or other mic processing to be disabled. More...
 
virtual bool showControlPanel ()
 Shows a device-specific control panel if there is one. More...
 
virtual void start (AudioIODeviceCallback *callback)=0
 Starts the device actually playing. More...
 
virtual void stop ()=0
 Stops the device playing. More...
 

Protected Member Functions

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

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

@tags{Audio}

Constructor & Destructor Documentation

◆ ~AudioIODevice()

virtual juce::AudioIODevice::~AudioIODevice ( )
virtual

Destructor.

◆ AudioIODevice()

juce::AudioIODevice::AudioIODevice ( const String deviceName,
const String typeName 
)
protected

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

Member Function Documentation

◆ close()

virtual void juce::AudioIODevice::close ( )
pure virtual

Closes and releases the device if it's open.

Implemented in juce::iOSAudioIODevice.

◆ getActiveInputChannels()

virtual BigInteger juce::AudioIODevice::getActiveInputChannels ( ) const
pure virtual

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

See also
getInputChannelNames

Implemented in juce::iOSAudioIODevice.

Referenced by juce::StandalonePluginHolder::CallbackMaxSizeEnforcer::audioDeviceAboutToStart(), and juce::StandalonePluginHolder::audioDeviceAboutToStart().

◆ getActiveOutputChannels()

virtual BigInteger juce::AudioIODevice::getActiveOutputChannels ( ) const
pure virtual

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

See also
getOutputChannelNames

Implemented in juce::iOSAudioIODevice.

Referenced by juce::StandalonePluginHolder::CallbackMaxSizeEnforcer::audioDeviceAboutToStart().

◆ getAvailableBufferSizes()

virtual Array<int> juce::AudioIODevice::getAvailableBufferSizes ( )
pure virtual

Returns the set of buffer sizes that are available.

See also
getCurrentBufferSizeSamples, getDefaultBufferSize

Implemented in juce::iOSAudioIODevice.

◆ getAvailableSampleRates()

virtual Array<double> juce::AudioIODevice::getAvailableSampleRates ( )
pure virtual

Returns the set of sample-rates this device supports.

See also
getCurrentSampleRate

Implemented in juce::iOSAudioIODevice.

◆ getCurrentBitDepth()

virtual int juce::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.

Implemented in juce::iOSAudioIODevice.

◆ getCurrentBufferSizeSamples()

virtual int juce::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.

Implemented in juce::iOSAudioIODevice.

Referenced by juce::StandalonePluginHolder::CallbackMaxSizeEnforcer::audioDeviceAboutToStart(), and juce::StandalonePluginHolder::audioDeviceAboutToStart().

◆ getCurrentSampleRate()

virtual double juce::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.

Implemented in juce::iOSAudioIODevice.

◆ getDefaultBufferSize()

virtual int juce::AudioIODevice::getDefaultBufferSize ( )
pure virtual

Returns the default buffer-size to use.

Returns
a number of samples
See also
getAvailableBufferSizes

Implemented in juce::iOSAudioIODevice.

◆ getInputChannelNames()

virtual StringArray juce::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().

Implemented in juce::iOSAudioIODevice.

◆ getInputLatencyInSamples()

virtual int juce::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.

Implemented in juce::iOSAudioIODevice.

◆ getLastError()

virtual String juce::AudioIODevice::getLastError ( )
pure virtual

Returns the last error that happened if anything went wrong.

Implemented in juce::iOSAudioIODevice.

◆ getName()

const String& juce::AudioIODevice::getName ( ) const
inlinenoexcept

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

References juce::gl::name.

◆ getOutputChannelNames()

virtual StringArray juce::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().

Implemented in juce::iOSAudioIODevice.

◆ getOutputLatencyInSamples()

virtual int juce::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.

Implemented in juce::iOSAudioIODevice.

◆ getTypeName()

const String& juce::AudioIODevice::getTypeName ( ) const
inlinenoexcept

Returns the type of the device.

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

◆ getXRunCount()

virtual int juce::AudioIODevice::getXRunCount ( ) const
virtualnoexcept

Returns the number of under- or over runs reported by the OS since playback/recording has started.

This number may be different than determining the Xrun count manually (by measuring the time spent in the audio callback) as the OS may be doing some buffering internally - especially on mobile devices.

Returns -1 if playback/recording has not started yet or if getting the underrun count is not supported for this device (Android SDK 23 and lower).

Reimplemented in juce::iOSAudioIODevice.

◆ hasControlPanel()

virtual bool juce::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.

◆ isOpen()

virtual bool juce::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.

Implemented in juce::iOSAudioIODevice.

◆ isPlaying()

virtual bool juce::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.

Implemented in juce::iOSAudioIODevice.

◆ open()

virtual String juce::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 getAvailableSampleRates()
bufferSizeSamplesthe size of i/o buffer to use - to find out the available buffer sizes, see getAvailableBufferSizes()
Returns
an error description if there's a problem, or an empty string if it succeeds in opening the device
See also
close

Implemented in juce::iOSAudioIODevice.

◆ setAudioPreprocessingEnabled()

virtual bool juce::AudioIODevice::setAudioPreprocessingEnabled ( bool  shouldBeEnabled)
virtual

On devices which support it, this allows automatic gain control or other mic processing to be disabled.

If the device doesn't support this operation, it'll return false.

Reimplemented in juce::iOSAudioIODevice.

◆ showControlPanel()

virtual bool juce::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().

◆ start()

virtual void juce::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

Implemented in juce::iOSAudioIODevice.

◆ stop()

virtual void juce::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.

Implemented in juce::iOSAudioIODevice.

Member Data Documentation

◆ name

String juce::AudioIODevice::name
protected

◆ typeName

String juce::AudioIODevice::typeName
protected

The documentation for this class was generated from the following file: