Commit graph

16 commits

Author SHA1 Message Date
Cooper Dalrymple
a426fbf51d
Add buffer read to AudioBufferManager and I2S (#2777)
* Added buffer read to `AudioBufferManager` and `I2S`. Example and documentation included.
* Update type of words to unsigned in example.
* Improve buffered loopback example.
* Remove const from read buffer.
2025-01-26 10:03:44 -08:00
Earle F. Philhower, III
cc2581afd6
Properly wrap AudioBufferManager block writes (#2725)
The memcpy-version of the ABM::write updated the destination and count
but neglected to move the source forward.  If a block write crossed a
frame boundary then the 2nd frame would repeat the data from the first
half of the buffer.

Fix by incrementing the source pointer by the same amount as was written.
2024-12-29 16:26:23 -08:00
Earle F. Philhower, III
5fb5e16be8
Add real block write for AudioRequestBuffer (#2712)
Optimize AudioRequestBuffer writing when large blocks are available (i.e.
I2S writes of full MP3 or AAC frames in BackgroundAudio).  Update I2S to use
the new call.  Reduces 1152 calls to arb::write() to a single call/return
and optimized memcpy in that case.
2024-12-21 14:15:40 -08:00
Earle F. Philhower, III
66af359578
Remove unused variable from AudioBufferManager class (#2701) 2024-12-18 07:06:40 -08:00
Earle F. Philhower, III
a02e188fc7
PWMAudio setFrequency optimization (#2683)
If we set the frequency to the same one running, no need to do anything.
2024-12-13 08:04:50 -08:00
Earle F. Philhower, III
5b4dff9a77
Add optional callback parameters for I2S/PWMAudio (#2677)
Like GPIO interrupts, allow the user to pass in a callback data pointer.
2024-12-11 14:53:54 -08:00
Earle F. Philhower, III
bf385490d3
Fix crash on audio end from IRQ, refactor A2DP (#2189)
Fixes #2188

We get a call to stop the audio channel from a timer/IRQ context, so can't
safely remove the IRQ handler for the AudioBufferManager.  The SDK will panic.

Because the IRQ handler will be a noop if it's not uninstalled, we will
instead just leave our shared handler in place and let it do nothing.

Use a common BluetoothLock RAII in BluetoothAudio to clen up the code and
automatically lock BT for the AVRCP button methods.
2024-05-31 12:14:57 -07:00
LinusHeu
73722b5c87
Fix I2S stop/start race condition #1656 (#1659)
Fixes  #1656
2023-08-22 08:40:23 -07:00
Earle F. Philhower, III
cc800713bd
Minor clean up includes (#1520) 2023-06-10 20:42:28 -07:00
Linar Yusupov
c6a0d6ecfe
Fix for invalid __channelCount in ~AudioBufferManager() (#1519) 2023-06-10 10:51:19 -07:00
Earle F. Philhower, III
3c408dab7c
AudioBufferManager(I2s, PWMAudio, ADCInput) clicking fix (#1500)
The ABM had an off-by-one error in the DMA buffer swapover.  Instead of
setting the DMA address to the newly added buffer in active[], it set it
to the buffer that was currently running.

This would effectively disable the ping-pong and cause clicks/lost data.

Fixes #1491
2023-06-04 18:40:29 -07:00
LinusHeu
45bbcca207
AudioBufferManager: Make dma_claim_unused_channel() not panic (#1487) 2023-05-30 15:51:07 -07:00
Earle F. Philhower, III
b6cb2e7edc
Avoid race condition in I2S/PWMAudio delete (#1163)
Fixes #1162

Disable DMA interrupts while we're tearing down an AudioBufferManager
and explicitly clear any potential leftover IRQs to avoid hangs.
2023-02-09 13:29:45 -08:00
Earle F. Philhower, III
da26016edf
DMA-based ADC input (microphone, analog sensor) (#1101)
Mimics the I2S/PWMAudio/Stream interface for ease of use.

* Fix non-32b DMA size transfer calculation in ABM
* Rename wasHolding to isHolding in the I2S/PWM
  It is the **current** number of bits left, not the past number.
* Add commented microphone example
* Add docs
2023-01-05 16:00:34 -08:00
Earle F. Philhower, III
02465b48b3
Allow on-the-fly changes to PWMAudio when possible (#1098)
Also fix crash on PWMAudio::end()
2023-01-03 16:02:43 -08:00
Earle F. Philhower, III
08d37de94e
Add PWMAudio for DAC-free audio playback (#1076)
Use the PWM hardware to generate a signal suitable for filtering and
amplifying 16bps audio output.

Refactor the AudioBufferManager to allow sharing with I2S

Add example
2022-12-30 13:24:06 -08:00