stymied by a bug in my teensy audio object ...

Not open for further replies.


Well-known member

I'm trying to implement a simple Karpluss-Strong object for Teensy Audio, and I'm having a hard time.
I suspect that something I'm doing is crashing the audio library, but I can't see what I'm doing wrong.

The object has one input, which is hooked to an AudioSynthNoisePink object, to use it as a source of
excitation for the KS buffer. Normally the KS object would take a small sip from that and then
start iterating on its own buffer from there. However, to simplify debugging, I whittled down my
update() method to the point that all it *should* be doing is copying its input to its output. And then
I reduced it to simply retransmitting the block it receives. Either way, I'm still getting the same problem.

The symptoms are:
-- When I trigger the KS object, I hear a brief burst of noise, then no audio.
-- On the second & subsequent calls to my object's update() method, the receiveReadOnly() method always returns NULL. (Why, I can't say. The gain is still set to 1.)
-- Once this has happened, I hear no more sound out of the library until I reset the Teensy. Completely unrelated objects that work before I trigger the KS object go silent afterwards.
-- All of my midi-event-managing code continues to run, and I get debugging lines from my object which assure me that update() is still being called regularly.

Other things I've tried:
-- circumventing almost all of the audio network & plugging KS directly into the i2s output did not help at all.
-- circumventing the KS object & running the noise directly into the rest of the network seems to work just fine.

... Anyway, I'm going to presumptuously post the current (messy, incomplete, in-process) code here, in the hopes that someone might have time to play spot-the-bug. Thanks in advance! -mykle-

View attachment AudioSyn.h
View attachment AudioSynthKS.cpp
View attachment bleep.ino
It sounds like it could be a buffer exhauation problem. A few things to check:

  • How many buffers are you allocating with AudioMemory() in steup()?
  • Are you calling transmit() and release() on the block?
  • You can check the number of buffers that have been used simultaneously with AudioMemoryUsageMax(). You should leave some margin between this number and the number allocated in steup.


Edit: I just took a peek at your code.

You need to call release() at the end of update().
You *must* release your hold on the audio block after transmitting.

Transmitting does not release your hold on the block.
You mean I need to release the block I get with receiveReadOnly()? That's probably the problem, because I'm definitely not doing that. I'll give it a try. Thanks!
Not open for further replies.