Linux

InTheWorks
Posts: 80
Joined: Sat May 28, 2022 11:59 pm

Re: Linux

Post by InTheWorks » Thu Dec 29, 2022 9:01 am

I haven't measured the latency, but I just played through a song and it didn't seem bad. I'm using hydrogen audio (nothing fancy) and output to pulse. Maybe tomorrow I'll try a latency measurement.

What doesn't work is hihat CC. In fact, open/close doesn't even work. This may be a limitation in hydrogen. I'll check out drumgizmo next.

One downside is the audio levels. Can't control the mix of drums to song in Aerodrums like this. Probably not a huge deal once I get the sampler/sequencer set up properly.

I'm cautiously optimistic that this might actually work. Thanks for the push NarcoticV.

NarcoticV
Posts: 13
Joined: Wed Dec 21, 2022 12:27 am

Re: Linux

Post by NarcoticV » Thu Dec 29, 2022 1:50 pm

Great to hear that you're taking another stab at it! I hope I am not wasting your time and you are happy with the result. I am curious about the latency result.

I expect that the latency would be determined (apart from the framerate latency of course) by your ALSA settings and audio interface. The period size is important, but also the number of periods is configurable. I use a period of 128 samples and 2 period buffering.

If you are using Jackd, there is a little tool called "jack_iodelay" which you can use to measure total round-trip latency by connecting your audio out back to your audio in. That would tell you how much of your latency is coming from the audio interfacing and buffering, as opposed to from Aerodrums/Wine/whatever else.

I am not sure about the MIDI mapping troubles. I can imagine that this differs per program, and Aerodrums doesn't have a built-in map for Hydrogen. Maybe we should request this from the Aerodrums team? After all, Hydrogen is free and available on Windows too. Same goes for DrumGizmo. Might be interesting for other users who want more freedom in kit selection and customization.

DrumGizmo is quite nice. It is actively developed, comes with 5 free kits of varying quality, and most of all offers a lot of customization capability, including the MIDI mapping. One thing though is that it seems that DrumGizmo comes as a plugin (LV2 on Linux / VST on Windows). So you would need to run it using a plugin host (like e.g. Carla).

Best of luck!

NarcoticV
Posts: 13
Joined: Wed Dec 21, 2022 12:27 am

Re: Linux

Post by NarcoticV » Thu Dec 29, 2022 1:51 pm

I found a small mistake in my Arch package regarding the shortcuts.
It also seems I may be able to convert it to a .deb package for Ubuntu/Debian relatively easily - I will have a shot at that.

NarcoticV
Posts: 13
Joined: Wed Dec 21, 2022 12:27 am

Re: Linux

Post by NarcoticV » Thu Dec 29, 2022 1:58 pm

I've been thinking about pipewire too. Do your volume indicators still work?
For me, everything works like a dream now. Pipewire is regarded as the future of Linux (professional) audio, and I am fully sold on it. My desktop environment and regular apps talk to Pipewire via its Pulseaudio interface, and my music production tools via its Jack interface, and it all blends without any issues.

But as it is still emerging, it may take quite some effort to get it installed and configured properly. It was for me, even on Arch Linux, which has great documentation on Pipewire. I had to jump through quite some hoops to get it running well and at a low latency with my audio interface. For Ubuntu MATE, I have no idea.

I think jackd is the next best thing when you want to be able to easily patch applications together into pipelines. Which is already kind of what you are doing by connecting Aerodrums MIDI -> sampler -> output.

InTheWorks
Posts: 80
Joined: Sat May 28, 2022 11:59 pm

Re: Linux

Post by InTheWorks » Thu Dec 29, 2022 6:13 pm

NarcoticV wrote:
Thu Dec 29, 2022 1:50 pm
Great to hear that you're taking another stab at it! I hope I am not wasting your time and you are happy with the result.
I was already wasting time writing a program to capture from the ps3 eye and display it via sdl2...

