How To : PD - using an external USB audio interface

Ive had a few people PM’ing me about this, how to do it…and since its easier since OS 3.0 I thought Id post a quick ‘how to’… and some pitfalls, and things to consider

the essence of the answer to this question - is to provide Pure Data with command line options to make it use the audio interface.

so there are a few steps to this:
a) what are the command line option?
b) how do I know what to use?
c) where to put these options so they get picked up?

ok, im going to answer these in reverse order :slight_smile:

c) adding PD command options to be picked up when starting a patch

so 3.0 introduced a new feature to allow any PD command line option to be set
you do this by putting the options in a file called pd-opts.txt
this may reside in either /usbdrive/System (you may need to create the directory) or in the 'patch directory

if you place in the System directory, it will be used by ALL patches
if you place in the patch directory, it will be used just for that patch.

b) how do I know what my soundcard is called ?

well, you could guess… its probably going to be device 7 , as you will see below, but the proper way is to ask PD.
so if you cannot do below, just use 7 … and see if it works, if it doesn’t then come back to this step :wink:
(but still read this step, and you’ll see why i use 7 (and later 1)

you will need to run a command on the Organelle, you can either do this by
i) connecting a TV and monitor
ii) logging in remotely over wifi using ssh (Im not covering this here ;))

you then need to run the command

pd -nogui -listdev

this will output something like

[audio input devices:
1. On-board Codec (hardware)
2. On-board Codec (plug-in)
3. imx-spdif (hardware)
4. imx-spdif (plug-in)
5. imx-hdmi-soc (hardware)
6. imx-hdmi-soc (plug-in)
7. USB AUDIO  CODEC (hardware)
8. USB AUDIO  CODEC (plug-in)
audio output devices:
1. On-board Codec (hardware)
2. On-board Codec (plug-in)
3. imx-spdif (hardware)
4. imx-spdif (plug-in)
5. imx-hdmi-soc (hardware)
6. imx-hdmi-soc (plug-in)
7. USB AUDIO  CODEC (hardware)
8. USB AUDIO  CODEC (plug-in)
API number 1

... blah blah :) 

ok, without anything plugged in , you will get devices 1-6 , but Ive plugged in a usb audio interface
… if you dont see this when your audio interface is plugged in, then your out of luck for now (sorry)

important bit of information , usually we are using the Ob-board Codec (device 1)
In this scenario , I want to use the device 7

(Plugin or hardware both work for me, so I use hardware… if you have issues you may want to try the plugin, so 8)

ok, so I now know my device number (7)

a) telling PD to use the external soundcard

finally , we know where to put the option , now we need to just know what to add

the easy solution is just to tell PD to use this device instead, for both input and output.

so in pd-opts.txt, I simply add the line

-audiodev 7

start a patch, and magically it works :slight_smile:

but we should still proceed a bit further , as this is a bit ‘simplified’… what if we want more than 2 channels?, what if we want to only use it for output ?, what if its crackling?

ok, here we have to go at look at what options are available in PD

https://puredata.info/docs/faq/commandline

some useful options are:
-audioindev ,-audiooutdev , so we can specify a different device for input and output ,
e.g.

-audioindev 1
-audiooutdev 7

now we still use the organelles input jack, but by usb audio interface for output

-channels, -inchannels, -outchannels, to specify number of inputs /outputs on your audio interface.
(of course, by default all audio from Organelle patches are going only to channel 1,2 so if you need more , you’l; have to alter)

-audiobuf , Organlle has this low (4) , when running without the GUI, but usb is going to be slower than the onboard codec, so if you get crackling, you may need to up this significantly.

-r samplerate , your audio interface may need to use a different sampling rate from the default… (44100)… note: higher sampling rates = more cpu, so you may need to increase audiobuf and possible blocksize. basically id advise against changing sampling rate if possible.

another option, which did not work for me ( I got audio distortion) is to have 2 audio devices
so say you want to hear the output on the headphone jack (so onboard codec) AND the usb audio interface
then you need, something like:

 -audiodev 1,7
 -channels 2,2

this says use devices 1 and 7, and that audio device 1 has 2 channels and so does device 7
(you need channels, otherwise (stupidly!) it assumes zero )
… note: this did not work for me, I got audio distortion - sounded like there was no audio sync on the second device, but might work for you.

ok, thats about it… you can get more information from the above link, and im sure theres lots of information on the internet… but hopefully this will get you started

Cheers
Mark

p.s. no the hdmi device doesn’t work currently… I tried, though i will re-test in the ‘linux upgrade project’ perhaps it will then.

btw: silly tip, perhaps obvious…
if you do redirect the audio to USB, keep a note somewhere close by your organelle… its easy to forget you’ve done it… and then spend quite a frustrating time, wondering why your Organelle no longer produces sound from outputs or headphone (or input) … and if you come to the forum for help nobody will think to ask/remind you that you’ve redirected it :wink:

7 Likes

Thanks so much for this :+1:t2:.

I’m up and running using my SD Mix Pre-D. The only thing I needed to adjust was the audio buffer as mentioned above. This is how my day’s shaping up.

4 Likes

How was the sampling rate / latency? Apart from the quality of the preamps of the SD, does it bring more features to the Organelle?

1 Like

Just FYI. I use an Organelle M and It seems that the external interface is on #3.
So :

-audiodev 3

1 Like

@domicidre @thetechnobear Thanks for the info.

Edit: Nevermind my question was answered above!