How to get USB serial, USB audio and USB Midi on Teensy 3.6?

Mike5000

Well-known member
How do I get USB serial, USB audio and USB Midi on the Teensy 3.6? Is there a "-D directive" for PlatformIO for this?
 
I believe there is. However, I personally do not use PlatormIO, but assume it would work with the same settings.
While I know there are many who do not wish to do their development using the Arduino IDE, I would personally suggest that maybe most should install it. That way they can try things out and see if they work and probably easier to see what options are out there...

Screenshot.png

For example the one shown in the photo looks promising for what you are looking for:
If you look at the file boards.txt in this case IDE 2 (<where arduino15 is installed>/hardware/avr/0.59.2/boards.txt)
You will see the section:
Code:
teensy36.menu.usb.serialmidiaudio=Serial + MIDI + Audio
teensy36.menu.usb.serialmidiaudio.build.usbtype=USB_MIDI_AUDIO_SERIAL
teensy36.menu.usb.serialmidiaudio.upload_port.usbtype=USB_MIDI_AUDIO_SERIAL
teensy36.menu.usb.serialmidi16audio=Serial + MIDIx16 + Audio
teensy36.menu.usb.serialmidi16audio.build.usbtype=USB_MIDI16_AUDIO_SERIAL
teensy36.menu.usb.serialmidi16audio.upload_port.usbtype=USB_MIDI16_AUDIO_SERIAL
So my gues is to try: the -DUSB_MIDI_AUDIO_SERIAL
 
I tried that in PlatformIO, no audio out but serial works. If I select -D USB_AUDIO audio works. However i need the serial port for debugging.

Tried the same code in Arduino IDE. No audio out but serial works. If I select -D USB_AUDIO audio works. However i need the serial port for debugging.

I have gotten both serial and audio to work before on teensy 3.6 but its some versions of the libraries ago.. I use the floating point audio lib btw.
 
Is your Teensy core library up to date? With Arduino IDE this is easy to check. Have no idea what to do with PlatformIO.

I do know the Serial + MIDI + Audio type had a bug on Teensy 4.0 which was fixed with version 1.52. Probably unrelated since you're using Teensy 3.6... and 1.52 is so old.

Still, worthwhile to check that you're really using the latest core library, just in case.
 
Is your Teensy core library up to date? With Arduino IDE this is easy to check. Have no idea what to do with PlatformIO.

I do know the Serial + MIDI + Audio type had a bug on Teensy 4.0 which was fixed with version 1.52. Probably unrelated since you're using Teensy 3.6... and 1.52 is so old.

Still, worthwhile to check that you're really using the latest core library, just in case.

Hi Paul. I now also compiled with the Arduino IDE. Same problem with the Arduino IDE so it is not PlatformIO related: just when ONLY "Audio" is selected there is audio thru to the USB Audio port. When "Serial+Midi+Audio" is selected there is no audio thru. I also tried "Everything" to no avail.

I have tried both the latest 1.58.1 Teensy core lib and 1.58.0 as well as 1.57.2. There is the same problem when I use all those Teensy core libraries. I need serial and audio, but when I select this there is no audio.

The code I tested is very simple and it works when I only select "Audio" (there is a mic attached / soldered to the audio board):

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

// GUItool: begin automatically generated code
AudioInputI2S            i2s1;           //xy=165,171
AudioOutputUSB           usb1;           //xy=502,170
AudioConnection          patchCord1(i2s1, 0, usb1, 0);
AudioConnection          patchCord2(i2s1, 1, usb1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=314,496
// GUItool: end automatically generated code


void setup(void) 
{
    Serial.begin(38400);
    Serial.print("running");

    AudioMemory(5);
 
    sgtl5000_1.enable();
    sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
    sgtl5000_1.volume(0.5);

    
}

void loop(void) 
{
    

}
teensy_issue.jpg
 
Is your Teensy core library up to date? With Arduino IDE this is easy to check. Have no idea what to do with PlatformIO.

I do know the Serial + MIDI + Audio type had a bug on Teensy 4.0 which was fixed with version 1.52. Probably unrelated since you're using Teensy 3.6... and 1.52 is so old.

Still, worthwhile to check that you're really using the latest core library, just in case.

Additional info Paul: I am in fact able to get serial data to the Serial monitor in the Arduino IDE when I select ONLY "Audio". With this setting Audio makes it thru to the USB port.
.... This seems counter intuitive. I thought serial was turned off when you select only Audio.
 
Might be worth boosting your AudioMemory(5) up a bit? The USB audio object uses a couple of blocks per channels as buffers, so you're perilously close to starving the system of blocks for use elsewhere in the flow. Though I don't see why it would affect only the Serial+MIDI+Audio build.
 
Might be worth boosting your AudioMemory(5) up a bit? The USB audio object uses a couple of blocks per channels as buffers, so you're perilously close to starving the system of blocks for use elsewhere in the flow. Though I don't see why it would affect only the Serial+MIDI+Audio build.

Yes, I've tried it and you haven't allocated enough AudioMemory. It rather looks from other posts you've made that you might have tried it yourself and got it working ... if so, it's a good plan to report the fact, otherwise future readers of this forum will think there might be an outstanding issue when there isn't.
 
I got this working but only intermittently. There seems to be something related to how Windows 10 recognizes the USB device. Only when deleting the USB registrations with the tool USBDeview from nirsoft (free tool) and plugging in and out the Teensy USB connection several times I got it somehow working. However this is not a stable solution.
 
Back
Top