no Audio out from Teensy 4.1 with audio shield on attempt to create polyphony

Howdy everyone! Thank you all so much for your help thus far, I've got another question,

I'm working on a polyphonic synth using a Teensy 4.1 w/ Audio Adapter as the brains, and I'm putting together the code for it currently, using the github repo https://github.com/floretan/bontempi/tree/master/synth_main/src as inspiration and reference

The code I'm using for the test can be found here: https://git.gay/BorealisBlues/False-Idol-DIY-Teensy-Synth/src/branch/main/Code/test/test_channel

I have a separate test for the Voice Object (Which works as expected and makes audible noise out to headphones) located here https://git.gay/BorealisBlues/False-Idol-DIY-Teensy-Synth/src/branch/main/Code/test/test_SingleVoice

as far as I can tell, Channel::noteOn works as expected, but channel::noteOff doesn't seem able to find the right voice to turn off, which I could use some guidance on for bonus points, but my primary concern is that on a call to Channel::noteOn there isn't any sound out of the teensy

Any help would be appreciated! thank you all so much <3
 
Um … I may be wrong…but you don’t appear to be calling testNoteSequence() from loop()
ah! I'm so sorry, i forgot to commit that change, I had already noticed that and changed it in my local code, the code is otherwise identical, will push that now to avoid confusion
 
OK, so you’re starting 5 notes but can only actually play the last 2, with the result that your first 3 calls to noteOff() do nothing because the notes are no longer playing so don’t get found by the search.

This doesn't look right - the gain for mixer channel 0 will be set to 0.0...
C++:
this->mergeMixers[i]->gain(j,  (float)j/channelsPerMixer);
 
OK, so you’re starting 5 notes but can only actually play the last 2, with the result that your first 3 calls to noteOff() do nothing because the notes are no longer playing so don’t get found by the search.

This doesn't look right - the gain for mixer channel 0 will be set to 0.0...
C++:
this->mergeMixers[i]->gain(j,  (float)j/channelsPerMixer);
great catch! Updated that line to read
C++:
this->mergeMixers[i]->gain(j,  ((float)j+1.0)/channelsPerMixer);

C++:
this->mergeMixers[i]->gain(j,(1.0/channelsPerMixer));

edit: idk what i was thinking the first time oops.

and thank you for catching why I was getting alerts that channel::noteOff() wasn't able to find a note to turn off, unfortunately I still can't hear anything from the headphones
 
Last edited:
From a hardware perspective...,
Are you plugging headphones into Audio Adaptor headphone jack?
Or are you plugging something else into Audio Adaptor headphone jack?
 
From a hardware perspective...,
Are you plugging headphones into Audio Adaptor headphone jack?
Or are you plugging something else into Audio Adaptor headphone jack?
Plugging a pair of skullcandy earbuds directly into the headphone jack on the audio adaptor!

The same pair i use for daily listening and for the test located in tests/test_singleVoice
 
Right, had another chance to look, including actually compiling your code. Two things:

Voice.cpp needs this->env->noteOn(); adding to Voice::noteOn(), otherwise the envelope isn't triggered and nothing gets through to the voice output mixer. Hadn't looked too closely before, because you asserted Voice to be working as expected...

Secondly, you have:
C++:
void setup(){
    ...
    AudioConnection patchCord1(channel->outputMixer, 0, audioOut, 0); // connect our synth to the audio out
    AudioConnection patchCord2(channel->outputMixer, 0, audioOut, 1);
    ...
}
This connects fine, but as soon as setup() returns the patchcords go out of scope and are destroyed, severing the connections. You need something like:
C++:
AudioConnection* patchCord1,*patchCord2;
    
void setup(){
    ...
    patchCord1 = new AudioConnection(channel->outputMixer, 0, audioOut, 0); // connect our synth to the audio out
    patchCord2 = new AudioConnection(channel->outputMixer, 0, audioOut, 1);
    ...
}

Your envelope parameters are a bit odd; and some of your MIDI note numbers result in very low notes, which might be inaudible in some circumstances (I changed them, just to be sure).
 
Voice.cpp needs this->env->noteOn(); adding to Voice::noteOn(), otherwise the envelope isn't triggered and nothing gets through to the voice output mixer. Hadn't looked too closely before, because you asserted Voice to be working as expected...
thank you so much! I actually had the line
C++:
this->env->noteOn();
in the Voice.cpp file located in test/test_singleVoice, I'm not sure how it wound up missing from the copy in test_channel

🤦‍♀️I feel very silly for not catching the scope issue as well, but that solved it! Audio is now coming out of the teensy as desired! You're a lifesaver
 
Last edited:
Yes, it looks as if your development and test code is getting a bit out of hand - Arduino doesn't make that easy, though there are hints you're using PlatformIO, which may make a difference (I've never used it...). A quick scan reveals there are 5 copies of Voice.cpp in your repo, and they're all different from one another, which is pretty much a recipe for disaster!

One way to cope would be to split your effort into two repositories: one is a library with the infrastructure (Voice, Channel, Synth etc.) and the other contains applications and test code. Make liberal use of branching and frequent commits, so you can switch or revert to get back to known-working code, and can look at the diffs to see where you broke stuff.

I noticed your recent commit message :giggle: and can't really take much credit for being "eagle-eyed", just methodical - I was changing patchcord connections to shortcut the original routings until I got sound, so I then knew where to look. Fairly standard debugging procedure - if it's broken, compare with the last working version, or make it simpler until it works, then build it back up again. Mundane, but pretty much guaranteed to work.
 
Back
Top