Commit | Line | Data |
---|---|---|
5732e7a2 | 1 | Guide to using M-Audio Audiophile USB with ALSA and Jack v1.3 |
e311334e TLM |
2 | ======================================================== |
3 | ||
4 | Thibault Le Meur <Thibault.LeMeur@supelec.fr> | |
5 | ||
6 | This document is a guide to using the M-Audio Audiophile USB (tm) device with | |
7 | ALSA and JACK. | |
8 | ||
9 | 1 - Audiophile USB Specs and correct usage | |
10 | ========================================== | |
11 | This part is a reminder of important facts about the functions and limitations | |
12 | of the device. | |
13 | ||
14 | The device has 4 audio interfaces, and 2 MIDI ports: | |
15 | * Analog Stereo Input (Ai) | |
19739fef TLM |
16 | - This port supports 2 pairs of line-level audio inputs (1/4" TS and RCA) |
17 | - When the 1/4" TS (jack) connectors are connected, the RCA connectors | |
18 | are disabled | |
e311334e TLM |
19 | * Analog Stereo Output (Ao) |
20 | * Digital Stereo Input (Di) | |
21 | * Digital Stereo Output (Do) | |
22 | * Midi In (Mi) | |
23 | * Midi Out (Mo) | |
24 | ||
5732e7a2 | 25 | The internal DAC/ADC has the following characteristics: |
e311334e TLM |
26 | * sample depth of 16 or 24 bits |
27 | * sample rate from 8kHz to 96kHz | |
5732e7a2 | 28 | * Two ports can't use different sample depths at the same time. Moreover, the |
e311334e TLM |
29 | Audiophile USB documentation gives the following Warning: "Please exit any |
30 | audio application running before switching between bit depths" | |
31 | ||
32 | Due to the USB 1.1 bandwidth limitation, a limited number of interfaces can be | |
33 | activated at the same time depending on the audio mode selected: | |
5732e7a2 | 34 | * 16-bit/48kHz ==> 4 channels in/4 channels out |
e311334e TLM |
35 | - Ai+Ao+Di+Do |
36 | * 24-bit/48kHz ==> 4 channels in/2 channels out, | |
37 | or 2 channels in/4 channels out | |
38 | - Ai+Ao+Do or Ai+Di+Ao or Ai+Di+Do or Di+Ao+Do | |
39 | * 24-bit/96kHz ==> 2 channels in, or 2 channels out (half duplex only) | |
40 | - Ai or Ao or Di or Do | |
41 | ||
42 | Important facts about the Digital interface: | |
43 | -------------------------------------------- | |
5732e7a2 CK |
44 | * The Do port additionally supports surround-encoded AC-3 and DTS passthrough, |
45 | though I haven't tested it under Linux | |
e311334e TLM |
46 | - Note that in this setup only the Do interface can be enabled |
47 | * Apart from recording an audio digital stream, enabling the Di port is a way | |
19739fef | 48 | to synchronize the device to an external sample clock |
e311334e TLM |
49 | - As a consequence, the Di port must be enable only if an active Digital |
50 | source is connected | |
51 | - Enabling Di when no digital source is connected can result in a | |
52 | synchronization error (for instance sound played at an odd sample rate) | |
53 | ||
54 | ||
55 | 2 - Audiophile USB support in ALSA | |
56 | ================================== | |
57 | ||
58 | 2.1 - MIDI ports | |
59 | ---------------- | |
60 | The Audiophile USB MIDI ports will be automatically supported once the | |
61 | following modules have been loaded: | |
62 | * snd-usb-audio | |
e311334e TLM |
63 | * snd-seq-midi |
64 | ||
5732e7a2 | 65 | No additional setting is required. |
e311334e TLM |
66 | |
67 | 2.2 - Audio ports | |
68 | ----------------- | |
69 | ||
70 | Audio functions of the Audiophile USB device are handled by the snd-usb-audio | |
71 | module. This module can work in a default mode (without any device-specific | |
5732e7a2 | 72 | parameter), or in an "advanced" mode with the device-specific parameter called |
e311334e TLM |
73 | "device_setup". |
74 | ||
75 | 2.2.1 - Default Alsa driver mode | |
76 | ||
5732e7a2 | 77 | The default behavior of the snd-usb-audio driver is to parse the device |
e311334e | 78 | capabilities at startup and enable all functions inside the device (including |
5732e7a2 | 79 | all ports at any supported sample rates and sample depths). This approach |
e311334e TLM |
80 | has the advantage to let the driver easily switch from sample rates/depths |
81 | automatically according to the need of the application claiming the device. | |
82 | ||
83 | In this case the Audiophile ports are mapped to alsa pcm devices in the | |
84 | following way (I suppose the device's index is 1): | |
85 | * hw:1,0 is Ao in playback and Di in capture | |
86 | * hw:1,1 is Do in playback and Ai in capture | |
87 | * hw:1,2 is Do in AC3/DTS passthrough mode | |
88 | ||
89 | You must note as well that the device uses Big Endian byte encoding so that | |
90 | supported audio format are S16_BE for 16-bit depth modes and S24_3BE for | |
91 | 24-bits depth mode. One exception is the hw:1,2 port which is Little Endian | |
92 | compliant and thus uses S16_LE. | |
93 | ||
94 | Examples: | |
95 | * playing a S24_3BE encoded raw file to the Ao port | |
96 | % aplay -D hw:1,0 -c2 -t raw -r48000 -fS24_3BE test.raw | |
97 | * recording a S24_3BE encoded raw file from the Ai port | |
98 | % arecord -D hw:1,1 -c2 -t raw -r48000 -fS24_3BE test.raw | |
99 | * playing a S16_BE encoded raw file to the Do port | |
100 | % aplay -D hw:1,1 -c2 -t raw -r48000 -fS16_BE test.raw | |
101 | ||
102 | If you're happy with the default Alsa driver setup and don't experience any | |
103 | issue with this mode, then you can skip the following chapter. | |
104 | ||
105 | 2.2.2 - Advanced module setup | |
106 | ||
107 | Due to the hardware constraints described above, the device initialization made | |
108 | by the Alsa driver in default mode may result in a corrupted state of the | |
109 | device. For instance, a particularly annoying issue is that the sound captured | |
110 | from the Ai port sounds distorted (as if boosted with an excessive high volume | |
111 | gain). | |
112 | ||
113 | For people having this problem, the snd-usb-audio module has a new module | |
114 | parameter called "device_setup". | |
115 | ||
5732e7a2 | 116 | 2.2.2.1 - Initializing the working mode of the Audiophile USB |
e311334e | 117 | |
5732e7a2 | 118 | As far as the Audiophile USB device is concerned, this value let the user |
e311334e TLM |
119 | specify: |
120 | * the sample depth | |
121 | * the sample rate | |
122 | * whether the Di port is used or not | |
123 | ||
124 | Here is a list of supported device_setup values for this device: | |
125 | * device_setup=0x00 (or omitted) | |
126 | - Alsa driver default mode | |
127 | - maintains backward compatibility with setups that do not use this | |
128 | parameter by not introducing any change | |
fff9289b | 129 | - results sometimes in corrupted sound as described earlier |
e311334e TLM |
130 | * device_setup=0x01 |
131 | - 16bits 48kHz mode with Di disabled | |
132 | - Ai,Ao,Do can be used at the same time | |
133 | - hw:1,0 is not available in capture mode | |
134 | - hw:1,2 is not available | |
135 | * device_setup=0x11 | |
136 | - 16bits 48kHz mode with Di enabled | |
137 | - Ai,Ao,Di,Do can be used at the same time | |
138 | - hw:1,0 is available in capture mode | |
139 | - hw:1,2 is not available | |
140 | * device_setup=0x09 | |
141 | - 24bits 48kHz mode with Di disabled | |
142 | - Ai,Ao,Do can be used at the same time | |
143 | - hw:1,0 is not available in capture mode | |
144 | - hw:1,2 is not available | |
145 | * device_setup=0x19 | |
146 | - 24bits 48kHz mode with Di enabled | |
147 | - 3 ports from {Ai,Ao,Di,Do} can be used at the same time | |
148 | - hw:1,0 is available in capture mode and an active digital source must be | |
149 | connected to Di | |
150 | - hw:1,2 is not available | |
151 | * device_setup=0x0D or 0x10 | |
152 | - 24bits 96kHz mode | |
153 | - Di is enabled by default for this mode but does not need to be connected | |
154 | to an active source | |
155 | - Only 1 port from {Ai,Ao,Di,Do} can be used at the same time | |
156 | - hw:1,0 is available in captured mode | |
157 | - hw:1,2 is not available | |
158 | * device_setup=0x03 | |
159 | - 16bits 48kHz mode with only the Do port enabled | |
160 | - AC3 with DTS passthru (not tested) | |
161 | - Caution with this setup the Do port is mapped to the pcm device hw:1,0 | |
162 | ||
163 | 2.2.2.2 - Setting and switching configurations with the device_setup parameter | |
164 | ||
165 | The parameter can be given: | |
166 | * By manually probing the device (as root): | |
167 | # modprobe -r snd-usb-audio | |
168 | # modprobe snd-usb-audio index=1 device_setup=0x09 | |
169 | * Or while configuring the modules options in your modules configuration file | |
170 | - For Fedora distributions, edit the /etc/modprobe.conf file: | |
171 | alias snd-card-1 snd-usb-audio | |
172 | options snd-usb-audio index=1 device_setup=0x09 | |
173 | ||
174 | IMPORTANT NOTE WHEN SWITCHING CONFIGURATION: | |
175 | ------------------------------------------- | |
5732e7a2 | 176 | * You may need to _first_ initialize the module with the correct device_setup |
e311334e TLM |
177 | parameter and _only_after_ turn on the Audiophile USB device |
178 | * This is especially true when switching the sample depth: | |
5732e7a2 CK |
179 | - first turn off the device |
180 | - de-register the snd-usb-audio module (modprobe -r) | |
181 | - change the device_setup parameter by changing the device_setup | |
182 | option in /etc/modprobe.conf | |
e311334e TLM |
183 | - turn on the device |
184 | ||
19739fef | 185 | 2.2.2.3 - Audiophile USB's device_setup structure |
e311334e TLM |
186 | |
187 | If you want to understand the device_setup magic numbers for the Audiophile | |
188 | USB, you need some very basic understanding of binary computation. However, | |
5732e7a2 | 189 | this is not required to use the parameter and you may skip this section. |
e311334e TLM |
190 | |
191 | The device_setup is one byte long and its structure is the following: | |
192 | ||
193 | +---+---+---+---+---+---+---+---+ | |
194 | | b7| b6| b5| b4| b3| b2| b1| b0| | |
195 | +---+---+---+---+---+---+---+---+ | |
196 | | 0 | 0 | 0 | Di|24B|96K|DTS|SET| | |
197 | +---+---+---+---+---+---+---+---+ | |
198 | ||
199 | Where: | |
200 | * b0 is the "SET" bit | |
201 | - it MUST be set if device_setup is initialized | |
202 | * b1 is the "DTS" bit | |
203 | - it is set only for Digital output with DTS/AC3 | |
204 | - this setup is not tested | |
205 | * b2 is the Rate selection flag | |
206 | - When set to "1" the rate range is 48.1-96kHz | |
207 | - Otherwise the sample rate range is 8-48kHz | |
208 | * b3 is the bit depth selection flag | |
209 | - When set to "1" samples are 24bits long | |
210 | - Otherwise they are 16bits long | |
211 | - Note that b2 implies b3 as the 96kHz mode is only supported for 24 bits | |
212 | samples | |
213 | * b4 is the Digital input flag | |
214 | - When set to "1" the device assumes that an active digital source is | |
215 | connected | |
216 | - You shouldn't enable Di if no source is seen on the port (this leads to | |
217 | synchronization issues) | |
218 | - b4 is implied by b2 (since only one port is enabled at a time no synch | |
219 | error can occur) | |
220 | * b5 to b7 are reserved for future uses, and must be set to "0" | |
221 | - might become Ao, Do, Ai, for b7, b6, b4 respectively | |
222 | ||
223 | Caution: | |
224 | * there is no check on the value you will give to device_setup | |
225 | - for instance choosing 0x05 (16bits 96kHz) will fail back to 0x09 since | |
226 | b2 implies b3. But _there_will_be_no_warning_ in /var/log/messages | |
227 | * Hardware constraints due to the USB bus limitation aren't checked | |
228 | - choosing b2 will prepare all interfaces for 24bits/96kHz but you'll | |
229 | only be able to use one at the same time | |
230 | ||
19739fef | 231 | 2.2.3 - USB implementation details for this device |
e311334e | 232 | |
5732e7a2 | 233 | You may safely skip this section if you're not interested in driver |
e311334e TLM |
234 | development. |
235 | ||
5732e7a2 CK |
236 | This section describes some internal aspects of the device and summarize the |
237 | data I got by usb-snooping the windows and Linux drivers. | |
e311334e | 238 | |
19739fef | 239 | The M-Audio Audiophile USB has 7 USB Interfaces: |
e311334e | 240 | a "USB interface": |
19739fef TLM |
241 | * USB Interface nb.0 |
242 | * USB Interface nb.1 | |
e311334e | 243 | - Audio Control function |
19739fef | 244 | * USB Interface nb.2 |
e311334e | 245 | - Analog Output |
19739fef | 246 | * USB Interface nb.3 |
e311334e | 247 | - Digital Output |
19739fef | 248 | * USB Interface nb.4 |
e311334e | 249 | - Analog Input |
19739fef | 250 | * USB Interface nb.5 |
e311334e | 251 | - Digital Input |
19739fef | 252 | * USB Interface nb.6 |
e311334e TLM |
253 | - MIDI interface compliant with the MIDIMAN quirk |
254 | ||
255 | Each interface has 5 altsettings (AltSet 1,2,3,4,5) except: | |
256 | * Interface 3 (Digital Out) has an extra Alset nb.6 | |
257 | * Interface 5 (Digital In) does not have Alset nb.3 and 5 | |
258 | ||
259 | Here is a short description of the AltSettings capabilities: | |
260 | * AltSettings 1 corresponds to | |
261 | - 24-bit depth, 48.1-96kHz sample mode | |
262 | - Adaptive playback (Ao and Do), Synch capture (Ai), or Asynch capture (Di) | |
263 | * AltSettings 2 corresponds to | |
264 | - 24-bit depth, 8-48kHz sample mode | |
265 | - Asynch capture and playback (Ao,Ai,Do,Di) | |
266 | * AltSettings 3 corresponds to | |
267 | - 24-bit depth, 8-48kHz sample mode | |
268 | - Synch capture (Ai) and Adaptive playback (Ao,Do) | |
269 | * AltSettings 4 corresponds to | |
270 | - 16-bit depth, 8-48kHz sample mode | |
271 | - Asynch capture and playback (Ao,Ai,Do,Di) | |
272 | * AltSettings 5 corresponds to | |
273 | - 16-bit depth, 8-48kHz sample mode | |
274 | - Synch capture (Ai) and Adaptive playback (Ao,Do) | |
275 | * AltSettings 6 corresponds to | |
276 | - 16-bit depth, 8-48kHz sample mode | |
277 | - Synch playback (Do), audio format type III IEC1937_AC-3 | |
278 | ||
5732e7a2 | 279 | In order to ensure a correct initialization of the device, the driver |
e311334e | 280 | _must_know_ how the device will be used: |
5732e7a2 | 281 | * if DTS is chosen, only Interface 2 with AltSet nb.6 must be |
e311334e TLM |
282 | registered |
283 | * if 96KHz only AltSets nb.1 of each interface must be selected | |
284 | * if samples are using 24bits/48KHz then AltSet 2 must me used if | |
285 | Digital input is connected, and only AltSet nb.3 if Digital input | |
286 | is not connected | |
287 | * if samples are using 16bits/48KHz then AltSet 4 must me used if | |
288 | Digital input is connected, and only AltSet nb.5 if Digital input | |
289 | is not connected | |
290 | ||
291 | When device_setup is given as a parameter to the snd-usb-audio module, the | |
5732e7a2 | 292 | parse_audio_endpoints function uses a quirk called |
e311334e TLM |
293 | "audiophile_skip_setting_quirk" in order to prevent AltSettings not |
294 | corresponding to device_setup from being registered in the driver. | |
295 | ||
296 | 3 - Audiophile USB and Jack support | |
297 | =================================== | |
298 | ||
299 | This section deals with support of the Audiophile USB device in Jack. | |
300 | The main issue regarding this support is that the device is Big Endian | |
301 | compliant. | |
302 | ||
303 | 3.1 - Using the plug alsa plugin | |
304 | -------------------------------- | |
305 | ||
306 | Jack doesn't directly support big endian devices. Thus, one way to have support | |
307 | for this device with Alsa is to use the Alsa "plug" converter. | |
308 | ||
309 | For instance here is one way to run Jack with 2 playback channels on Ao and 2 | |
310 | capture channels from Ai: | |
311 | % jackd -R -dalsa -dplughw:1 -r48000 -p256 -n2 -D -Cplughw:1,1 | |
312 | ||
313 | ||
314 | However you may see the following warning message: | |
315 | "You appear to be using the ALSA software "plug" layer, probably a result of | |
316 | using the "default" ALSA device. This is less efficient than it could be. | |
317 | Consider using a hardware device instead rather than using the plug layer." | |
318 | ||
e311334e | 319 | 3.2 - Patching alsa to use direct pcm device |
5732e7a2 | 320 | -------------------------------------------- |
e311334e TLM |
321 | A patch for Jack by Andreas Steinmetz adds support for Big Endian devices. |
322 | However it has not been included in the CVS tree. | |
323 | ||
324 | You can find it at the following URL: | |
325 | http://sourceforge.net/tracker/index.php?func=detail&aid=1289682&group_id=39687& | |
326 | atid=425939 | |
327 | ||
328 | After having applied the patch you can run jackd with the following command | |
329 | line: | |
19739fef | 330 | % jackd -R -dalsa -Phw:1,0 -r48000 -p128 -n2 -D -Chw:1,1 |
e311334e | 331 | |
5732e7a2 CK |
332 | 3.2 - Getting 2 input and/or output interfaces in Jack |
333 | ------------------------------------------------------ | |
334 | ||
335 | As you can see, starting the Jack server this way will only enable 1 stereo | |
336 | input (Di or Ai) and 1 stereo output (Ao or Do). | |
337 | ||
338 | This is due to the following restrictions: | |
339 | * Jack can only open one capture device and one playback device at a time | |
340 | * The Audiophile USB is seen as 2 (or three) Alsa devices: hw:1,0, hw:1,1 | |
341 | (and optionally hw:1,2) | |
342 | If you want to get Ai+Di and/or Ao+Do support with Jack, you would need to | |
343 | combine the Alsa devices into one logical "complex" device. | |
344 | ||
345 | If you want to give it a try, I recommend reading the information from | |
346 | this page: http://www.sound-man.co.uk/linuxaudio/ice1712multi.html | |
347 | It is related to another device (ice1712) but can be adapted to suit | |
348 | the Audiophile USB. | |
349 | ||
350 | Enabling multiple Audiophile USB interfaces for Jackd will certainly require: | |
351 | * patching Jack with the previously mentioned "Big Endian" patch | |
352 | * patching Jackd with the MMAP_COMPLEX patch (see the ice1712 page) | |
353 | * patching the alsa-lib/src/pcm/pcm_multi.c file (see the ice1712 page) | |
354 | * define a multi device (combination of hw:1,0 and hw:1,1) in your .asoundrc | |
355 | file | |
356 | * start jackd with this device | |
357 | ||
358 | I had no success in testing this for now, but this may be due to my OS | |
359 | configuration. If you have any success with this kind of setup, please | |
360 | drop me an email. |