Curiously, when I played it through pulseaudio, the latency seemed pretty minimal. And that's been the problem with my observations. Sometimes it's good, mostly it's not and I have no idea what's responsible.
NarcoticV wrote:
Thu Dec 29, 2022 1:50 pm
I am not sure about the MIDI mapping troubles. I can imagine that this differs per program, and Aerodrums doesn't have a built-in map for Hydrogen. Maybe we should request this from the Aerodrums team? After all, Hydrogen is free and available on Windows too. Same goes for DrumGizmo. Might be interesting for other users who want more freedom in kit selection and customization.
When Hydrogen creates an alsa midi port, wine can see it and it shows up automatically in Aerodrums. No work required. The issue with Drumgizmo is it doesn't have a working alsa midi port and wine can't see jack midi ports. I know there's convoluted ways to connect jack and make it work, but I'm not interested in such a solution.
NarcoticV wrote:
Thu Dec 29, 2022 1:50 pm
One thing though is that it seems that DrumGizmo comes as a plugin (LV2 on Linux / VST on Windows). So you would need to run it using a plugin host (like e.g. Carla).
Not true. You can run drumgizmo standalone from the command line.

InTheWorks
Posts: 80
Joined: Sat May 28, 2022 11:59 pm

Re: Linux

Post by InTheWorks » Thu Dec 29, 2022 6:19 pm

NarcoticV wrote:
Thu Dec 29, 2022 1:58 pm
My desktop environment and regular apps talk to Pipewire via its Pulseaudio interface, and my music production tools via its Jack interface, and it all blends without any issues.
I don't do professional audio on my machine so I don't need the capability other than to run Aerodrums.
NarcoticV wrote:
Thu Dec 29, 2022 1:58 pm
But as it is still emerging, it may take quite some effort to get it installed and configured properly.
That was my understanding on the current state of pipewire.
NarcoticV wrote:
Thu Dec 29, 2022 1:58 pm
I think jackd is the next best thing when you want to be able to easily patch applications together into pipelines. Which is already kind of what you are doing by connecting Aerodrums MIDI -> sampler -> output.
I'll be honest, I don't like jackd. It's too complicated for what I need to do and I'd rather not use it. What I need to do works fine with plain alsa.

I also don't think it's reasonable to expect your average Aerodrums user on linux to deal with jackd.

InTheWorks
Posts: 80
Joined: Sat May 28, 2022 11:59 pm

Re: Linux

Post by InTheWorks » Thu Dec 29, 2022 6:42 pm

Actually the latest version of drumgizmo (0.9.20) supports alsamidi now. After compiling the latest it runs (I have it connected to alsa pulse), but the midi map is totally wrong. The only thing making noises are the bass drum and cymbals.

To run drumgizmo from the command line, I use a script:

Code: Select all

#!/bin/sh
PROG=/path/to/compiled/drumgizmo
KIT=/path/to/drumgizmo/kits

$PROG -i alsamidi -I midimap=$KIT/midimap.xml -o alsa -O dev=pulse $KIT/ShittyKit.xml
When I get around to it, I'll check the latency through drumgizmo.

InTheWorks
Posts: 80
Joined: Sat May 28, 2022 11:59 pm

Re: Linux

Post by InTheWorks » Fri Dec 30, 2022 8:17 am

Okay some latency measurements.

The test setup was:
1. a behringer ECM8000 mic with a MicMate (usb sound card)
2. KRK KNS-8400 headphones

The microphone was placed inside the left earcup of the headphones. The microphones and headphones were placed about a drumstick's length away from where I clicked the sticks. One drum stick was held backwards (reflective ball in the palm of my hand) and suspended approximately where the snare was placed. To get a latency measurement, I used the other drumstick normally and brought it down onto the other stick. This creates an audible click that travels through the air and into the microphone. Simultaneously aerodrums detects the snare hit and sends it out audio or midi. This eventually comes out the headphones and into the microphone. The latency is the measurement between the clicking of the drumsticks and the snare sound from the headphones.

First of all, yesterday my aerodrums audio config looked like this:
Screenshot at 2022-12-29 01-21-32.png
Screenshot at 2022-12-29 01-21-32.png (160.62 KiB) Viewed 14698 times
And the latency was not noticeable. I have no idea why the buffer size was 1, but it worked. However, after playing around with settings and such I can no longer put it back in that state and the latency is horrible. Right now it looks like this:
Screenshot at 2022-12-29 22-08-01.png
Screenshot at 2022-12-29 22-08-01.png (175.14 KiB) Viewed 14698 times
To get it there I had to modify the aerodrums.cfg to set the buffer size to 1. The test button plays fine only in the wine output mapper or pulseaudio (not WASPI) modes. With other pulseaudio WASPI mode the test button plays garbage.

