|
arduino-audio-tools
|
USB Audio host for the Adafruit TinyUSB host stack: reads audio from an attached USB microphone and/or writes audio to an attached USB speaker. More...
#include <USBAudioHostTinyUSB.h>
Public Member Functions | |
| USBAudioHostTinyUSB ()=default | |
| USBAudioHostTinyUSB (Adafruit_USBH_Host &host) | |
| Use the Adafruit_USBH_Host which was set up by the sketch. | |
| USBAudioHostTinyUSB (USBAudioConfig cfg) | |
| virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
| Adds target to be notified about audio changes. | |
| virtual AudioInfo | audioInfo () override |
| provides the actual input AudioInfo | |
| virtual AudioInfo | audioInfoOut () |
| AudioInfo | audioInfoRx () const |
| Negotiated format of the microphone stream (readBytes()) | |
| AudioInfo | audioInfoTx () const |
| Negotiated format of the speaker stream (write()) | |
| uint16_t | audioPacketSize () const |
| int | available () override |
| Bytes of received audio waiting in the RX buffer. | |
| int | availableForWrite () override |
| Bytes of free space in the TX buffer. | |
| bool | begin () |
| Start the USB host stack with the current config. The attached device is opened as soon as it has been enumerated. | |
| bool | begin (const USBAudioConfig &cfg) |
| Apply a config and start the USB audio host. | |
| BaseBuffer< uint8_t > & | bufferRx () override |
| Returns the RX audio buffer. Must be overridden by subclasses. | |
| BaseBuffer< uint8_t > & | bufferTx () override |
| Returns the TX audio buffer. Must be overridden by subclasses. | |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| const USBAudioConfig & | config () const |
| Provides the active configuration. | |
| USBAudioConfig | defaultConfig (RxTxMode mode=RXTX_MODE) |
| Returns a default configuration for the requested direction. RX_MODE reads from a USB microphone, TX_MODE writes to a USB speaker, RXTX_MODE does both (headset). | |
| void | end () |
| Stop the streams and clear the buffers. The host stack keeps running, so the device is opened again with the next begin(). | |
| virtual void | flush () override |
| virtual int | getActualCore () const |
| Returns the actual core on which the call is running (for RP2040) | |
| uint32_t | getRxDroppedBytes () const |
| Bytes discarded because bufferRx() was full. | |
| uint32_t | getRxTotalBytes () const |
| Total bytes received from the microphone. | |
| uint32_t | getRxXferCount () const |
| uint32_t | getTxUnderflowBytes () const |
| Bytes of silence which were sent because bufferTx() was empty. | |
| uint32_t | getTxXferCount () const |
| Number of isochronous OUT packets which were provided to the speaker. | |
| bool | hasMicrophone () const |
| True if the attached device provides a microphone (RX) | |
| bool | hasSpeaker () const |
| True if the attached device provides a speaker (TX) | |
| bool | isEpInEnabled () const |
| Returns true if the IN endpoint is enabled. | |
| bool | isEpOutEnabled () const |
| Returns true if the OUT endpoint is enabled. | |
| bool | isMute (uint8_t channel=0) const |
| Returns the current mute state for the given channel. | |
| bool | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| bool | isStreamingActive () const |
| Returns true if either the TX or RX stream is open. | |
| bool | isStreamingActiveRx () const override |
| Returns true if the microphone stream (used by readBytes()) is open. | |
| bool | isStreamingActiveTx () const override |
| Returns true if the speaker stream (used by write()) is open. | |
| bool | mounted () override |
| Returns true if an audio device is attached and configured. | |
| operator bool () override | |
| uint16_t | pid () const |
| Product id of the attached device (0 if none) | |
| size_t | readBytes (uint8_t *buffer, size_t bufsize) |
| Receive audio data from the USB peer. Until bufferRx() has filled past config.rx_start_fill_percent at least once after begin(), no data is returned. This is a one-shot startup prime only – once reached, readBytes() keeps draining normally for the rest of the session and is not gated again by later underruns. | |
| virtual size_t | readSilence (uint8_t *buffer, size_t length) |
| Source to generate silence: just sets the buffer to 0. | |
| virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
| Removes a target in order not to be notified about audio changes. | |
| void | serviceUSB () override |
| Process pending USB events. Skipped when a dedicated FreeRTOS task already runs the USB stack (tuh_task() is not re-entrant). | |
| void | setAudioInfo (AudioInfo info) override |
| Defines the audio format. Before begin() all fields can be changed; once started, a new sample rate is re-negotiated with the attached device. | |
| void | setHost (Adafruit_USBH_Host &host) |
| bool | setMute (bool m, uint8_t channel=0) |
| Set the mute state for a channel and notify the USB peer. | |
| void | setMuteCallback (std::function< void(bool, uint8_t)> cb) |
| Register a callback invoked when the mute state changes. | |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
| void | setSampleRateCallback (std::function< void(uint32_t)> cb) |
| Register a callback invoked when the sample rate changes. | |
| void | setStreamingStateCallback (std::function< void(bool, bool)> cb) |
| Register a callback invoked when the streaming state changes (a streaming interface was opened or closed). | |
| bool | setVolume (float vol, uint8_t channel) |
| Set the volume for a channel and notify the USB peer. | |
| bool | setVolume (float volume) override |
| sets the volume for the master channel (channel 0) | |
| void | setVolumeCallback (std::function< void(float, uint8_t)> cb) |
| Register a callback invoked when the volume changes. | |
| void | setWriteBufferSize (int size) |
| uint8_t | uacVersion () const |
| USB Audio Class version of the attached device: 1 or 2 (0 if none) | |
| uint16_t | vid () const |
| Vendor id of the attached device (0 if none) | |
| float | volume () override |
| gets the volume for the master channel (channel 0) | |
| float | volume (uint8_t channel) |
| Returns the current volume for the given channel. | |
| size_t | write (const uint8_t *data, size_t len) |
| Send audio data to the USB peer. Silently discards data while the TX stream is not open so StreamCopy doesn't report write errors before streaming starts. | |
| virtual size_t | write (uint8_t ch) override |
| virtual void | writeSilence (size_t len) |
| Writes len bytes of silence (=0). | |
Protected Types | |
| enum class | Step : uint8_t { Idle , StopRx , StopTx , ClockRangeHeaderRx , ClockRangeRx , ClockRangeHeaderTx , ClockRangeTx , Select , SetClockRx , SetInterfaceRx , OpenRx , SetEpRateRx , VolumeRangeRx , VolumeMaxRx , SetClockTx , SetInterfaceTx , OpenTx , SetEpRateTx , VolumeRangeTx , VolumeMaxTx , Done } |
| Steps of the (re)configuration state machine. More... | |
Protected Member Functions | |
| USBAudioHostBackend & | backend () override |
| Returns the backend used for all USB host stack calls. | |
| bool | beginUSB () override |
| Override in platform subclasses to start the USB stack. | |
| bool | clockRange (Stream &s, std::vector< RateRange > &ranges, Step following) |
| bool | clockRangeHeader (Stream &s, std::vector< RateRange > &ranges, Step on_success, Step skip) |
| uint32_t | closestRate (const AltSetting &a, const std::vector< RateRange > &clock, uint32_t wanted) |
| Supported sample rate which is closest to the wanted rate (0 if none) | |
| bool | configChanged (const USBAudioConfig &n) |
| bool | executeStep () |
| Entity * | findEntity (uint8_t id) |
| void | finishMount () |
| void | finishRuntimeRequest () |
| bool | fitsBandwidth (const AltSetting &a, uint32_t rate) |
| float | getVolumeExt (uint8_t channel) const |
| Returns the effective volume for a per-channel index (1-based). Combines master volume (index 0) with per-channel volume and mute. | |
| bool | issueControl (uint8_t request_type, uint8_t request, uint16_t value, uint16_t index, uint16_t length) |
| bool | issueSetInterface (uint8_t itf, uint8_t alt) |
| void | next (Step s) |
| Advance to the next step. | |
| virtual int | not_supported (int out, const char *msg="") |
| void | notifyAudioChange (AudioInfo info) |
| void | notifyStreamingState () |
| uint16_t | onAttach (uint8_t daddr, uint16_t vid, uint16_t pid, const uint8_t *desc, uint16_t len) override |
| void | onConfigured (uint8_t daddr) override |
| void | onControlComplete (bool ok, uint16_t len) override |
| void | onDetach (uint8_t daddr) override |
| The device was removed. | |
| void | onFeedback (const uint8_t *data, uint16_t len) |
| Explicit feedback from the speaker: samples per packet. | |
| void | onIsoIn (UsbHostStreamRole role, const uint8_t *data, uint16_t len) override |
| One isochronous IN packet was received (RxData or Feedback). | |
| uint16_t | onIsoOut (uint8_t *data, uint16_t max) override |
| void | onMuteChanged (uint8_t channel) override |
| void | onVolumeChanged (uint8_t channel) override |
| void | openStream (Stream &s, bool is_rx) |
| uint16_t | packetsPerSecond (const AltSetting &a) |
| void | parseAcDescriptor (const uint8_t *p) |
| Audio Control interface: header, terminals, units and clocks. | |
| void | parseAsDescriptor (AltSetting &a, const uint8_t *p) |
| Audio Streaming interface: AS_GENERAL and FORMAT_TYPE descriptors. | |
| void | parseClockRange (std::vector< RateRange > &ranges) |
| Parses a UAC2 GET_RANGE (layout 3: 32 bit) response for the clock. | |
| uint16_t | parseConfiguration (const uint8_t *desc, uint16_t len) |
| void | parseFeatureUnitControls (Entity &e, const uint8_t *p, bool v2) |
| Determines which channels provide a host programmable mute / volume. | |
| void | poll () |
| Called regularly from the USB stack context. | |
| void | processUSB () |
| template<typename T > | |
| void | processVolume (T *data, size_t sample_count) |
| void | processVolume (uint8_t *data, size_t len) |
| Process audio data for volume control. | |
| void | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read() | |
| bool | requestClockRange (Stream &s, uint16_t len) |
| bool | requestFeature (Stream &s, uint8_t selector, uint8_t ch, int16_t value) |
| bool | requestSetClock (Stream &s) |
| bool | requestSetEpRate (Stream &s) |
| bool | requestVolumeRange (Stream &s, bool max) |
| void | resetDevice () |
| void | resizeBuffers () override |
| Resize the platform audio buffers. | |
| uint8_t | resolveClock (uint8_t id) |
| Follow clock selectors and multipliers to the clock source. | |
| void | resolveTopology (Stream &s, bool is_rx) |
| void | run () |
| Runs the state machine until a control request is in flight. | |
| bool | selectAlt (Stream &s, const std::vector< RateRange > &clock, AudioInfo &negotiated) |
| Selects the alternate setting which matches the requested format best. | |
| bool | sendFeature (bool is_volume, uint8_t ch) |
| bool | sendFeatureFor (Stream &s) |
| bool | sendFeatureNextStream () |
| bool | setClock (Stream &s, Step following) |
| void | setConfig (const USBAudioConfig &cfg) |
| Set the USB audio configuration (use begin(cfg) instead). | |
| bool | setEpRate (Stream &s, Step following) |
| bool | setInterface (Stream &s, Step on_success, Step skip) |
| void | setupVolumeState () |
| (Re)sizes the volume and mute state: master (index 0) + one per channel | |
| void | startRuntimeRequest () |
| Sends the next queued volume or mute change. | |
| bool | stopStream (Stream &s, Step following) |
| Stop streaming before a reconfiguration: select alt 0. | |
| bool | supportsRate (const AltSetting &a, const std::vector< RateRange > &clock, uint32_t rate) |
| True if the alternate setting supports the sample rate. | |
| void | updateBufferSize () |
| bool | volumeRange (Stream &s, bool max, Step on_success, Step skip) |
Static Protected Member Functions | |
| static uint32_t | descU24 (const uint8_t *p) |
| static int16_t | floatToUac2 (float vol) |
| Convert linear volume (0.0–1.0) to UAC2 int16 (1/256 dB). Linear mapping: 0.0 → -100 dB (min), 1.0 → 0 dB (max). | |
| static bool | isValidBitsPerSample (uint8_t bps) |
| static uint16_t | packetSizeFor (const AudioInfo &info) |
| Bytes of one 1 ms packet for the indicated format (+1 sample margin) | |
| static int16_t | toDeviceVolume (const Stream &s, float vol) |
| Linear mapping of 0.0..1.0 to the volume range of the device. | |
| static float | uac2ToFloat (int16_t v) |
| Convert UAC2 int16 (1/256 dB) to linear volume (0.0–1.0). Linear mapping within the -100..0 dB range reported by GET_RANGE. | |
| static uint8_t | volumeRangeChannel (const Stream &s) |
| Channel used to determine the volume range. | |
Protected Attributes | |
| int | _timeout = 10 |
| volatile bool | attached_ = false |
| USBAudioHostBackendTinyUSB | backend_impl_ |
| uint16_t | buffer_bytes_ = 0 |
| RingBufferSPSC< uint8_t > | buffer_rx_ |
| RingBufferSPSC< uint8_t > | buffer_tx_ |
| std::vector< RateRange > | clock_ranges_rx_ |
| std::vector< RateRange > | clock_ranges_tx_ |
| USBAudioConfig | config_ |
| volatile bool | configured_ = false |
| int | core = -1 |
| uint8_t | ctrl_buf_ [kCtrlBufSize] = {} |
| bool | ctrl_busy_ = false |
| uint16_t | ctrl_len_ = 0 |
| bool | ctrl_ok_ = false |
| uint32_t | ctrl_start_ms_ = 0 |
| uint8_t | daddr_ = 0 |
| std::vector< Entity > | entities_ |
| bool | in_run_ = false |
| AudioInfo | info |
| bool | is_active_ = false |
| bool | is_notify_active = true |
| bool | is_started_ = false |
| uint8_t | itf_num_ac_ = 0 |
| volatile bool | mounted_ = false |
| std::vector< bool > | mute_ |
| std::function< void(bool, uint8_t)> | mute_cb_ |
| std::vector< uint8_t > | mute_pending_ |
| Vector< AudioInfoSupport * > | notify_vector |
| uint8_t | pending_channel_ = 0 |
| bool | pending_is_volume_ = false |
| Stream * | pending_stream_ = nullptr |
| uint16_t | pid_ = 0 |
| volatile bool | reconfigure_pending_ = false |
| bool | reconfiguring_ = false |
| bool | restart_pending_ = false |
| bool | run_again_ = false |
| Stream | rx_ |
| AudioInfo | rx_info_ |
| bool | rx_primed_ = false |
| std::function< void(uint32_t)> | sample_rate_cb_ |
| UsbSetupPacket | setup_ |
| Step | step_ = Step::Idle |
| bool | step_done_ = false |
| std::function< void(bool, bool)> | streaming_state_cb_ |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| Stream | tx_ |
| AudioInfo | tx_info_ |
| uint8_t | uac_version_ = 0 |
| bool | usb_task_active_ = false |
| uint16_t | vid_ = 0 |
| std::vector< float > | volume_ |
| std::function< void(float, uint8_t)> | volume_cb_ |
| std::vector< uint8_t > | volume_pending_ |
| float | volume_value = 1.0f |
| int | write_buffer_size = MAX_SINGLE_CHARS |
Static Protected Attributes | |
| static constexpr uint16_t | kCtrlBufSize = 2 + 12 * 24 |
| static constexpr uint8_t | kMaxChannels = 8 |
| static constexpr uint8_t | kMaxRates = 16 |
| static constexpr uint8_t | kReqInItf = 0xA1 |
| static constexpr uint8_t | kReqOutEp = 0x22 |
| static constexpr uint8_t | kReqOutItf = 0x21 |
| static constexpr int16_t | kVolumeMinDb256 = -25600 |
| Convert AudioTools volume (0.0–1.0) to UAC2 int16 (1/256 dB). 0.0 maps to 0x8000 (silence), 1.0 maps to 0 (0 dB). | |
USB Audio host for the Adafruit TinyUSB host stack: reads audio from an attached USB microphone and/or writes audio to an attached USB speaker.
The USB stack is driven by the application: readBytes() and write() call serviceUSB(), which runs tuh_task(). Call serviceUSB() regularly (e.g. in loop()) if you neither read nor write.
|
strongprotectedinherited |
|
default |
|
inline |
|
inline |
Use the Adafruit_USBH_Host which was set up by the sketch.
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, CodecChain, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, RTSPClient< TcpClient, UdpSocket >, Pipeline, and Pipeline::ModifyingStreamAdapter.
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in JupyterAudioT< T >, MozziStream, TimerCallbackAudioStream, EncodedAudioStream, PureDataStream, AdapterAudioOutputToAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and InputMerge< T >.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in MP3EncoderShine, PureDataStream, PWMAudioOutput< PWMDriverT >, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, ResampleStreamT< TInterpolator >, and SupportedRatesStream.
|
inlineinherited |
Negotiated format of the microphone stream (readBytes())
|
inlineinherited |
One isochronous packet (1 ms at full speed) of the largest stream in bytes
|
inlineoverridevirtualinherited |
Bytes of received audio waiting in the RX buffer.
Reimplemented from BaseStream.
|
inlineoverridevirtualinherited |
Bytes of free space in the TX buffer.
Reimplemented from BaseStream.
|
inlineoverrideprotectedvirtual |
Returns the backend used for all USB host stack calls.
Implements USBAudioHostBase.
|
inlinevirtualinherited |
Start the USB host stack with the current config. The attached device is opened as soon as it has been enumerated.
Reimplemented from BaseStream.
|
inlineinherited |
Apply a config and start the USB audio host.
|
inlineoverrideprotectedvirtualinherited |
Override in platform subclasses to start the USB stack.
Implements USBAudioStreamBase.
Reimplemented in USBAudioHostESP32, and USBAudioHostTinyUSBFreeRTOS.
|
inlineoverridevirtual |
Returns the RX audio buffer. Must be overridden by subclasses.
Implements USBAudioStreamBase.
Reimplemented in USBAudioHostTinyUSBFreeRTOS.
|
inlineoverridevirtual |
Returns the TX audio buffer. Must be overridden by subclasses.
Implements USBAudioStreamBase.
Reimplemented in USBAudioHostTinyUSBFreeRTOS.
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
Supported sample rate which is closest to the wanted rate (0 if none)
|
inlineinherited |
Provides the active configuration.
|
inlineprotectedinherited |
|
inlineinherited |
Returns a default configuration for the requested direction. RX_MODE reads from a USB microphone, TX_MODE writes to a USB speaker, RXTX_MODE does both (headset).
|
inlinestaticprotectedinherited |
|
inlinevirtualinherited |
Stop the streams and clear the buffers. The host stack keeps running, so the device is opened again with the next begin().
Reimplemented from BaseStream.
|
inlineprotectedinherited |
Executes the current step. Returns false if the step could not be started and needs to be retried later.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlinestaticprotectedinherited |
Convert linear volume (0.0–1.0) to UAC2 int16 (1/256 dB). Linear mapping: 0.0 → -100 dB (min), 1.0 → 0 dB (max).
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in PureDataStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, ReformatBaseStream, AudioStreamWrapper, ResampleStream, EncodedAudioStream, URLStream, BufferedTaskStream, AutomaticGainControlStream, MeasuringStream, QualityAnalysisStream, VolumeStream, AudioEffectStreamT< T >, AudioEffectStream, Equalizer3BandsT< T >, Equalizer3BandsPerChannelT< T >, I2SStream, TimedStream, MemoryStream, RingBufferStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, BufferedStream, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, QueueStream< T >, QueueStream< uint8_t >, FadeStream, Pipeline::ModifyingStreamAdapter, SupportedRatesStream, and EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >.
|
inlinevirtualinherited |
Returns the actual core on which the call is running (for RP2040)
Reimplemented in USBAudioDeviceBase, USBAudioDeviceESP32, USBAudioDeviceTinyUSB, and USBAudioHostESP32.
|
inlineinherited |
Bytes discarded because bufferRx() was full.
|
inlineinherited |
Total bytes received from the microphone.
|
inlineinherited |
Number of isochronous IN packets which were received from the microphone
|
inlineinherited |
Bytes of silence which were sent because bufferTx() was empty.
|
inlineinherited |
Number of isochronous OUT packets which were provided to the speaker.
|
inlineprotectedinherited |
Returns the effective volume for a per-channel index (1-based). Combines master volume (index 0) with per-channel volume and mute.
|
inlineinherited |
True if the attached device provides a microphone (RX)
|
inlineinherited |
True if the attached device provides a speaker (TX)
|
inlineinherited |
Returns true if the IN endpoint is enabled.
|
inlineinherited |
Returns true if the OUT endpoint is enabled.
|
inlineinherited |
Returns the current mute state for the given channel.
| channel | 0 = master, 1..N = per-channel. |
|
inlineinherited |
Checks if the automatic AudioInfo update is active.
|
inlineinherited |
Returns true if either the TX or RX stream is open.
|
inlineoverridevirtualinherited |
Returns true if the microphone stream (used by readBytes()) is open.
Implements USBAudioStreamBase.
|
inlineoverridevirtualinherited |
Returns true if the speaker stream (used by write()) is open.
Implements USBAudioStreamBase.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlinestaticprotectedinherited |
|
inlineoverridevirtualinherited |
Returns true if an audio device is attached and configured.
Implements USBAudioStreamBase.
|
inlineprotectedinherited |
Advance to the next step.
|
inlineprotectedvirtualinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineoverrideprotectedvirtualinherited |
A device was enumerated: desc points to the descriptors starting with an Audio Control interface descriptor and len is the number of bytes which are available after it. Returns the number of bytes which belong to the audio function (0 if the interface was not accepted).
Implements USBAudioHostEvents.
|
inlineoverrideprotectedvirtualinherited |
The device configuration is active: the class logic can start to select the alternate settings and open the streaming endpoints.
Implements USBAudioHostEvents.
|
inlineoverrideprotectedvirtualinherited |
Completion of control() or setInterface(). For IN requests len is the number of bytes which were received into the request buffer.
Implements USBAudioHostEvents.
|
inlineoverrideprotectedvirtualinherited |
The device was removed.
Implements USBAudioHostEvents.
|
inlineprotectedinherited |
Explicit feedback from the speaker: samples per packet.
|
inlineoverrideprotectedvirtualinherited |
One isochronous IN packet was received (RxData or Feedback).
Implements USBAudioHostEvents.
|
inlineoverrideprotectedvirtualinherited |
Provide the next isochronous OUT packet (TxData): fill at most max bytes into data and return the packet length.
Implements USBAudioHostEvents.
|
inlineoverrideprotectedvirtualinherited |
Called by setMute() after the state was updated: propagate the change to the USB peer.
Reimplemented from USBAudioStreamBase.
|
inlineoverrideprotectedvirtualinherited |
Called by setVolume() after the state was updated: propagate the change to the USB peer.
Reimplemented from USBAudioStreamBase.
|
inlineprotectedinherited |
|
inlineoverridevirtualinherited |
Returns true when begin() has been called and the USB connection is established.
Reimplemented from AudioStream.
|
inlinestaticprotectedinherited |
Bytes of one 1 ms packet for the indicated format (+1 sample margin)
|
inlineprotectedinherited |
|
inlineprotectedinherited |
Audio Control interface: header, terminals, units and clocks.
|
inlineprotectedinherited |
Audio Streaming interface: AS_GENERAL and FORMAT_TYPE descriptors.
|
inlineprotectedinherited |
Parses a UAC2 GET_RANGE (layout 3: 32 bit) response for the clock.
|
inlineprotectedinherited |
Parses the audio function which starts with the AC interface at desc. Returns the number of bytes which belong to the audio function.
|
inlineprotectedinherited |
Determines which channels provide a host programmable mute / volume.
|
inlineinherited |
Product id of the attached device (0 if none)
|
inlineprotectedinherited |
Called regularly from the USB stack context.
|
inlineprotectedinherited |
Pump the USB stack and process queued requests: called by the platform specific serviceUSB() or USB task.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
Process audio data for volume control.
|
inlinevirtualinherited |
Receive audio data from the USB peer. Until bufferRx() has filled past config.rx_start_fill_percent at least once after begin(), no data is returned. This is a one-shot startup prime only – once reached, readBytes() keeps draining normally for the rest of the session and is not gated again by later underruns.
Reimplemented from AudioStream.
|
inlinevirtualinherited |
Source to generate silence: just sets the buffer to 0.
|
inlineprotectedinherited |
Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineoverrideprotectedvirtual |
Resize the platform audio buffers.
Implements USBAudioStreamBase.
Reimplemented in USBAudioHostTinyUSBFreeRTOS.
|
inlineprotectedinherited |
Follow clock selectors and multipliers to the clock source.
|
inlineprotectedinherited |
Finds the Feature Unit and the Clock Source of a stream by following the entity links of its USB streaming terminal.
|
inlineprotectedinherited |
Runs the state machine until a control request is in flight.
|
inlineprotectedinherited |
Selects the alternate setting which matches the requested format best.
|
inlineprotectedinherited |
Sends the volume or mute of a channel to the next stream which supports it. Returns true if a request was issued.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineoverridevirtual |
Process pending USB events. Skipped when a dedicated FreeRTOS task already runs the USB stack (tuh_task() is not re-entrant).
Implements USBAudioStreamBase.
|
inlineoverridevirtualinherited |
Defines the audio format. Before begin() all fields can be changed; once started, a new sample rate is re-negotiated with the attached device.
Reimplemented from AudioStream.
|
inlineprotectedinherited |
Set the USB audio configuration (use begin(cfg) instead).
|
inline |
Defines the Adafruit_USBH_Host which was set up by the sketch (call before begin())
|
inlineinherited |
Set the mute state for a channel and notify the USB peer.
| m | true = muted, false = unmuted. |
| channel | 0 = master, 1..N = per-channel. |
|
inlineinherited |
Register a callback invoked when the mute state changes.
| cb | Callback receiving (bool muted, uint8_t channel). |
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
|
inlineinherited |
Register a callback invoked when the sample rate changes.
| cb | Callback receiving the new rate in Hz. |
|
inlineinherited |
Register a callback invoked when the streaming state changes (a streaming interface was opened or closed).
| cb | Callback receiving (bool active_tx, bool active_rx). |
|
inlineprotectedinherited |
(Re)sizes the volume and mute state: master (index 0) + one per channel
|
inlineinherited |
Set the volume for a channel and notify the USB peer.
| vol | Volume as a float 0.0 (silence) to 1.0 (0 dB). |
| channel | 0 = master, 1..N = per-channel. |
|
inlineoverridevirtualinherited |
sets the volume for the master channel (channel 0)
Reimplemented from VolumeSupport.
|
inlineinherited |
Register a callback invoked when the volume changes.
| cb | Callback receiving (float volume, uint8_t channel). |
|
inlineinherited |
|
inlineprotectedinherited |
Sends the next queued volume or mute change.
Stop streaming before a reconfiguration: select alt 0.
|
inlineprotectedinherited |
True if the alternate setting supports the sample rate.
|
inlinestaticprotectedinherited |
Linear mapping of 0.0..1.0 to the volume range of the device.
|
inlinestaticprotectedinherited |
Convert UAC2 int16 (1/256 dB) to linear volume (0.0–1.0). Linear mapping within the -100..0 dB range reported by GET_RANGE.
|
inlineinherited |
USB Audio Class version of the attached device: 1 or 2 (0 if none)
|
inlineprotectedinherited |
Make sure that the buffers can hold fifo_packets packets of the negotiated format
|
inlineinherited |
Vendor id of the attached device (0 if none)
|
inlineoverridevirtualinherited |
gets the volume for the master channel (channel 0)
Reimplemented from VolumeSupport.
|
inlineinherited |
Returns the current volume for the given channel.
| channel | 0 = master, 1..N = per-channel. |
|
inlinestaticprotectedinherited |
Channel used to determine the volume range.
|
inlinevirtualinherited |
Send audio data to the USB peer. Silently discards data while the TX stream is not open so StreamCopy doesn't report write errors before streaming starts.
Reimplemented from AudioStream.
|
inlineoverridevirtualinherited |
Reimplemented in MemoryStream, AudioStreamWrapper, BufferedTaskStream, RingBufferStream, BufferedStream, and URLStream.
|
inlinevirtualinherited |
Writes len bytes of silence (=0).
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
staticconstexprprotectedinherited |
|
staticconstexprprotectedinherited |
|
staticconstexprprotectedinherited |
|
staticconstexprprotectedinherited |
|
staticconstexprprotectedinherited |
|
staticconstexprprotectedinherited |
|
staticconstexprprotectedinherited |
Convert AudioTools volume (0.0–1.0) to UAC2 int16 (1/256 dB). 0.0 maps to 0x8000 (silence), 1.0 maps to 0 (0 dB).
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |