Loading...
Searching...
No Matches
juce::AudioIODevice Class Referenceabstract

`#include <juce_AudioIODevice.h>`

## Public Member Functions

virtual | ~AudioIODevice ()
const String & | getName () const noexcept
const String & | getTypeName () const noexcept
virtual StringArray | getOutputChannelNames ()=0
virtual StringArray | getInputChannelNames ()=0
virtual std::optional< BigInteger > | getDefaultOutputChannels () const
virtual std::optional< BigInteger > | getDefaultInputChannels () const
virtual Array< double > | getAvailableSampleRates ()=0
virtual Array< int > | getAvailableBufferSizes ()=0
virtual int | getDefaultBufferSize ()=0
virtual String | open (const BigInteger &inputChannels, const BigInteger &outputChannels, double sampleRate, int bufferSizeSamples)=0
virtual void | close ()=0
virtual bool | isOpen ()=0
virtual void | start (AudioIODeviceCallback *callback)=0
virtual void | stop ()=0
virtual bool | isPlaying ()=0
virtual String | getLastError ()=0
virtual int | getCurrentBufferSizeSamples ()=0
virtual double | getCurrentSampleRate ()=0
virtual int | getCurrentBitDepth ()=0
virtual BigInteger | getActiveOutputChannels () const =0
virtual BigInteger | getActiveInputChannels () const =0
virtual int | getOutputLatencyInSamples ()=0
virtual int | getInputLatencyInSamples ()=0
virtual AudioWorkgroup | getWorkgroup () const
virtual bool | hasControlPanel () const
virtual bool | showControlPanel ()
virtual bool | setAudioPreprocessingEnabled (bool shouldBeEnabled)
virtual int | getXRunCount () const noexcept

## Protected Member Functions

| AudioIODevice (const String &deviceName, const String &typeName)

## 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

Definition at line 150 of file juce_AudioIODevice.h.

## Constructor & Destructor Documentation

## ~AudioIODevice()

juce::AudioIODevice::~AudioIODevice | ( |  | ) |

virtual

Destructor.

Definition at line 39 of file juce_AudioIODevice.cpp.

## AudioIODevice()

juce::AudioIODevice::AudioIODevice | ( | const String & | deviceName,
|  | const String & | typeName )

protected

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

Definition at line 34 of file juce_AudioIODevice.cpp.

## Member Function Documentation

## close()

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

pure virtual

Closes and releases the device if it's open.

## 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

## 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

## getAvailableBufferSizes()

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

pure virtual

Returns the set of buffer sizes that are available.

See also
  getCurrentBufferSizeSamples, getDefaultBufferSize

## getAvailableSampleRates()

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

pure virtual

Returns the set of sample-rates this device supports.

See also
  getCurrentSampleRate

## 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.

## 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.

Referenced by juce::AudioSourcePlayer::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.

Referenced by juce::AudioSourcePlayer::audioDeviceAboutToStart().

## getDefaultBufferSize()

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

pure virtual

Returns the default buffer-size to use.

Returns
  a number of samples

See also
  getAvailableBufferSizes

## getDefaultInputChannels()

virtual std::optional< BigInteger > juce::AudioIODevice::getDefaultInputChannels | ( |  | ) | const

inline virtual

For devices that support a default layout, returns the channels that are enabled in the default layout.

Returns nullopt if the device doesn't supply a default layout.

Definition at line 190 of file juce_AudioIODevice.h.

## getDefaultOutputChannels()

virtual std::optional< BigInteger > juce::AudioIODevice::getDefaultOutputChannels | ( |  | ) | const

inline virtual

For devices that support a default layout, returns the channels that are enabled in the default layout.

Returns nullopt if the device doesn't supply a default layout.

Definition at line 183 of file juce_AudioIODevice.h.

## 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().

## 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.

## getLastError()

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

pure virtual

Returns the last error that happened if anything went wrong.

## getName()

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

inline noexcept

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

Definition at line 158 of file juce_AudioIODevice.h.

## 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().

## 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.

## getTypeName()

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

inline noexcept

Returns the type of the device.

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

Definition at line 164 of file juce_AudioIODevice.h.

## getWorkgroup()

virtual AudioWorkgroup juce::AudioIODevice::getWorkgroup | ( |  | ) | const

inline virtual

Returns the workgroup for this device.

Definition at line 311 of file juce_AudioIODevice.h.

## getXRunCount()

int juce::AudioIODevice::getXRunCount | ( |  | ) | const

virtual noexcept

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).

Definition at line 44 of file juce_AudioIODevice.cpp.

## hasControlPanel()

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.

Definition at line 43 of file juce_AudioIODevice.cpp.

## 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.

## 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.

## 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

  inputChannels | a BigInteger in which a set bit indicates that the corresponding input channel should be enabled
  outputChannels | a BigInteger in which a set bit indicates that the corresponding output channel should be enabled
  sampleRate | the sample rate to try to use - to find out which rates are available, see getAvailableSampleRates()
  bufferSizeSamples | the 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

## setAudioPreprocessingEnabled()

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.

Definition at line 42 of file juce_AudioIODevice.cpp.

## showControlPanel()

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().

Definition at line 46 of file juce_AudioIODevice.cpp.

## 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

  callback | the callback to use for streaming the data.

See also
  AudioIODeviceCallback, open

## 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.

## Member Data Documentation

## name

String juce::AudioIODevice::name

protected

Definition at line 353 of file juce_AudioIODevice.h.

Referenced by AudioIODevice(), and getName().

## typeName

String juce::AudioIODevice::typeName

protected

Definition at line 353 of file juce_AudioIODevice.h.

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

- juce_AudioIODevice.h
- juce_AudioIODevice.cpp