Skip to content

Commit 28642ab

Browse files
committed
Add audio output support!
This evolves the API from 2.x (and breaks it). Playback devices are now separate from the samples themselves. This allows for greater playback flexibility. Two sample sources are audioio.RawSample and audioio.WaveFile. They can both be mono or stereo. They can be output to audioio.AudioOut or audiobusio.I2SOut. Internally, the dma tracking has changed from a TC counting block transfers to an interrupt generated by the block event sent to the EVSYS. This reduces the overhead of each DMA transfer so multiple can occure without using up TCs. Fixes adafruit#652. Fixes adafruit#522. Huge progress on adafruit#263
1 parent e311d17 commit 28642ab

36 files changed

Lines changed: 2953 additions & 731 deletions

ports/atmel-samd/Makefile

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ endif
220220
SRC_ASF := $(addprefix asf4/$(CHIP_FAMILY)/, $(SRC_ASF))
221221

222222
SRC_C = \
223+
audio_dma.c \
223224
background.c \
225+
clocks.c \
226+
events.c \
224227
fatfs_port.c \
225228
flash_api.c \
226229
mphalport.c \
@@ -276,7 +279,7 @@ SRC_COMMON_HAL = \
276279
neopixel_write/__init__.c \
277280
os/__init__.c \
278281
storage/__init__.c \
279-
supervisor/__init__.c \
282+
supervisor/__init__.c \
280283
supervisor/Runtime.c \
281284
time/__init__.c \
282285
analogio/__init__.c \
@@ -287,12 +290,11 @@ SRC_COMMON_HAL = \
287290
pulseio/PulseOut.c \
288291
pulseio/PWMOut.c \
289292
usb_hid/__init__.c \
290-
usb_hid/Device.c
291-
# audiobusio/__init__.c \
292-
audiobusio/PDMIn.c \
293+
usb_hid/Device.c \
293294
audioio/__init__.c \
294295
audioio/AudioOut.c \
295-
nvm/__init__.c \
296+
# nvm/__init__.c \
297+
audiobusio/PDMIn.c \
296298
nvm/ByteArray.c \
297299
touchio/__init__.c \
298300
touchio/TouchIn.c \
@@ -338,6 +340,8 @@ SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
338340
$(addprefix common-hal/, $(SRC_COMMON_HAL))
339341

340342
SRC_SHARED_MODULE = \
343+
audioio/RawSample.c \
344+
audioio/WaveFile.c \
341345
bitbangio/__init__.c \
342346
bitbangio/I2C.c \
343347
bitbangio/OneWire.c \
@@ -355,6 +359,22 @@ SRC_SHARED_MODULE = \
355359
uheap/__init__.c \
356360
ustack/__init__.c
357361

362+
ifeq ($(CHIP_FAMILY),samd21)
363+
SRC_COMMON_HAL = $SRC_COMMON_HAL \
364+
audiobusio/__init__.c \
365+
audiobusio/I2SOut.c
366+
endif
367+
ifeq ($(CHIP_VARIANT),SAMD51G18)
368+
SRC_COMMON_HAL = $SRC_COMMON_HAL \
369+
audiobusio/__init__.c \
370+
audiobusio/I2SOut.c
371+
endif
372+
ifeq ($(CHIP_VARIANT),SAMD51G19)
373+
SRC_COMMON_HAL = $SRC_COMMON_HAL \
374+
audiobusio/__init__.c \
375+
audiobusio/I2SOut.c
376+
endif
377+
358378
SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \
359379
$(addprefix shared-module/, $(SRC_SHARED_MODULE))
360380

0 commit comments

Comments
 (0)