grahamwhaley / DSPham

A Teensy based DSP audio processor
GNU General Public License v3.0
24 stars 7 forks source link

Audio IN to USB "in" ? #24

Open rhaamo opened 2 years ago

rhaamo commented 2 years ago

I am trying to get the audio incoming into the DSP to be routed in the "in/mic" of the USB, but I think I am missing something.

I have tried adding:

AudioOutputUSB           usb2;
...
AudioConnection          patchCord15(usb1, 0, usb2, 0);
AudioConnection          patchCord16(usb1, 0, usb2, 1);

Also with Q_in_L or peak_amp instead of usb1 but nothing.

What can I be missing here ?

grahamwhaley commented 2 years ago

Hi @rhaamo . Thanks for your question. To check, you are trying to take the audio being fed into DSPham, and direct it back out over USB to the computer, yes?

The code you posted looks OK to me. It should route the audio coming into the DSPham USB back out over the DSPham USB back to the computer.

I should ask, how are you monitoring the audio on the computer end? This may be a silly question, but I think it is the first logical step. I don't know which operating system you are using, but I think you will need to open a system audio config dialog or an application and choose the Teensy Audio in device or make an 'audio pipe' in order to hear it?

I also presume you have a working DSPham hardware, and it boots and works normally? And you are feeding some audio into the DSPham to process? The DSPham itself make no noise without an input :smile:

Maybe a fist step is to check you can hear sound coming out over the Teensy USB. There is an example for instance here on the teensy forum where a sine wave is fed directly out over USB - that would ensure the hardware and computer are set up OK to start with?

Then, if you want to monitor the audio into the DSPham, you might be better taking the feed from the input_mixer, which will then get you audio from both the USB and line-in inputs:

AudioOutputUSB           usb2;
...
AudioConnection          patchCord15(input_mixer, 0, usb2, 0);
AudioConnection          patchCord16(input_mixer, 0, usb2, 1);

Or, the more obvious to me, is to feed the processed audio back over USB, like:

AudioOutputUSB           usb2;
...
AudioConnection          patchCord15(peak_amp, 0, usb2, 0);
AudioConnection          patchCord16(peak_amp, 0, usb2, 1);

but it sounds like you tried that already.

I hope that helps? If you cannot get it to work, let me know, and I will see if I have time to test the code here. I do think having USB output on DSPham would be useful, as DSPham could then be used as an 'outboard USB DSP processor', without the need for a line in/out or headphones...

rhaamo commented 2 years ago

Hello!

First yes I have a working DSPham, how it is wired is basically as an external loudspeaker with extras: 4 inputs mono selector to DSPham to an amplifier to a speaker/headphones.

The input of the DSPham is the headphones out of a xiegu g90, that part works, I can use the filters properly.

As the teensy usb/audio part, if I choose the Teensy as audio out on the computer, I can hear music through the teensy and speaker.

What I am interested in is doing:

TRX -> DSPham _> speaker
             \_> usb audio to computer

I think I did try peak_amp, I will retry a bit later and let you know.

And for how I monitor the audio on the computer, it was with fldigi (I wanted to decode some digimodes).

Roturbo commented 2 years ago

Hello rhaamo and graham.

I have change my code in order to get audio out from the teensy, it means if i want the audio comes from the radio to the teensy and is cleaned or bypass and goes to PC over USB, i just need to chose the micro input on PC and the audio comes out of the speakers or i can pipe it to a virtual cable and using audio recorder software chose the same virtual cable and start recording.

On my PC, if i chose the audio output as the teensy, than all the audio from my PC will go to USB and will come out on the DSPham speaker, i can also clean it, change filters etc, or bypass.

Sometimes i use this to clean the audio from some websdr that i use all over the world, and i have success getting a recorded files played on PC than goes to teensy to clean it and back to PC to record it again already processed, this is a little more complex and requires virtual cables.

Don´t remember if i have to install some drivers win10, but teensy is detected as an USB audio IN/OUT.

Line 37

AudioInputUSB usb1; // USB audio input from PC
AudioOutputUSB usb2; // -------------USB audio output to PC AudioOutputI2S i2s_out; AudioInputI2S i2s_in; AudioConnection patchCord15 (i2sout, 0, usb2, 0); // **-----------connection to audio output on USB_**`

on line 79

//Wire up the peak detectors

AudioConnection patchCord9(input_mixer, 0, input_peak_detector, 0); AudioConnection patchCord10(firfilter, 0, postfir_peak_detector, 0); AudioConnection patchCord11(peak_amp, 0, output_peak_detector, 0); AudioConnection patchCord12(Q_out_R, 0, toneDetect, 0); //Should we do these after the peak amp? AudioConnection patchCord13(Q_out_R, 0, noteFreq, 0); //Should we do these after the peak amp? AudioConnection patchCord114(peakamp, 0, usb2, 0); // **----------output to USB for audio on PC_**

These are the mods i have done, you can try it and report if it works for you.

Regards.

grahamwhaley commented 2 years ago

Hi @Roturbo , thanks for the response and confirmation. It's good to know it can work. Your code changes look functionally very similar to those of @rhaamo . @rhaamo - I suspect your code was OK, and you have an audio/driver routing issue at your computer end - I'd start to look there most likely.

A note for @Roturbo - in your code I think you have an extra redundant line. This line:

AudioConnection patchCord15 (i2s_out, 0, usb2, 0); // -----------connection to audio output on USB

is trying to route the i2s_out output to the usb2 input - but, the i2s_out object does not have any output connections. I think that line is probably redundant and can be removed...

Also, a note. Your audio is probably only coming out of one channel on the USB, as you have only wired up to the 0 output channel. I don't know if that puts the USB audio device into mono mode, but I would expect not. You might also want to add:

AudioConnection patchCord114(peak_amp, 0, usb2, 1); // ----------output to USB for audio on PC

to connect up the other USB channel. Up to you though :-)

Roturbo commented 2 years ago

Hi @grahamwhaley , it is like you say,, the redundant i think i forget to remove,

O was trying to record the audio and notice that one channel was empty,, it was mono,, so i add the code as you say, but Audacity record with low audio level,, maybe there is a way to increase the audio output from Teensy USB,, if you know it please tell me.

Tanks for your help.

Regards.

grahamwhaley commented 1 year ago

Hi @rhaamo - just wondering if you ever got this to work? If so, shall we close this Issue? :-)