Mono USB Audio

Status
Not open for further replies.
I'm using the Audio adapter as sound card for a project running pure data on a raspberry pi. I seem to be having an issue when using it as both a input and output at the same time, I get an audible pop every 10s or so. I have a feeling this issue is on the pi/pure data end as the audio adapter works fine running the same pure data patch on my mac. I have reason to believe the issue is happening because the usb input has two channels. I tested the same patch on a pi using a generic usb audio device that only has a single input channel and got no pops. Is it possible to configure the audio adapter to be recognized by a host computer as a single channel input and output rather than stereo?
 
Is it possible to configure the audio adapter to be recognized by a host computer as a single channel input and output rather than stereo?

Yes, if your idea of "possible" involves editing the USB descriptors and code to tell the host to use only 1 channel, and then to process the data for only 1 channel.

But I would guess the problem may be due to the host not properly adapting to the 41117 Hz sample rate feedback. If dig into the code, look for the places where buffer overflow and underflow are handled. You'll see some commented out code. Enable that, or maybe blink a LED connected to a Teensy pin. If the pop occurs when the buffer overflows (or underflows), then that's almost certainly the problem.

It's also possible the problem could be entirely on the host side. Maybe the driver is getting 44110 Hz data and not dealing well with adapting it to the 44117 Hz sample rate feedback. A simple test might involve playing music or video, which (probably) communicates with the Linux device driver in a different way. I can tell you playing ordinary MP3 files with RhythmBox on Ubuntu (X86 64 bit) to a Teensy works fine, without any pops or artifacts. If non-Pd software can play music without the pop every 10 seconds, they you'll have a pretty good idea the issue is on the host side.
 
Thanks for the response Paul, the host not adapting seems like it could be the issue. Ive tested a couple other audio devices with this patch running on the pi and the pops are not occurring at all. Is there a particular place I should be looking for the buffer overflow/underflow commented out code? I'm not sure I follow you there.
 
Ok, think I've found the commented out code you were referring to in usb_audio.cpp. Excuse my ignorance here but I'm not sure how to blink an led from inside this file. Seems that digitalWrite will not work here.
 
Well, I worked on this all weekend (I've actually been trying to figure this issue out for a couple weeks) and I'm still unsure what is causing these glitches. Any help would be much appreciated! I have an audio adc/dac coming in the mail soon for the pi but I'd really like to use the teensy audio adapter If I can solve this issue. I tested 3 different usb audio devices and I'm not getting any pops, it's only happening with the teensy audio board.

Printing out from usb_audio.cpp gives me a pretty steady steam of buffer overruns indicated by * but not specifically when I hear the pops, its just constantly printing them. Here is some more info on this project.

Teensy 3.2 with audio adapter->usb->raspberry pi zero w (although the same happens on the pi 3)
usb type: serial+midi+audio
Teensyduino: 1.37

uname -a
Linux loopscaper 4.9.35+ #1014 Fri Jun 30 14:34:49 BST 2017 armv6l GNU/Linux
Pure data version 0.46.2
Im launching pd with: pd -nogui -audiodev 3 osc.pd &
I've tried many different startup flags for pd with no luck. The only time I don't get pops is when I use -noadc, which kills the audio input.

Audio connections:
m3-1y1hiCV1gsT5XdGpupvYTKaRdpYLYHrEtLs4AZRDeEaZRgP3pRJn9qU7Ns9C8RdRVKn_D=w2880-h1606


PD patch (its just a sine wave):
https://drive.google.com/file/d/0B6on_J3TFqYvZTdFS1p3VEFOSnM/view

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

// GUItool: begin automatically generated code
AudioInputI2S            i2s1;           //xy=322,226
AudioInputUSB            usb2;           //xy=324,266
AudioOutputUSB           usb1;           //xy=440,227
AudioOutputI2S           i2s2;           //xy=443,267
AudioConnection          patchCord1(i2s1, 0, usb1, 0);
AudioConnection          patchCord2(i2s1, 1, usb1, 1);
AudioConnection          patchCord3(usb2, 0, i2s2, 0);
AudioConnection          patchCord4(usb2, 1, i2s2, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=370,309
// GUItool: end automatically generated code


void setup() {                
  AudioMemory(12);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.8);
}

void loop() {

}
 
Any idea if the USB audio overruns problem also happens when you run with a regular x86-based PC rather than Raspberry Pi?
 
Status
Not open for further replies.
Back
Top