Difference between revisions of "Audio Through USB"

From MOD Wiki
Jump to navigation Jump to search
 
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Using netJACK2 ==
 
  
'''NOTE: This requires v1.4 or later.'''
+
== Using USB Audio Gadget ==
 +
 
 +
'''NOTE: For best results please use v1.14 or later'''
 +
 
 +
'''NOTE: This is EXPERIMENTAL'''
 +
 
 +
First [[Access_MOD_using_SSH|ssh into the unit]], and run:
  
First, connect the MOD Duo to your PC via usb cable. Make sure to open port 19000 on your firewall. If you use Linux with ufw, you can use:
+
<pre>
 +
touch /data/enable-usb-multi-gadget
 +
touch /data/enable-usb-audio-gadget
 +
# if using windows, also run:
 +
touch /data/enable-usb-windows-compat
 +
</pre>
  
<source lang="bash">
+
Now we reboot
sudo ufw allow 19000
+
<pre>
</source>
+
sync && hmi-reset && reboot
 +
</pre>
  
Then, [[Access_MOD_using_SSH|ssh into the Duo]], and run:
+
Some caveats and known issues:
  
<source lang="bash">
+
* Only 48000 Hz sample rate is supported (this is intentional, matches the internal sample rate of the unit)
touch /data/enable-netmanager
+
* USB audio requires very precise timings, loading big resources on the web interface over USB can lead to audio dropouts (best results are achieved with web interface over WiFi, leaving USB for audio and MIDI)
systemctl start jack-netmanager
+
* MOD Duo X "limited edition" only works in capture mode
</source>
+
* For use in Windows, an up-to-date Windows 10 or later is required
NOTE: You only need to run this command once. The next the Duo boots, <tt>jack-netmanager</tt> will be loaded by default. Delete the <tt>/data/enable-netmanager</tt> file inside the Duo to remove this auto-start feature.
 
  
Now run <tt>jackd</tt> on your own computer (connected to the Duo via USB), like this:
+
Forum Threads:
<source lang="bash">
 
jackd -R -P 80 -d net -a 192.168.51.1 -C 2 -P 2 -i 1 -o 1 -l 4 -n mod-slave -s
 
</source>
 
Adjust the parameters as needed, but keep <tt>mod-slave</tt> as the client name.
 
  
=== Parameters explained ===
+
* https://forum.moddevices.com/t/duo-x-as-usb-audio-input-and-midi-device-experimental/3469
 +
* https://forum.moddevices.com/t/solved-usb-audio-jack-with-pipewire-on-linux-how-to-mod-duo/7723/7
  
{| class="wikitable"
+
=== Windows specific tweaks ===
|-
 
| <tt>-R</tt>
 
| Use realtime scheduling, enabled by default.
 
|-
 
| <tt>-P</tt>
 
| Set the realtime scheduling priority, in this case 80.
 
|-
 
| <tt>-d</tt>
 
| JACK backend, in this case the "net" driver.
 
|-
 
| <tt>-a</tt>
 
| Multicast address, in this case the IP address of the MOD Duo.
 
|-
 
| <tt>-C</tt>
 
| Number of audio input ports on the slave. This determines the number of audio output ports on the MOD Duo, marked as "Hardware Audio To Slave" ports in the web interface.
 
|-
 
| <tt>-P</tt>
 
| Number of audio output ports on the slave. This determines the number of audio input ports on the MOD Duo, marked as "Hardware Audio From Slave" ports in the web interface.
 
|-
 
| <tt>-i</tt>
 
| Number of MIDI input ports on the slave. This determines the number of MIDI output ports on the MOD Duo, marked as "Hardware Midi To Slave" ports in the web interface.
 
|-
 
| <tt>-o</tt>
 
| Number of MIDI output ports on the slave. This determines the number of MIDI input ports on the MOD Duo, marked as "Hardware Midi From Slave" ports in the web interface.
 
|-
 
| <tt>-l</tt>
 
| Number of cycles, determines the network latency.
 
|-
 
| <tt>-s</tt>
 
| Setting this option makes the JACK slave memorize the ports that are connected to the JACK master. In case the master disappears and reappears the JACK slave will try to reconnect those ports automatically.
 
|}
 
  
or if you prefer to use jackdbus:
+
When picking an audio driver/mode look for "WASAPI" or "Windows Audio".<br>
<source lang="bash">
+
If there is an option for "exclusive mode" try that first; it won't allow other applications to use the usb audio device at the same time but it reduces the amount of latency.
jack_control eps realtime true eps realtime-priority 80
 
jack_control ds net dps multicast-ip 192.168.51.1 dps client-name mod-slave
 
jack_control dps input-ports 2
 
jack_control dps output-ports 2
 
jack_control dps midi-in-ports 1
 
jack_control dps midi-out-ports 1
 
jack_control dps latency 4
 
jack_control dps auto-save true
 
jack_control start
 
