|
arduino-audio-tools
|
USBAudioDeviceBase subclass for the Arduino UNO R4 / Nano R4 (Renesas RA4M1, arduino:renesas_uno core).
More...
#include <USBAudioDeviceRenesas.h>
Public Member Functions | |
| USBAudioDeviceRenesas ()=default | |
| USBAudioDeviceRenesas (USBAudioConfig cfg) | |
| virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
| Adds target to be notified about audio changes. | |
| bool | audiod_control_complete (uint8_t rhport, UsbSetupPacket const &p_request) |
| bool | audiod_control_xfer_cb (uint8_t rhport, uint8_t stage, UsbSetupPacket const &request) |
| bool | audiod_deinit (void) |
| void | audiod_init (void) |
| uint16_t | audiod_open (uint8_t rhport, UsbInterfaceDescriptorView const &itf_desc, uint8_t const *raw_desc, uint16_t max_len) |
| void | audiod_reset (uint8_t rhport) |
| void | audiod_sof_isr (uint8_t rhport, uint32_t frame_count) |
| bool | audiod_xfer_cb (uint8_t rhport, uint8_t ep_addr, UsbXferResult result, uint32_t xferred_bytes) |
| TODO refactor control request handling to separate function and reduce nesting. | |
| virtual AudioInfo | audioInfo () override |
| provides the actual input AudioInfo | |
| virtual AudioInfo | audioInfoOut () |
| uint16_t | audioPacketSize () const |
| One isochronous USB packet size in bytes (same formula as the descriptor builder). | |
| 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 () |
| (Re-)start the USB audio device with the current config. | |
| bool | begin (const USBAudioConfig &cfg) |
| Apply a config and start the USB audio device. | |
| BaseBuffer< uint8_t > & | bufferRx () override |
| Returns the RX audio buffer (public to match USBAudioDeviceESP32, so sketches using the portable USBAudioStream alias can call it on either platform). | |
| BaseBuffer< uint8_t > & | bufferTx () override |
| Returns the TX audio buffer (public to match USBAudioDeviceESP32, so sketches using the portable USBAudioStream alias can call it on either platform). | |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| USBAudioConfig | defaultConfig (RxTxMode mode=RXTX_MODE) |
| Returns a default configuration pre-filled for the requested direction (RX_MODE, TX_MODE, or RXTX_MODE). Use TX if you write and rx if you want to read audio data. RXTX is for full duplex. | |
| void | end () |
| Stop audio streaming and clear buffers. Does not disconnect USB. | |
| virtual void | flush () override |
| uint8_t | getAudioCount () const |
| Returns the number of audio functions (always 1). | |
| uint16_t | getDescriptor (uint8_t *desc) |
| Returns the audio-function descriptor block for use in tud_descriptor_configuration_cb(). | |
| uint32_t | getRxTotalBytes () const |
| Total bytes received from host via OUT endpoint. | |
| uint32_t | getRxXferCount () const |
| Number of times audiod_xfer_cb fired for the OUT endpoint. | |
| uint8_t | getTxBytesPerSample () const |
| TX bytes per sample parsed from the descriptor. | |
| uint8_t | getTxChannels () const |
| TX channel count parsed from the descriptor. | |
| uint32_t | getTxFifoReadTotal () const |
| uint16_t | getTxFrameBytesLast () const |
| uint8_t | getTxInterval () const |
| TX isochronous interval (bInterval) parsed from the descriptor. | |
| uint32_t | getTxSampleRate () const |
| TX sample rate parsed from the descriptor (must be non-zero for flow control). | |
| uint32_t | getTxXferCount () const |
| Number of times audiod_xfer_cb fired for the IN endpoint. | |
| uint32_t | getTxXferredLast () const |
| bool | isEpInEnabled () const |
| Returns true if the IN endpoint is enabled. | |
| bool | isEpInFlowControlEnabled () const |
| Returns true if IN endpoint flow control is enabled. When on, the per-frame isochronous packet size is varied so non-integer sample-per- frame rates (e.g. 44100 Hz) are delivered at the exact average rate. | |
| bool | isEpOutEnabled () const |
| Returns true if the OUT endpoint is enabled. | |
| bool | isFeedbackEpEnabled () const |
| Returns true if the feedback endpoint is enabled. Only meaningful in pure RX (OUT-only) mode: with an IN endpoint present the host uses the TX stream as implicit feedback instead. | |
| bool | isInterruptEpEnabled () const |
| Returns true if the interrupt 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 IN or OUT streaming endpoint is open. | |
| bool | isStreamingActiveRx () const |
| Returns true if the host has opened the OUT (playback) stream. | |
| bool | isStreamingActiveTx () const |
| Returns true if the host has opened the IN (capture) stream. | |
| bool | isTxXferArmed () const |
| True if the initial isochronous IN transfer was armed successfully. | |
| bool | mounted () |
| Returns true if the device is mounted by the USB host. | |
| uint8_t | numInterfaces () const |
| Total number of USB interfaces claimed by the audio function (1 AC + 1 or 2 AS), for use in the bNumInterfaces field of the configuration descriptor. | |
| operator bool () override | |
| Returns true when begin() has been called and the USB host has mounted the device. | |
| size_t | readBytes (uint8_t *buffer, size_t bufsize) |
| Receive audio data from the host (host → device, speaker/playback). | |
| 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 | setAudioFeedbackFormatCorrectionCallback (std::function< bool(USBAudioDeviceBase *, uint8_t)> cb) |
| Register a callback for audio feedback format correction events. | |
| void | setAudioFeedbackParamsCallback (std::function< void(USBAudioDeviceBase *, uint8_t, uint8_t, audio_feedback_params_t *)> cb) |
| Register a callback for audio feedback parameter events. | |
| void | setAudioInfo (AudioInfo info) override |
| Change the sample rate and notify the host. | |
| void | setFbDoneCallback (std::function< void(USBAudioDeviceBase *, uint8_t)> cb) |
| Register a callback for feedback done events. | |
| void | setGetReqEpCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, UsbSetupPacket const &)> cb) |
| Register a callback for GET requests on an endpoint. | |
| void | setGetReqItfCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, UsbSetupPacket const &)> cb) |
| Register a callback for GET requests on the interface. | |
| void | setIntDoneCallback (std::function< void(USBAudioDeviceBase *, uint8_t)> cb) |
| Register a callback for interrupt done events. | |
| void | setItfCloseEpCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, UsbSetupPacket const &)> cb) |
| Register a callback for interface close endpoint events. | |
| bool | setMute (bool m, uint8_t channel=0) |
| Set the mute state for a channel and notify the host. | |
| void | setMuteCallback (std::function< void(bool, uint8_t)> cb) |
| Register a callback invoked when the host (or device) changes the mute state. | |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
| void | setReqEntityCallback (std::function< bool(USBAudioDeviceBase *, uint8_t)> cb) |
| Register a callback for entity requests. | |
| void | setReqEntityCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, UsbSetupPacket const &, uint8_t *)> cb) |
| Register a callback for entity set requests. | |
| void | setReqEpCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, UsbSetupPacket const &, uint8_t *)> cb) |
| Register a callback for endpoint set requests. | |
| void | setReqItfCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, UsbSetupPacket const &, uint8_t *)> cb) |
| Register a callback for interface set requests. | |
| void | setRxDoneCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, audiod_function_t *, uint16_t)> cb) |
| Register a callback for RX done events. | |
| void | setSampleRateCallback (std::function< void(uint32_t)> cb) |
| Register a callback invoked when the host (or device) changes the sample rate. | |
| void | setStreamingStateCallback (std::function< void(bool, bool)> cb) |
| Register a callback invoked when the streaming state changes. Fires when the host opens or closes a streaming interface (SET_INTERFACE alt=1 / alt=0). | |
| void | setTudAudioSetItfCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, UsbSetupPacket const &)> cb) |
| Register a callback for interface set requests. | |
| void | setTxDoneCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, audiod_function_t *)> cb) |
| Register a callback for TX done events. | |
| bool | setVolume (float vol, uint8_t channel) |
| Set the volume for a channel and notify the host. | |
| 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 host (or device) changes the volume. | |
| void | setWriteBufferSize (int size) |
| 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 host (device → host, microphone/capture). Silently discards data when the host has not opened the capture device (alt=0) so StreamCopy doesn't report write errors before recording. | |
| virtual size_t | write (uint8_t ch) override |
| virtual void | writeSilence (size_t len) |
| Writes len bytes of silence (=0). | |
Static Public Member Functions | |
| static USBAudioDeviceBase & | activeInstance () |
| Returns the most-recently-constructed instance (base or subclass). | |
| static uint8_t * | customDescriptorCallback (uint8_t itfnum, size_t *len, uint8_t *num_interfaces) |
| static USBAudioDeviceRenesas & | getActualInstance () |
Protected Member Functions | |
| bool | activateEndpoint (uint8_t rhport, const UsbEndpointDescriptorView &desc_ep, UsbDir dir=UsbDir::In) |
| bool | audiod_calc_tx_packet_sz (audiod_function_t *audio) |
| bool | audiod_control_request (uint8_t rhport, UsbSetupPacket const &p_request) |
| bool | audiod_fb_send (audiod_function_t *audio) |
| bool | audiod_get_AS_interface_index (uint8_t itf, audiod_function_t *audio, uint8_t *idxItf, uint8_t const **pp_desc_int) |
| bool | audiod_get_AS_interface_index_global (uint8_t itf, uint8_t *func_id, uint8_t *idxItf, uint8_t const **pp_desc_int) |
| bool | audiod_get_interface (uint8_t rhport, UsbSetupPacket const &p_request) |
| void | audiod_parse_flow_control_params (audiod_function_t *audio, uint8_t const *p_desc) |
| bool | audiod_set_fb_params_freq (audiod_function_t *audio, uint32_t sample_freq, uint32_t mclk_freq) |
| bool | audiod_set_interface (uint8_t rhport, UsbSetupPacket const &p_request) |
| uint16_t | audiod_tx_packet_size_fc (audiod_function_t *audio) |
| bool | audiod_verify_entity_exists (uint8_t itf, uint8_t entityID, uint8_t *func_id) |
| bool | audiod_verify_ep_exists (uint8_t ep, uint8_t *func_id) |
| bool | audiod_verify_itf_exists (uint8_t itf, uint8_t *func_id) |
| USBAudioBackend & | backend () override |
| Returns the backend used for all raw USB-stack calls (TinyUSB today, or a future native-HAL backend). Must be overridden by every platform subclass; the returned reference must outlive this object. | |
| bool | beginUSB () override |
Starts the RA4M1's native USB peripheral via the core's __USBStart(). Endpoint addresses are fixed (see USB_AUDIO_EP_* in USBAudioConfig.h) since this core has no dynamic endpoint allocator; VID/PID/manufacturer/product/serial in USBAudioConfig are not applicable here – the whole composite device (CDC + HID + Audio) shares the one board-level identity the core's USB.cpp compiles in. | |
| void | closeEpIn (uint8_t rhport, audiod_function_t *audio, uint8_t itf, UsbSetupPacket const &p_request) |
| void | closeEpOut (uint8_t rhport, audiod_function_t *audio, uint8_t itf, UsbSetupPacket const &p_request) |
| bool | configChanged (const USBAudioConfig &n) |
| uint16_t | getCtrlBufSz (uint8_t fn) const |
| uint16_t | getDescLen (uint8_t fn) const |
| 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 | handleClockSourceGet (uint8_t rhport, UsbSetupPacket const &p_request, uint8_t *cb) |
| bool | handleEndpointRequest (uint8_t rhport, UsbSetupPacket const &p_request) |
| bool | handleEntityRequest (uint8_t rhport, UsbSetupPacket const &p_request, uint8_t entityID) |
| bool | handleFeatureUnitGet (uint8_t rhport, UsbSetupPacket const &p_request, uint8_t *cb) |
| bool | handleInterfaceRequest (uint8_t rhport, UsbSetupPacket const &p_request) |
| bool | isFeatureUnit (uint8_t id) const |
| Returns true if the given entity ID is a Feature Unit (FU1 or FU2). | |
| virtual int | not_supported (int out, const char *msg="") |
| void | notifyAudioChange (AudioInfo info) |
| void | notifyStreamingState () |
| bool | openEndpointsForAltSetting (uint8_t rhport, audiod_function_t *audio, uint8_t func_id, uint8_t itf, uint8_t alt) |
| void | openEpFeedback (audiod_function_t *audio, const UsbEndpointDescriptorView &desc_ep) |
| void | openEpIn (uint8_t rhport, audiod_function_t *audio, uint8_t itf, const UsbEndpointDescriptorView &desc_ep, uint8_t const *p_desc_for_params) |
| void | openEpOut (uint8_t rhport, audiod_function_t *audio, uint8_t itf, const UsbEndpointDescriptorView &desc_ep) |
| uint16_t | packetSize () const |
| 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() | |
| void | resizeBuffers () override |
| Resize buffers as block pools: block size = one USB frame at the current sample rate, block count = fifo_packets. | |
| void | sendInterruptNotification (uint8_t ctrlSel, uint8_t channel, uint8_t entityID) |
| Send a UAC2 status/change notification via the AC interrupt EP. | |
| void | serviceTinyUSB () override |
No-op: _usbfs_interrupt_handler() in the core's USB.cpp already calls tud_task() directly from the USB ISR on every interrupt, so polling it again here would be redundant (tud_task() is not re-entrant). | |
| void | setConfig (const USBAudioConfig &cfg) |
| Set the USB audio configuration (use begin(cfg) instead). | |
| void | setSampleRate (uint32_t rate) |
| Device-initiated sample rate change. | |
| void | setupFeedback (audiod_function_t *audio, uint8_t func_id, uint8_t alt) |
| void | tud_audio_feedback_interval_isr (uint8_t func_id, uint32_t, uint8_t frame_shift) |
Static Protected Member Functions | |
| 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 constexpr size_t | getResetSize () |
| static bool | isPowerOfTwo (uint32_t value) |
| static bool | isValidBitsPerSample (uint8_t bps) |
| static uint8_t | log2Floor (uint32_t value) |
| 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. | |
Protected Attributes | |
| int | _timeout = 10 |
| USBAudioConfig | active_config_ |
| std::vector< audiod_function_t > | audiod_fct_ |
| USBAudioBackendTinyUSB | backend_impl_ |
| bool | begin_called_ = false |
| RingBufferSPSC< uint8_t > | buffer_rx_ |
| RingBufferSPSC< uint8_t > | buffer_tx_ |
| USBAudioConfig | config_ |
| std::vector< uint16_t > | ctrl_buf_sz_ |
| std::vector< uint16_t > | desc_len_ |
| USBAudio2DescriptorBuilder | descr_builder {config_} |
| std::function< void(USBAudioDeviceBase *, uint8_t func_id)> | fb_done_cb_ |
| std::function< bool(USBAudioDeviceBase *, uint8_t rhport, UsbSetupPacket const &)> | get_req_ep_cb_ |
| std::function< bool(USBAudioDeviceBase *, uint8_t rhport, UsbSetupPacket const &)> | get_req_itf_cb_ |
| AudioInfo | info |
| std::function< void(USBAudioDeviceBase *, uint8_t rhport)> | int_done_cb_ |
| uint8_t | int_notify_buf_ [6] = {} |
| bool | is_active_ = false |
| bool | is_notify_active = true |
| bool | is_started_ = false |
| std::vector< bool > | mute_ |
| std::function< void(bool, uint8_t)> | mute_cb_ |
| Vector< AudioInfoSupport * > | notify_vector |
| std::function< bool(USBAudioDeviceBase *, uint8_t func_id)> | req_entity_cb_ |
| std::function< bool(USBAudioDeviceBase *, uint8_t rhport, audiod_function_t *, uint16_t xferred_bytes)> | rx_done_cb_ |
| volatile uint32_t | rx_total_bytes_ = 0 |
| std::function< void(uint32_t)> | sample_rate_cb_ |
| std::function< void(bool, bool)> | streaming_state_cb_ |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| std::function< bool(USBAudioDeviceBase *, uint8_t func_id)> | tud_audio_feedback_format_correction_cb_ |
| std::function< void(USBAudioDeviceBase *, uint8_t func_id, uint8_t alt_itf, audio_feedback_params_t *feedback_param)> | tud_audio_feedback_params_cb_ |
| std::function< bool(USBAudioDeviceBase *, uint8_t rhport, UsbSetupPacket const &p_request)> | tud_audio_set_itf_cb_ |
| std::function< bool(USBAudioDeviceBase *, uint8_t rhport, UsbSetupPacket const &p_request)> | tud_audio_set_itf_close_EP_cb_ |
| std::function< bool(USBAudioDeviceBase *, uint8_t rhport, UsbSetupPacket const &p_request, uint8_t *pBuff)> | tud_audio_set_req_entity_cb_ |
| std::function< bool(USBAudioDeviceBase *, uint8_t rhport, UsbSetupPacket const &p_request, uint8_t *pBuff)> | tud_audio_set_req_ep_cb_ |
| std::function< bool(USBAudioDeviceBase *, uint8_t rhport, UsbSetupPacket const &p_request, uint8_t *pBuff)> | tud_audio_set_req_itf_cb_ |
| std::function< bool(USBAudioDeviceBase *, uint8_t rhport, audiod_function_t *)> | tx_done_cb_ |
| volatile uint32_t | tx_fifo_read_total_ = 0 |
| volatile uint16_t | tx_frame_bytes_last_ = 0 |
| bool | tx_xfer_armed_ = false |
| volatile uint32_t | tx_xferred_last_ = 0 |
| bool | usb_task_active_ = false |
| std::vector< float > | volume_ |
| std::function< void(float, uint8_t)> | volume_cb_ |
| float | volume_value = 1.0f |
| int | write_buffer_size = MAX_SINGLE_CHARS |
| volatile uint32_t | xfer_cb_rx_count_ = 0 |
| volatile uint32_t | xfer_cb_tx_count_ = 0 |
Static Protected Attributes | |
| 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). | |
| static USBAudioDeviceBase * | s_active_ = nullptr |
Friends | |
| class | Emulated_TinyUSB |
USBAudioDeviceBase subclass for the Arduino UNO R4 / Nano R4 (Renesas RA4M1, arduino:renesas_uno core).
The core's own USB.cpp runs TinyUSB internally (via its RUSB2 Device Controller Driver), so USBAudioBackendTinyUSB is reused as-is here – this class only supplies the platform-specific descriptor-registration glue, matching the pattern of USBAudioDeviceESP32/USBAudioDeviceTinyUSB.
Stock arduino:renesas_uno (as of release 1.6.0) builds one fixed composite descriptor (CDC + HID + MSD) with no extension point for a third-party class driver – this class needs the USB.h/USB.cpp hook that lets an external interface append itself (a weak __USBGetCustomInterfaceDescriptor() callback, checked and invoked from __SetupUSBDescriptor() the same way HID's __USBGetHIDReport() already is). Without that hook in the core, this file will still compile but the Audio interface will silently never appear in the composite descriptor.
main.cpp calls __USBStart() (which builds and freezes the composite descriptor) automatically at boot, before the sketch's setup() runs – unless the board defines NO_USB (UNO R4 WiFi already does; UNO R4 Minima/Nano R4 do not). Since the descriptor is built lazily but then cached forever (usbd_desc_cfg is only ever assigned once), our Audio interface must be registered before the first build, which means beginUSB() here has to be the one calling __USBStart() – after the sketch's setup() has configured the audio format via begin(). On boards that auto-start USB before setup() runs (Minima/Nano R4), add -DNO_USB yourself, e.g. via arduino-cli compile --build-property "build.extra_flags=-DNO_USB" or a boards.local.txt/platform.local.txt override. With NO_USB defined, the Serial macro maps to a plain UART instead of native-USB CDC – use SerialUSB explicitly if you also want USB serial alongside audio (see usb-tx.ino's composite-device pattern).
|
default |
|
inline |
|
inlineprotectedinherited |
|
inlinestaticinherited |
Returns the most-recently-constructed instance (base or subclass).
Set in the constructor via s_active_, so usbd_app_driver_get_cb() and the static process() trampoline can reach the right object without a singleton.
|
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.
|
inlineprotectedinherited |
|
inlineinherited |
|
inlineprotectedinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineprotectedinherited |
|
inlineinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineinherited |
TODO refactor control request handling to separate function and reduce nesting.
|
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, and ResampleStreamT< TInterpolator >.
|
inlineinherited |
One isochronous USB packet size in bytes (same formula as the descriptor builder).
|
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 raw USB-stack calls (TinyUSB today, or a future native-HAL backend). Must be overridden by every platform subclass; the returned reference must outlive this object.
Implements USBAudioDeviceBase.
|
inlinevirtualinherited |
(Re-)start the USB audio device with the current config.
Safe to call more than once: descriptor building, FIFO allocation, and USB stack startup only run on the first call. Subsequent calls just push the current volume/mute/sample-rate state to the host.
Reimplemented from BaseStream.
|
inlineinherited |
Apply a config and start the USB audio device.
Before the first begin() all fields may be changed freely. Once started, only the sample rate can change at runtime (via setSampleRate()); descriptor-level fields like channels, bit depth, and endpoint addresses are fixed by the USB enumeration.
| cfg | Audio configuration. |
|
inlineoverrideprotectedvirtual |
Starts the RA4M1's native USB peripheral via the core's __USBStart(). Endpoint addresses are fixed (see USB_AUDIO_EP_* in USBAudioConfig.h) since this core has no dynamic endpoint allocator; VID/PID/manufacturer/product/serial in USBAudioConfig are not applicable here – the whole composite device (CDC + HID + Audio) shares the one board-level identity the core's USB.cpp compiles in.
Implements USBAudioDeviceBase.
|
inlineoverridevirtual |
Returns the RX audio buffer (public to match USBAudioDeviceESP32, so sketches using the portable USBAudioStream alias can call it on either platform).
Implements USBAudioDeviceBase.
|
inlineoverridevirtual |
Returns the TX audio buffer (public to match USBAudioDeviceESP32, so sketches using the portable USBAudioStream alias can call it on either platform).
Implements USBAudioDeviceBase.
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlinestatic |
Called by the core's __SetupUSBDescriptor() (via the weak __USBGetCustomInterfaceDescriptor hook defined below) to fetch our UAC2 descriptor block. itfnum is the first free (0-based) interface number – CDC/HID/MSD have already claimed lower numbers by the time this runs, matching the same running-interface-index handoff used by USBAudioDeviceESP32::descriptorCallback.
|
inlineinherited |
Returns a default configuration pre-filled for the requested direction (RX_MODE, TX_MODE, or RXTX_MODE). Use TX if you write and rx if you want to read audio data. RXTX is for full duplex.
| mode | Audio direction. |
|
inlinevirtualinherited |
Stop audio streaming and clear buffers. Does not disconnect USB.
Reimplemented from BaseStream.
|
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, I2SStream, MemoryStream, RingBufferStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and BufferedStream.
|
inlinestatic |
|
inlineinherited |
Returns the number of audio functions (always 1).
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineinherited |
Returns the audio-function descriptor block for use in tud_descriptor_configuration_cb().
Call begin() first so that the config is known. The returned pointer points to an internal static buffer that is valid for the lifetime of the program; copy it into your configuration descriptor buffer.
| [out] | len | Total byte count of the returned block. |
|
inlinestaticconstexprprotectedinherited |
|
inlineinherited |
Total bytes received from host via OUT endpoint.
|
inlineinherited |
Number of times audiod_xfer_cb fired for the OUT endpoint.
|
inlineinherited |
TX bytes per sample parsed from the descriptor.
|
inlineinherited |
TX channel count parsed from the descriptor.
|
inlineinherited |
Total bytes read from ep_in_ff by xfer_cb (should grow at ~176KB/s for 44100Hz stereo 16-bit).
|
inlineinherited |
Last frame_bytes computed by flow control (should be ~176-180 for 44100Hz).
|
inlineinherited |
TX isochronous interval (bInterval) parsed from the descriptor.
|
inlineinherited |
TX sample rate parsed from the descriptor (must be non-zero for flow control).
|
inlineinherited |
Number of times audiod_xfer_cb fired for the IN endpoint.
|
inlineinherited |
xferred_bytes from the previous completed transfer (what the DCD actually sent).
|
inlineprotectedinherited |
Returns the effective volume for a per-channel index (1-based). Combines master volume (index 0) with per-channel volume and mute.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineinherited |
Returns true if the IN endpoint is enabled.
|
inlineinherited |
Returns true if IN endpoint flow control is enabled. When on, the per-frame isochronous packet size is varied so non-integer sample-per- frame rates (e.g. 44100 Hz) are delivered at the exact average rate.
|
inlineinherited |
Returns true if the OUT endpoint is enabled.
|
inlineprotectedinherited |
Returns true if the given entity ID is a Feature Unit (FU1 or FU2).
|
inlineinherited |
Returns true if the feedback endpoint is enabled. Only meaningful in pure RX (OUT-only) mode: with an IN endpoint present the host uses the TX stream as implicit feedback instead.
|
inlineinherited |
Returns true if the interrupt 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.
|
inlinestaticprotectedinherited |
|
inlineinherited |
Returns true if either IN or OUT streaming endpoint is open.
|
inlineinherited |
Returns true if the host has opened the OUT (playback) stream.
|
inlineinherited |
Returns true if the host has opened the IN (capture) stream.
|
inlineinherited |
True if the initial isochronous IN transfer was armed successfully.
|
inlinestaticprotectedinherited |
|
inlinestaticprotectedinherited |
|
inlineinherited |
Returns true if the device is mounted by the USB host.
|
inlineprotectedvirtualinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineinherited |
Total number of USB interfaces claimed by the audio function (1 AC + 1 or 2 AS), for use in the bNumInterfaces field of the configuration descriptor.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineoverridevirtualinherited |
Returns true when begin() has been called and the USB host has mounted the device.
Reimplemented from AudioStream.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
Process audio data for volume control.
|
inlinevirtualinherited |
Receive audio data from the host (host → device, speaker/playback).
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 >.
|
inlineoverrideprotectedvirtual |
Resize buffers as block pools: block size = one USB frame at the current sample rate, block count = fifo_packets.
Implements USBAudioDeviceBase.
|
inlineprotectedinherited |
Send a UAC2 status/change notification via the AC interrupt EP.
6-byte message: bInfo(1) bAttribute(1) wValue(2) wIndex(2). The host will re-query the affected control with GET_CUR.
| ctrlSel | Control selector (e.g. AUDIO_FU_CTRL_VOLUME). |
| channel | Channel number (0 = master). |
| entityID | Target entity (Feature Unit or Clock Source). |
|
inlineoverrideprotectedvirtual |
No-op: _usbfs_interrupt_handler() in the core's USB.cpp already calls tud_task() directly from the USB ISR on every interrupt, so polling it again here would be redundant (tud_task() is not re-entrant).
Implements USBAudioDeviceBase.
|
inlineinherited |
Register a callback for audio feedback format correction events.
| cb | Callback function. |
|
inlineinherited |
Register a callback for audio feedback parameter events.
| cb | Callback function. |
|
inlineoverridevirtualinherited |
Change the sample rate and notify the host.
Reimplemented from AudioStream.
|
inlineprotectedinherited |
Set the USB audio configuration (use begin(cfg) instead).
|
inlineinherited |
Register a callback for feedback done events.
| cb | Callback function. |
|
inlineinherited |
Register a callback for GET requests on an endpoint.
| cb | Callback function. |
|
inlineinherited |
Register a callback for GET requests on the interface.
| cb | Callback function. |
|
inlineinherited |
Register a callback for interrupt done events.
| cb | Callback function. |
|
inlineinherited |
Register a callback for interface close endpoint events.
| cb | Callback function. |
|
inlineinherited |
Set the mute state for a channel and notify the host.
| m | true = muted, false = unmuted. |
| channel | 0 = master, 1..N = per-channel. |
|
inlineinherited |
Register a callback invoked when the host (or device) changes the mute state.
| cb | Callback receiving (bool muted, uint8_t channel). |
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
|
inlineinherited |
Register a callback for entity requests.
| cb | Callback function. |
|
inlineinherited |
Register a callback for entity set requests.
| cb | Callback function. |
|
inlineinherited |
Register a callback for endpoint set requests.
| cb | Callback function. |
|
inlineinherited |
Register a callback for interface set requests.
| cb | Callback function. |
|
inlineinherited |
Register a callback for RX done events.
| cb | Callback function. |
|
inlineprotectedinherited |
Device-initiated sample rate change.
Updates the internal config, fires the sample-rate callback, and notifies the host via the AC interrupt endpoint (Clock Source SAM_FREQ CUR). The host will typically re-issue SET_INTERFACE to restart streaming at the new rate.
| rate | New sample rate in Hz (should be one of the 14 rates advertised in the Clock Source GET_RANGE response). |
|
inlineinherited |
Register a callback invoked when the host (or device) changes the sample rate.
| cb | Callback receiving the new rate in Hz. |
|
inlineinherited |
Register a callback invoked when the streaming state changes. Fires when the host opens or closes a streaming interface (SET_INTERFACE alt=1 / alt=0).
| cb | Callback receiving (bool active_tx, bool active_rx). |
|
inlineinherited |
Register a callback for interface set requests.
| cb | Callback function. |
|
inlineinherited |
Register a callback for TX done events.
| cb | Callback function. |
|
inlineprotectedinherited |
|
inlineinherited |
Set the volume for a channel and notify the host.
| 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 host (or device) changes the volume.
| cb | Callback receiving (float volume, uint8_t channel). |
|
inlineinherited |
|
inlineprotectedinherited |
|
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.
|
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. |
|
inlinevirtualinherited |
Send audio data to the host (device → host, microphone/capture). Silently discards data when the host has not opened the capture device (alt=0) so StreamCopy doesn't report write errors before recording.
Reimplemented from AudioStream.
|
inlineoverridevirtualinherited |
Reimplemented in MemoryStream, AudioStreamWrapper, BufferedTaskStream, RingBufferStream, BufferedStream, and URLStream.
|
inlinevirtualinherited |
Writes len bytes of silence (=0).
|
friend |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
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 |
|
inlinestaticprotectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |