Paul: suggestion for audio library

Status
Not open for further replies.

grahamguitarman

Well-known member
Hi Paul,

Since you are doing some work on the audio libray at the moment may I suggest a useful addition to it - namely a reverse mixer.
Basically, it would work exactly like the current mixer object, but in reverse, i.e. one input and four outputs.
This would be a godsend for synth design using your library because at the moment its easy to mix several signals / control 'voltages' into one source.
But it is difficult (and very messy) to do things the opposite way, for example sending the output of one lfo to multiple objects (vco, vcf, vca etc), with the ability to control how much of that signal is fed to them. It would also make signal switching a lot easier when rerouting signals around the synth.

Another thing I wanted to ask about, is interfacing with audio objects in code to get a value.
Some of my synth objects use custom code for their waveform effects, but I've found myself having to write lfo's and envelopes in code to control them, purely to provide control values I can read.
Is there a simple way to access the output of waveforms, waveshapers, multipliers and envelope generators, so the output levels can be used to drive other parts of the code.
Bearing in mind I'm not a C programmer so don't have low level coding skills.

If not would it be possible to add an object into the audio design tool like the AudioOutputI2s object, that can read the current value of whatever is plugged into it and then make that value accessible via an object.readvalue() command, a sort of snapshot of the current value that can be read once per loop sort of thing.

Thanks for reading :)
 
But it is difficult (and very messy) to do things the opposite way, for example sending the output of one lfo to multiple objects (vco, vcf, vca etc), with the ability to control how much of that signal is fed to them. It would also make signal switching a lot easier when rerouting signals around the synth.

I have considered adding a simple gain/amplifier/attenuator object. Maybe that would work for this need? If you want to send the same signal with different levels to many places, you'd put several of these and connect the signal to each one. Functionally it would be identical to a mixer with only 1 channel connected (no mixing, just apply the gain), but perhaps from a human design point of view a smaller object might be easier to understand and use?

If not would it be possible to add an object into the audio design tool like the AudioOutputI2s object, that can read the current value of whatever is plugged into it and then make that value accessible via an object.readvalue() command, a sort of snapshot of the current value that can be read once per loop sort of thing.

This is exactly what the analyze rms & peak objects do.

I've considered adding more of those, for "volume" (perhaps with configurable attack & decay timing), loudness and other more involved algorithms.
 
individual gain blocks would certainly be very useful, at the moment I'm often using a multiplier with a DC control attached, and using the DC to control signal levels through the multiplier. It works but its a messy way to work.

One of the reasons I favoured the reverse mixer approach was so that it could be used as a multiway switch, i.e. by switching individual channels on or off you can reroute signals to different parts of the synth - like a software modular synth.

This is one of my tidier layouts, where I've removed some of the DC/multiplier combo's to make things a bit easier to follow, but it still requires more modulation lines to be wired into the design (especially now I am using the modulatable waveforms). This is basically the audio signal paths with the modulation routing removed:

Screen Shot 2018-04-04 at 18.18.51.jpg

BTW, I did look at the RMS and peak objects but assumed they would be averaging over time, so wasn't sure about them. I need to get fairly accurate and responsive spot levels every 2ms, so I can update the wave shapers in real time, will the RMS/ peak meters work for this? it may well make things a lot more efficient for me if they can.
 
individual gain blocks would certainly be very useful, at the moment I'm often using a multiplier with a DC control attached, and using the DC to control signal levels through the multiplier. It works but its a messy way to work.

I'll add a simple amp object.

One of the reasons I favoured the reverse mixer approach was so that it could be used as a multiway switch, i.e. by switching individual channels on or off you can reroute signals to different parts of the synth - like a software modular synth.

Could a group of amp objects work for this? Just set the gain to 0 to turn the signal off, or 1.0 to turn it on.

BTW, I did look at the RMS and peak objects but assumed they would be averaging over time, so wasn't sure about them. I need to get fairly accurate and responsive spot levels every 2ms, so I can update the wave shapers in real time, will the RMS/ peak meters work for this?

The audio library updates every 2.9ms (128 samples at ~44.1 kHz). Your Arduino sketch can't get info or make changes any faster than once per update, so you simply can not have 2ms. Well, not unless you edit the core library to reduce the audio block length.

If you use the RMS object, it will return true from available() every 2.9 ms. If you read it promptly, you'll get the RMS level from the prior 2.9 ms.
 

Cool, that is going to be a very useful object :) And yes, a group of these will work fine for switching between objects, switching between a gain of 1 or 0 was exactly what I had in mind.

And that is very useful to know about the refresh time of the Audio library, something I was actually unaware of!
I've been using elapsedMillis at 2ms (if x > 2ms) but now I know this, I will increase the time to 3-4ms to allow more time for the library routine to complete :)

No wait... if I use .available(), I can use that for the timing, eg sync the master loop to .available() then everything will be in sync with the audio library yes?
I used to do smilar when I was programming games on the Amiga - syncing the main loop to the screen refresh :)

Thanks you've been a great help, hopefully i'll be able to post some videos of my synth soon!
 
I see the amp object in the online version of the audio design tool but it doesn't look like it was included in Teensyduino 1.42 beta 3. It doesn't appear in the bundled audio design tool and, if I copy code into Arduino from the web-based version, "AudioAmplifier" isn't highlighted as a keyword.
 
Status
Not open for further replies.
Back
Top