Skip to content

M4 Express: playing data array through audioio.AudioOut does loop infinite when dac.play(sine_wave, loop=False) #5961

@digixx

Description

@digixx

CircuitPython version

Adafruit CircuitPython 7.1.1

Code/REPL

import audiocore
import audioio
import board
import array
import time
import math

# Generate one period of sine wav.
length = 8000 // 440
sine_wave = array.array("h", [0] * length)
for i in range(length):
    sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15))
    print("Sin", sine_wave[i])

dac = audioio.AudioOut(board.A0)
sine_wave = audiocore.RawSample(sine_wave)
dac.play(sine_wave, loop=False)
while dac.playing:
    print("*", end="")
    time.sleep(0.25)
    
print("done")

Behavior

Running code on 7.1.1

soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Sin 0
Sin 11207
Sin 21062
Sin 28377
Sin 32270
Sin 32270
Sin 28377
Sin 21062
Sin 11207
Sin 0
Sin -11207
Sin -21062
Sin -28377
Sin -32270
Sin -32270
Sin -28377
Sin -21062
Sin -11207


running code on 6.1.0

soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

code.py output:
Sin 0
Sin 11207
Sin 21062
Sin 28377
Sin 32270
Sin 32270
Sin 28377
Sin 21062
Sin 11207
Sin 0
Sin -11207
Sin -21062
Sin -28377
Sin -32270
Sin -32270
Sin -28377
Sin -21062
Sin -11207
**done

Code done running.

Description

First I found this behavior on a new project using a Feather M4 Express, now I testet it on a ItsyBitsy M4 Express as well with the same results.

An array of data playing through the DMA to the DAC does not stop mat the end. The function dac.playing returns always True.

In CircuitPython Version 6.1.0 the code is working as excepted.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions