USB tone?

Status
Not open for further replies.

DaQue

Well-known member
Without an audio board can a Teensy have a sound or beeps come thru the PC audio by acting like some kind of USB audio + mouse + serial and maybe a keyboard too? I would use this as an alarm for when a task completes. Is this some best done using the audio tool that's mostly for the audio board?
 
Yes, in the audio lib design tool you can use several different output objects. For example: (right side docs panel)

https://www.pjrc.com/teensy/gui/?info=AudioOutputAnalog

The audio lib only works on Teensy 3.2, 3.5 and 3.6.

Several different USB options are available. In Arduino, select Teensy from the Tools > Boards menu, and then look at the Tools > USB Type menu to see the choices. Even if you don't yet have a Teensy, you can still install the Arduino & Teensyduino software and see these menus.

Other combinations not in the menu are also possible, but it involves editing usb_desc.h which isn't easy Arduino programming.
 
Thanks Paul. I wasn't sure if all that required an audio board to be present. I have one at work for a project there as soon as a pcb comes back from fab so I guess I better start learning those tools.
 
The only part of the audio lib that requires the audio shield to be present is the SGTL5000 control object.

Of course, the I2S objects aren't very useful if they're transmitting or receiving without an I2S chip connected. But I2S is a simple streaming protocol without any sort of acknowledgements or back-and-forth communication with the other side. It's much like LEDs with digitalWrite and pots with analogRead. If no LED is connected, the pin still drives high or low. If no analog voltage is present, the pin reads some random data. I2S works the same way.
 
I'm novice Teensy user ... I don't have the audio shield, and I'd like that my Teensy 3.2 makes some noise on my computer via USB. For this reason I've loaded the "SimpleDrum" and replaced the output by the "AudioOutputUSB". Because that didn't work, I added messages for debugging on the serial out, and realized that "sgtl5000_1.enable()" is hanging. I didn't really understand the need of this, so I just removed it. Of course, my computer is still quiet ...

Is there a simple solution to get this working? Can I implement some sort of timer or usb-kicker in the "loop()"?
 
Maybe the audio lib should have an example that sends synthesized sound to your PC without needing a SD card. We have HardwareTesting > WavFilePlayerUSB, but it requires a working SD card connected.

Without known-good code on the Teensy side, there's 3 questions... is your PC recognizing Teensy as a USB audio device, are you managing to select Teensy as the audio input (eg, in the sound control panel), and if those are ok, is Teensy actually sending anything to your PC.
 
Wow, that was a cool hint ... I don't have an SD-card connected, but in the sample there is also an "AudioOutputAnalog" Object. Inserting this object instead of the sgtl5000 makes it working! Just the Teensy, a USB-Cable, and my Computer. :) Next step are the Touch Sense Pins ...


#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthKarplusStrong string1; //xy=183.1999969482422,164.1999969482422
AudioOutputAnalog dac; //xy=464.20001220703125,194.99998474121094
AudioOutputUSB usb1; //xy=467.1999969482422,120.19999694824219
AudioConnection patchCord2(string1, 0, usb1, 0);
AudioConnection patchCord3(string1, 0, usb1, 1);
// GUItool: end automatically generated code

void setup() {
// put your setup code here, to run once:
AudioMemory(15);
}

void loop() {
// put your main code here, to run repeatedly:
string1.noteOn(110.0, 1); delay(100);
string1.noteOn(130.8, 1); delay(100);
string1.noteOn(164.8, 1); delay(100);
string1.noteOn(220.0, 1); delay(500);
string1.noteOff(10); delay(1000);
}
 
FIXED: Well not so much here. Copied and pasted the above code into a new sketch and it compiles fine after setting the usb to all of the above, but I get no sound. I tried just Audio and the same. It shows up on my Windows 10 devices as Teensy Audio /Digital Audio Interface when set to just Audio and All Things if set to all of the above. I have just the Teensy plugged into a purple test board and touchscreen and USB cable. Not sure what I am missing. Teensy loader 1.34 Arduino 1.8.0.

FIXED:
I had to check "listen to this device" on the recording/ listen tab for to hear it. Windows 10.
 
Last edited:
Status
Not open for further replies.
Back
Top