</source>
 
  
[[Category:netJACK]]
+
Under this WASAPI/Windows-Audio mode with 512 buffer size we have measured roundtrip latencies of around 80ms in normal/shared mode, and 60ms in exclusive mode.<br>
[[Category:Networking]]
+
When exclusive mode is selected we were able to reduce buffer size to 256, giving a roundtrip latency of around 38ms.
  
== Using USB Audio Gadget ==
+
Note that latency decreases if you use the MOD unit analog IO, as the analog IO has a full roundtrip latency of 8ms.<br>
 +
There is extra buffering for handling the USB audio card in software, which is needed in order to keep everything in sync between the MOD unit main audio interface and the USB audio side.
 +
 
 +
==== ASIO4ALL ====
 +
 
 +
Using ASIO4ALL has been confirmed to work, but needs some tweaks:
  
'''NOTE: This requires v1.10 or later.'''
+
* Set buffer size to 128 or higher
 +
* In advanced settings set buffer offset to 16ms
 +
* Turn off all other options in advanced settings
  
'''NOTE: This is EXPERIMENTAL and doesn't work on Windows right now.'''
+
This should result in around 60ms total roundtrip latency, will be less if you use the MOD unit analog IO.
  
 +
==== FL Studio ASIO ====
  
First [[Access_MOD_using_SSH|ssh into the unit]], and run:
+
The FL Studio ASIO driver has also been confirmed to work, no special tweaks needed.<br>
 +
Its minimum buffer size of 256 should work fine as-is.
  
<source lang="bash">
+
In our measurements it gives a total roundtrip latency of around 75ms, will be less if you use the MOD unit analog IO.
touch /data/enable-usb-multi-gadget
 
touch /data/enable-usb-audio-gadget
 
# if using windows, also run:
 
touch /data/enable-usb-windows-compat
 
</source>
 
  
Now we reboot
+
== Using netJACK2 ==
<source lang="bash">
 
sync
 
hmi-reset
 
reboot
 
</source>
 
  
Some caveats and known issues:
+
'''NOTE: This requires the use of JACK as sound server in your PC.'''
  
* USB audio requires very precise timings, loading big resources on the web interface over USB can lead to audio dropouts (the best results are with web interface loaded over WiFi, leaving USB for audio and MIDI)
+
See [[Audio Through NetJack2]]
* De-sync of USB packets will pause the audio (either capture or playback) for 10 seconds
 
* Not supported on Windows right now, to be dealt with later on
 
* MOD Duo works 100%
 
* MOD Duo X limited-edition works in playback-only mode
 
* MOD Duo X works well most of the time, with occasional playback sync issues
 
* MOD Dwarf has issues with playback, but capture works well
 

Latest revision as of 10:11, 26 July 2023

Using USB Audio Gadget

NOTE: For best results please use v1.14 or later

NOTE: This is EXPERIMENTAL

First ssh into the unit, and run:

touch /data/enable-usb-multi-gadget
touch /data/enable-usb-audio-gadget
# if using windows, also run:
touch /data/enable-usb-windows-compat

Now we reboot

sync && hmi-reset && reboot

Some caveats and known issues:

  • Only 48000 Hz sample rate is supported (this is intentional, matches the internal sample rate of the unit)
  • USB audio requires very precise timings, loading big resources on the web interface over USB can lead to audio dropouts (best results are achieved with web interface over WiFi, leaving USB for audio and MIDI)
  • MOD Duo X "limited edition" only works in capture mode
  • For use in Windows, an up-to-date Windows 10 or later is required

Forum Threads:

Windows specific tweaks

When picking an audio driver/mode look for "WASAPI" or "Windows Audio".
If there is an option for "exclusive mode" try that first; it won't allow other applications to use the usb audio device at the same time but it reduces the amount of latency.

Under this WASAPI/Windows-Audio mode with 512 buffer size we have measured roundtrip latencies of around 80ms in normal/shared mode, and 60ms in exclusive mode.
When exclusive mode is selected we were able to reduce buffer size to 256, giving a roundtrip latency of around 38ms.

Note that latency decreases if you use the MOD unit analog IO, as the analog IO has a full roundtrip latency of 8ms.
There is extra buffering for handling the USB audio card in software, which is needed in order to keep everything in sync between the MOD unit main audio interface and the USB audio side.

ASIO4ALL

Using ASIO4ALL has been confirmed to work, but needs some tweaks:

  • Set buffer size to 128 or higher
  • In advanced settings set buffer offset to 16ms
  • Turn off all other options in advanced settings

This should result in around 60ms total roundtrip latency, will be less if you use the MOD unit analog IO.

FL Studio ASIO

The FL Studio ASIO driver has also been confirmed to work, no special tweaks needed.
Its minimum buffer size of 256 should work fine as-is.

In our measurements it gives a total roundtrip latency of around 75ms, will be less if you use the MOD unit analog IO.

Using netJACK2

NOTE: This requires the use of JACK as sound server in your PC.

See Audio Through NetJack2