PYNQ: PYTHON PRODUCTIVITY

pAudio.play() never exits with built tones

I am playing with the audio on my PYNQ Tul-2 Board (the overlay is from May 2020), trying to build my own audio.

I wrote a simple routine to fill the channels with sine-wave data:

from pynq.overlays.base import BaseOverlay

import numpy as np
import math

adc_sample_freq = 48000             # Number of samples we need to provide per second. 

base = BaseOverlay("base.bit")
pAudio = base.audio

pAudio.configure(sample_rate=adc_sample_freq)
pAudio.select_microphone()

num_samples = adc_sample_freq*2*10  # 10-seconds of dual-channel audio 
#
# Build an array in numpy of int32s.

samples = np.zeros(num_samples).astype(np.int32)
TwoPi = math.pi*2
amplitude = 500000

#
# Build two sine-waves. 
#
def MakeSample(sample,tone_freq):
  return int(math.sin((sample*TwoPi)*tone_freq/adc_sample_freq)*amplitude)

for sample in range(0,num_samples,2):
   samples[sample] = MakeSample(sample/2,400)
   samples[sample+1] = MakeSample(sample/2,300)

pAudio.buffer     = samples
pAudio.sample_len = num_samples


pAudio.play()

I hear the sine-waves just fine, but play() never exits. Any idea what I might be doing wrong here?

Thanks,

Roger