|
|
(24 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
− | == Using netJACK2 ==
| |
− |
| |
− | '''NOTE: This requires v1.4 or later.'''
| |
− |
| |
− | 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:
| |
− |
| |
− | <source lang="bash">
| |
− | sudo ufw allow 19000
| |
− | </source>
| |
− |
| |
− | Then, [[Access_MOD_using_SSH|ssh into the Duo]], and run:
| |
− |
| |
− | <source lang="bash">
| |
− | touch /data/enable-netmanager
| |
− | systemctl start jack-netmanager
| |
− | </source>
| |
− | 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:
| |
− | <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 ===
| |
− |
| |
− | {| class="wikitable"
| |
− | |-
| |
− | | <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:
| |
− | <source lang="bash">
| |
− | 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]]
| |
− | [[Category:Networking]]
| |
| | | |
| == Using USB Audio Gadget == | | == Using USB Audio Gadget == |
| | | |
− | '''NOTE: This requires v1.10 or later.''' | + | '''NOTE: For best results please use v1.14 or later''' |
| | | |
− | '''NOTE: This is EXPERIMENTAL and doesn't work on Windows right now.''' | + | '''NOTE: This is EXPERIMENTAL''' |
− | | |
− | | |
− | We are going to enable USB Audio Gadget as UAC2 by replacing some system files and activating the unit gadget mode.
| |
| | | |
| First [[Access_MOD_using_SSH|ssh into the unit]], and run: | | First [[Access_MOD_using_SSH|ssh into the unit]], and run: |
| | | |
− | <source lang="bash"> | + | <pre> |
| touch /data/enable-usb-multi-gadget | | touch /data/enable-usb-multi-gadget |
− | mount / -o remount,rw
| + | touch /data/enable-usb-audio-gadget |
− | </source> | + | # if using windows, also run: |
| + | touch /data/enable-usb-windows-compat |
| + | </pre> |
| | | |
− | Second, open /sbin/enable-usb-gadget.sh inside the unit (with either nano or vi, as you prefer) and replace its entire contents with:
| + | Now we reboot |
− | <source lang="bash"> | + | <pre> |
− | #!/bin/bash
| + | sync && hmi-reset && reboot |
| + | </pre> |
| | | |
− | source /etc/mod-hardware-descriptor.env
| + | Some caveats and known issues: |
| | | |
− | # If we need to wait for usb to be plugged in before activating gadget mode, do nothing
| + | * Only 48000 Hz sample rate is supported (this is intentional, matches the internal sample rate of the unit) |
− | # On such units, we can only register g_ether after the USB is plugged in
| + | * 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) |
− | if [ "${USB_PLUGGED_IN_WAIT_REQUITED}" -eq 1 ] && [ -n "${STARTED_VIA_SYSTEMD}" ]; then
| + | * MOD Duo X "limited edition" only works in capture mode |
− | exit 0
| + | * For use in Windows, an up-to-date Windows 10 or later is required |
− | fi
| |
| | | |
− | if [ -f /data/enable-usb-multi-gadget ] && [ -e /proc/device-tree/compatible ]; then
| + | Forum Threads: |
− | /sbin/modprobe libcomposite
| |
| | | |
− | if [ -f /data/enable-usb-windows-compat ]; then
| + | * https://forum.moddevices.com/t/duo-x-as-usb-audio-input-and-midi-device-experimental/3469 |
− | /sbin/modprobe usb_f_rndis
| + | * https://forum.moddevices.com/t/solved-usb-audio-jack-with-pipewire-on-linux-how-to-mod-duo/7723/7 |
− | WINDOWS_COMPAT_MODE=1
| |
− | else
| |
− | WINDOWS_COMPAT_MODE=0
| |
− | fi
| |
| | | |
− | # Read serial
| + | === Windows specific tweaks === |
− | if [ -f /var/cache/mod/tag ]; then
| |
− | SERIAL=$(cat /var/cache/mod/tag)
| |
− | else
| |
− | SERIAL=$(mod-hardware tag)
| |
− | fi
| |
− | SERIAL=$(echo ${SERIAL} | awk 'sub("-","\n")' | tail -n 1 | sed 's/-//g')
| |
| | | |
− | # Create MAC address suffix
| + | When picking an audio driver/mode look for "WASAPI" or "Windows Audio".<br> |
− | MAC=$(echo ${SERIAL} | tail -c 10 | sed 's/\(\w\w\)/:\1/g')
| + | 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. |
| | | |
− | # create new composite gadget instance
| + | 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> |
− | mkdir /sys/kernel/config/usb_gadget/multi
| + | When exclusive mode is selected we were able to reduce buffer size to 256, giving a roundtrip latency of around 38ms. |
− | cd /sys/kernel/config/usb_gadget/multi
| |
| | | |
− | # assign an unique id based on model, so each one is handled separately/differently by the host OS
| + | Note that latency decreases if you use the MOD unit analog IO, as the analog IO has a full roundtrip latency of 8ms.<br> |
− | if [ "${PLATFORM}" = "duo" ]; then
| + | 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. |
− | PRODUCT_CODE="1"
| |
− | elif [ "${PLATFORM}" = "dwarf" ]; then
| |
− | PRODUCT_CODE="2"
| |
− | elif [ -n "${MODEL_IMX8MQ}" ] && [ "${MODEL_IMX8MQ}" -eq 1 ]; then
| |
− | PRODUCT_CODE="3"
| |
− | else
| |
− | PRODUCT_CODE="4"
| |
− | fi
| |
| | | |
− | # please increment this value everytime you make changes here!
| + | ==== ASIO4ALL ==== |
− | PRODUCT_VERSION="1"
| |
| | | |
− | # make a unique device id based on previous values
| + | Using ASIO4ALL has been confirmed to work, but needs some tweaks: |
− | echo "0x3${PRODUCT_CODE}${PRODUCT_VERSION}${WINDOWS_COMPAT_MODE}" > bcdDevice
| |
| | | |
− | # USB ID, see more at http://www.linux-usb.org/usb.ids
| + | * Set buffer size to 128 or higher |
− | echo "0x1d6b" > idVendor
| + | * In advanced settings set buffer offset to 16ms |
− | echo "0x0104" > idProduct
| + | * Turn off all other options in advanced settings |
| | | |
− | # Setup USB Gadget
| + | This should result in around 60ms total roundtrip latency, will be less if you use the MOD unit analog IO. |
− | echo 0x0200 > bcdUSB # USB 2.0
| |
− | echo 0xEF > bDeviceClass # Miscellaneous
| |
− | echo 0x02 > bDeviceSubClass
| |
− | echo 0x01 > bDeviceProtocol
| |
| | | |
− | # USB Information (0x409 is English)
| + | ==== FL Studio ASIO ==== |
− | mkdir strings/0x409
| |
− | echo "MOD Devices" > strings/0x409/manufacturer
| |
− | echo "${MODEL_NAME}" > strings/0x409/product
| |
− | echo "${SERIAL}" > strings/0x409/serialnumber
| |
| | | |
− | # Setup MIDI
| + | The FL Studio ASIO driver has also been confirmed to work, no special tweaks needed.<br> |
− | mkdir functions/midi.usb0
| + | Its minimum buffer size of 256 should work fine as-is. |
| | | |
− | if [ ${WINDOWS_COMPAT_MODE} -eq 1 ]; then
| + | In our measurements it gives a total roundtrip latency of around 75ms, will be less if you use the MOD unit analog IO. |
− | # Setup RNDIS
| |
− | mkdir functions/rndis.usb0
| |
− | echo "22${MAC}" > functions/rndis.usb0/dev_addr
| |
− | echo "32${MAC}" > functions/rndis.usb0/host_addr
| |
− | echo "RNDIS" > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
| |
− | echo "5162001" > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
| |
| | | |
− | ## Hacky stuff for Windows
| + | == Using netJACK2 == |
− | echo "1" > os_desc/use
| |
− | echo "0xcd" > os_desc/b_vendor_code
| |
− | echo "MSFT100" > os_desc/qw_sign
| |
− | else
| |
− | # Setup ECM
| |
− | mkdir functions/ecm.usb0
| |
− | echo "02${MAC}" > functions/ecm.usb0/dev_addr
| |
− | echo "12${MAC}" > functions/ecm.usb0/host_addr
| |
− | | |
− | # Setup UAC2
| |
− | mkdir functions/uac2.usb0
| |
− | echo "3" > functions/uac2.usb0/c_chmask
| |
− | echo "3" > functions/uac2.usb0/c_ssize
| |
− | echo "48000" > functions/uac2.usb0/c_srate
| |
− | echo "3" > functions/uac2.usb0/p_chmask
| |
− | echo "3" > functions/uac2.usb0/p_ssize
| |
− | echo "48000" > functions/uac2.usb0/p_srate
| |
− | fi
| |
− | | |
− | # Configuration
| |
− | mkdir configs/mod.1
| |
− | echo "0xc0" > configs/mod.1/bmAttributes # self-powerered
| |
− | echo "1" > configs/mod.1/MaxPower # 2mA
| |
− | | |
− | mkdir configs/mod.1/strings/0x409
| |
− | echo "${MODEL_NAME}" > configs/mod.1/strings/0x409/configuration
| |
− | | |
− | if [ ${WINDOWS_COMPAT_MODE} -eq 1 ]; then
| |
− | ln -s functions/rndis.usb0 configs/mod.1
| |
− | ln -s configs/mod.1 os_desc
| |
− | else
| |
− | ln -s functions/ecm.usb0 configs/mod.1
| |
− | ln -s functions/uac2.usb0 configs/mod.1
| |
− | fi
| |
− | | |
− | ln -s functions/midi.usb0 configs/mod.1
| |
− | | |
− | # Ready to roll!
| |
− | /bin/find /sys/class/udc -type l -maxdepth 1 | /bin/tail -n 1 | /bin/awk 'sub("/sys/class/udc/","")' > UDC
| |
− | else
| |
− | /sbin/modprobe g_ether
| |
− | fi
| |
− | | |
− | # Setup IRQ priority, taken from `set-irq-priorities.sh`
| |
− | if [ -n "${USB_IRQ}" ]; then
| |
− | USB_PID=$(/usr/bin/ps -e | /usr/bin/grep irq/${USB_IRQ} | /usr/bin/awk '{print $1}')
| |
− | # USB IRQ is sometimes only active if a usb host or gadget is plugged in
| |
− | if [ -n "${USB_PID}" ]; then
| |
− | # we can have 2 processes handling usb
| |
− | if [ "$(/usr/bin/echo ${USB_PID} | /usr/bin/wc -w)" -eq 2 ]; then
| |
− | USB_PIDS=($(/usr/bin/echo ${USB_PID}))
| |
− | /usr/bin/chrt -f -p 55 ${USB_PIDS[0]}
| |
− | /usr/bin/chrt -f -p 55 ${USB_PIDS[1]}
| |
− | else
| |
− | /usr/bin/chrt -f -p 55 ${USB_PID}
| |
− | fi
| |
− | fi
| |
− | fi
| |
− | | |
− | # Bring up usb0 ethernet interface
| |
− | /sbin/ifup usb0
| |
− | | |
− | # Restarts sshd service, needed after usb0 being active
| |
− | /usr/bin/systemctl restart sshd
| |
− | | |
− | # On legacy units, g_ether waits for first USB to be plugged in
| |
− | # As such, netmanager cannot start on boot, so do that now
| |
− | if [ -f /data/enable-netmanager ] && [ "${USB_PLUGGED_IN_WAIT_REQUITED}" -eq 1 ]; then
| |
− | /usr/bin/systemctl start jack-netmanager
| |
− | fi
| |
− | | |
− | exit 0
| |
− | </source>
| |
− | | |
− | Now we reboot
| |
− | <source lang="bash">
| |
− | hmi-reset
| |
− | sync
| |
− | reboot
| |
− | </source>
| |
− | | |
− | The UAC2 mode is now active. Once a unit is booted up again, simply activate extra audio inputs with:
| |
− | | |
− | <source lang="bash">
| |
− | jack_load mod-slave zita-a2j -i "-d hw:UAC2Gadget -p 128 -n 4"
| |
− | </source>
| |
| | | |
− | If something fails, boot into restore mode and reinstall to start fresh.
| + | '''NOTE: This requires the use of JACK as sound server in your PC.''' |
| | | |
− | This will be part of an official MOD release at some point, these contents are written here in the hopes of being useful, but it is really only meant for advanced users for now.
| + | See [[Audio Through NetJack2]] |
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