I dunno, maybe there is a clue in there.

Hydrogen buffer size is 100. No control over number of periods.

Drumgizmo is using the alsa output engine (not jackd) which only outputs float so I had to create an asound.conf snippet:

Code: Select all

$ cat /etc/alsa/conf.d/99-aerodrums.conf
pcm_slave.sl {
    pcm "hw:0,0"
    format S16_LE
    channels 2
    rate 44100
}

pcm.direct {
    type plug
    slave sl
}
then I could invoke drumgizmo like this:

Code: Select all

$PROG -i alsamidi -I midimap=$KIT/midimap.xml -o alsa -O dev=direct $KIT/ShittyKit.xml
or

Code: Select all

$PROG -i alsamidi -I midimap=$KIT/midimap.xml -o alsa -O dev=pulse $KIT/ShittyKit.xml
Here are the latency measurements.

Code: Select all

direct to pulseaudio (direct):        137ms
direct to pulseaudio (dock):          122ms

midi hydrogen to pulseaudio (direct):  24ms
midi hydrogen to pulseaudio (dock):    50ms

midi hydrogen to alsa (direct):        24ms

midi drumgizmo to pulseaudio (direct): 19ms
midi drumgizmo to alsa (direct):       14ms
It doesn't look like my dock changes the behaviour much. I stopped testing with the dock. Note that these are one shot measurements. By that I mean for each latency measurement, aerordums was closed and then opened. Hydrogen was closed and opened. Drumgizmo was started and stopped. And I only took one recording. There seems to be some variability with the pulseaudio back end which is not unexpected.

I would really like to get back to the state aerodrums was in the other day when latency wasn't noticeable with pulseaudio. Maybe it was a fluke, but if it can be like that once it's possible to maybe do that all the time.

Using hydrogen or drumgizmo directly with alsa is a bit of a pain. First I have to disconnect the audio device from pulseaudio by switching to a different output. Then the midimap needs to be fixed. And lastly the volume control issue. And the convenient 'drum stick user interface' can't be used to start and stop songs. Which is hella convenient.

Since drumgizmo achieved pretty low latency using pulseaudio through the alsa backend, that makes me think it should be possible to do it through wine if wine can use alsa instead of pulseaudio directly? I'd prefer to have the aerodrums audio work through pulseaudio.

If the portaudio library was exposed, like libusb is a separate lib, we could theoretically replace the portaudio calls through wine with a direct path to alsa or jackd or pulse. That might improve things. Maybe it's possible to patch the binary. I don't really want to go there though.

I may try pipewire. I found a guide that leaves pulseaudio installed and seems easy to reverse (in the event of issues):
https://askubuntu.com/questions/1339765 ... untu-20-04

NarcoticV
Posts: 13
Joined: Wed Dec 21, 2022 12:27 am

Re: Linux

Post by NarcoticV » Fri Dec 30, 2022 1:32 pm

Nice work!

Just out of curiosity: do you have an idea of what kind of latency is needed for it to be unnoticeable for you?
When I get back home in a few days, I will try to reproduce your experiment with some different setups also. I am happy with how it plays at the moment but have no idea what the latency is.

Are you aware of the wine alsa driver? This should expose your ALSA devices directly to Aerodrums. I found that if I run "winecfg" I cannot change the audio driver (which is by default set to winepulse). But after running "winetricks sound=alsa" (which I think only makes some registry edits), the driver is set to winealsa and it seems to work. Would be interesting for your latency comparison.

NarcoticV
Posts: 13
Joined: Wed Dec 21, 2022 12:27 am

Re: Linux

Post by NarcoticV » Fri Dec 30, 2022 1:37 pm

One thing about pipewire and the article you linked: apparently the session management for Pipewire comes in a separate tool (in your article, they reference "pipewire-media-session"). I have understood that pipewire-media-session is the default choice but is kind of a limited reference implementation, and for advanced usage the "wireplumber" session manager is preferred.

I remember that there was a reason for me to switch to wireplumber also. Unfortunately I don't remember what the reason was. But e.g. the Arch Linux documentation recommends wireplumber as being more powerful.

For example, my detailed ALSA settings for my audio interfaces are configured in wireplumber config files.

There you go, already getting more complicated than planned ;)

Post Reply