Scaling USB audio for analog output

Status
Not open for further replies.

moogerfooger

New member
Hi,

I am using Teensy 3.2 and the Teensy Audio library to directly connect AudioInputUSB to AudioOutputDAC. The goal is to create a DC-coupled interface from my computer running a software synth to an external hardware synth setup.

In its simplest form:

Code:
AudioInputUSB            usb1;           //xy=410,309
AudioOutputAnalog        dac1;           //xy=698,284
AudioConnection          patchCord1(usb1, 0, dac1, 0);

Looking at the voltages on a scope, the DAC outputs values from ~0.6-~1.2V for the signal I am putting in, which is the output of a LFO with (virtual) voltages equivalent to 0-10V.
If I change the values to -10V to 0V on my LFO, I get voltages of ~0-~0.6V on the DAC output, which makes sense.

Now, I would like to scale the (virtual) 0-10V to 0-1.2V on the DAC (and then use external OpAmp circuit to scale up to 0-10V to external connections).

What would be the best way yo do this?

Thanks!
 
Simple Math: (virtual(0-10V) * 2) -10 gives (still virtual) -10 to + 10V which result in a 0-1.2V DAC output which can then be upscaled by factor 8.3333 to get 0-10V again.
 
Sorry, this question wasn't about math, but about how to do it in code on the Teensy. I only need 0-10V (virtual), but would like the full 0-1.2V range on the Teensy.

Are there configuration options for scaling? Do I have access to the USB incoming audio buffer and can reroute the values through scaling and then into the AnalogOutputDAC?

I couldn't find an example for this use case.
 
The math suggestion comprised the idea (sorry if I haven’t been clear on that) that you write a new audio object which would sit in the middle between the usb input and the DAC output and perform just this math on every sample.

You could start from the mixer object, throwing away all but one input channel and modify the actual variable 0 to 1.0 signal scaling for the remaining channel to do a fixed y=x*2-1
 
Doesn't the multiply object do this?


edit - well the slope part... not sure about DC coupled thing so err, um, nevermind
. ;)
 
Last edited:
I believe you'll need the DC object and 2 mixers (due to a limitation in how the mixer works...)

First, you'd set the DC object to create a stream of -0.5. Then use a mixer to add it to the signal. Leave the gain at 1.0 on both inputs.

This will translate the part of the signal you want from 0 to 1.0 into -0.5 to +0.5.

Then use another mixer to amplify the signal by 2.0. Ideally just 1 mixer should be able to do this, and someday I will improve the mixer code to carry 32 bits for all internal calcs. But today it saturates to 16 bits at each step, so you need a 2nd mixer to amplify the signal to -1.0 to +1.0, which if course you connect to the DAC.

Of course you'll need an opamp circuit to multiply the voltage by 8.333, but it sounds like you already know how to do that part.
 
I believe you'll need the DC object and 2 mixers (due to a limitation in how the mixer works...)

Paul, your solution works great! Thank you very much.

Also, thanks to everybody else for trying to help. I ended up doing some RTFM in this process and learned quite a bit.
 
Status
Not open for further replies.
Back
Top