Commit Graph

18 Commits

Author SHA1 Message Date
Jeff Epler 989fb828d4
Revamp background writing
Now a 'once' and a 'loop' buffer can be specified.

'once' is useful for things like writing a neopixel strip in the background,
if you can guarantee the buffer contents are stable until the write is complete.

'loop' is useful for periodic things, like pwm & servos.

both together are useful for some special cases of pwm/servo, where a
transitional waveform needs to be played for one repetition and then
a new waveform needs to be played after that.

The API is renamed to reflect that it's a more generic 'background'
operation.
2022-04-23 13:09:36 -05:00
Jeff Epler 144eb5dfd4
fix lost DMA IRQ 2022-04-19 16:42:27 -05:00
Jeff Epler 33d6d55675
the basics work
the sequence has to be a minimum length, 8 entries, but this problem
is not detected. I don't THINK this is an insurmountable problem.
2022-04-19 15:14:50 -05:00
Dan Halbert d2d0bd289f Fix RP2040 I2S: always copy to output buffer 2021-09-07 16:35:42 -04:00
Dan Halbert b8b23c97d9 improve SAMD audio DMA 2021-08-21 14:34:37 -04:00
Dan Halbert 4608877c12 address review comments 2021-08-11 12:10:49 -04:00
Dan Halbert 24e61a7da8 Track more carefully which audio buffers to fill, based on interrupt channels 2021-08-10 22:00:09 -04:00
Dan Halbert 2451c788f4 valid channels in audio_dma_stop; cleaner supervisor_ticks mgmt in keypad 2021-08-09 09:47:13 -04:00
Dan Halbert 59b89fdc5c Fix various audio DMA issues:
RP2040 and SAMD51:
- Detect when DMA has finished, and stop DMA audio explicitly.
- Do not accidentally reuse `first_buffer` supplied by WaveFile or RawSample. Always realloc `first_buffer` and `second_buffer`

RP2040:
- When audio playing is stopped, write a final zero to the output register. This prevents residual PWM tones.
- Handle buffer size for 8-bit samples properly for 16-bit output.
- Fail on some edge cases (which may not be possible at the moment).
2021-08-09 09:47:13 -04:00
Dan Halbert 2cd80d1074 wip, with debugging printf's 2021-08-09 09:47:13 -04:00
Dan Halbert fd71d924d2 partial buffer mgmt fix 2021-08-09 09:47:13 -04:00
Dan Halbert bd6826496c Fix various RP2040 audio dma things: (see detailed commit message)
1. Check for correct error values from dma_claim_unused_channel.
2. Introduce a .stereo flag for simplicity.
3. Clarify PWM carrier frequency choice.
4. Start introducing quiescent audio value. Still need to ramp up/down.
5. Redo audio stop logic a bit.
6. Fix (unrelated) displayio dependency things.

There is still an interference problem between other DMA users and audio. Still debugging this.
2021-07-08 08:14:49 -04:00
Dan Halbert 33bbb8b1f4 RP2040 PWMAudioOut: Release DMA channels after play has finished. 2021-07-01 17:36:29 -04:00
root 760e8c77bd Changes to correct repeat playing on a channel 2021-05-29 11:55:10 -05:00
root 24e641a834 Fix for Issue #4266 2021-05-25 16:06:00 -05:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Scott Shawcroft 360475e266
Implement audiobusio and enhance PIO for it
This adds I2SOut and PDMIn support via PIO.

StateMachines can now:
 * read and read while writing
 * transfer in 1, 2 or 4 byte increments
 * init pins based on expected defaults automatically
 * be stopped and restarted
 * rxfifo can be cleared and rxstalls detected (good for tracking when
   the reading code isn't keeping up)

Fixes #4162
2021-02-23 15:50:00 -08:00
Scott Shawcroft 191b143e7b
Add PWM based audio playback
See
https://learn.adafruit.com/circuitpython-essentials/circuitpython-audio-out
to get started.

Fixes #4037
2021-02-09 15:38:33 -08:00