Closed
Description
While trying to reproduce #1992, I ran into this behvaior instead.
Testing setup: A0, A1 into o'scope. Put some.wav and code.py on CIRCUITPY.
Initially, A0 and A1 both display a signal, but often A1 stops showing signal before A0 even though both halves of the sample should play for the same duration. The length of time A1 plays varies. Oddly, it also varies whether the DAC value is high or low at the end of sample playing, on A0 and A1.
The conjecture is, it's a problem with DMA.
Tested in 4.1.0 and master on a Metro M4 Express.
Code to create wave file:
import array
from numpy import zeros
import scipy.io.wavfile
X=-32768+8000
Y=32767
sz = (512, 2)
a = zeros(sz, 'h')
a -= 32768
for i in range(0,sz[0],2):
a[i,0] = X
a[i,1] = X
scipy.io.wavfile.write("some.wav", 200000, a)
Code to run on circuitpython:
import board
import audioio
import array
import time
X = 4000
Y = 65535
data = array.array('H', [0,0,Y,X])
#sample = audioio.RawSample(data, sample_rate=24 * 1000, channel_count=2)
some_wav = open('some.wav', 'rb')
sample = audioio.WaveFile(some_wav)
### A0 will be x, A1 will be y
a = audioio.AudioOut(board.A0, right_channel=board.A1)
while 1:
a.play(sample, loop=True)
time.sleep(1)
a.stop()
time.sleep(1)