brummer10 / guitarix

guitarix virtual versatile amplification for Jack/Linux
254 stars 28 forks source link

[Feature Request] MIDI out option for tuner for headless use #14

Closed Rippert closed 4 years ago

Rippert commented 4 years ago

I really like the Guitarix tuner. It is one of the few that lets me tune my 5-string Bass with open strings. I would like to use it when I am running Guitarix on a headless system. I think something like a note-on message with the closest note value and the velocity equal to 63 when in tune. The velocity value would be lower than 63 when the note needs to be tuned higher, and higher than 63 when the note needs to be tuned lower. This could be used to provide a simple tuner display on my pedalboard similar to what the GUI display is like when set to "scale."

This could be an option under the Options menu.

Note this is different from trying to provide a note to MIDI interface which would have the velocity proportional to the loudness of the note.

brummer10 commented 4 years ago

Hi Nice idea. Done. Let me know if that work as you've expected.

brummer10 commented 4 years ago

Ah, I forgot to mention that the option is in the Plugin menu, together with the other tuner options, not under Options.

Rippert commented 4 years ago

Thanks for the quick response. It does work the way I expected except for two things.

  1. After I turn the tuner off, the MIDI notes continue to be output as if the tuner is still on. This is a problem because I don't want to slow down the MIDI bus with unneeded messages, and having the tuner running all the time causes xruns in jack at low latencies due to the extra CPU usage. The GUI display does turn off when I turn off the tuner, but it seems to still be running from the MIDI data.

  2. Every time, after the note stops (when I mute the string), a CC value of 0 is sent out on CC 120. I don't have any MIDI controllers set up in this instance, not even for the bypass switch, so this should not be happening as far as I can tell.

brummer10 commented 4 years ago
1. After I turn the tuner off, the MIDI notes continue to be output as if the tuner is still on. This is a problem because I don't want to slow down the MIDI bus with unneeded messages, and having the tuner running all the time causes xruns in jack at low latencies due to the extra CPU usage. The GUI display does turn off when I turn off the tuner, but it seems to still be running from the MIDI data.

Okay, I've corrected that now, so tuner and midi out from it will only run when tuner is explicit "On".

2\. Every time, after the note stops (when I mute the string), a CC value of 0 is sent out on CC 120. I don't have any MIDI controllers set up in this instance, not even for the bypass switch, so this should not be happening as far as I can tell.

That is there on purpose. I guess it wouldn't take long that first people will use this to drive a synth, so I send cc 120 "All Sound Off" when the note stops. You could use it as well to reset your tuner display.

Rippert commented 4 years ago
  1. Appears to be fixed, but now the tuner continuously operates when it's turned on, trying to find the note being played and outputting MIDI, even when I mute the input to my sound-card. Turning on the Noise Gate at maximum doesn't stop it either, and there is no output registering on the meters. It used to stop when I muted the string with my hand, now it only stops when i turn it off explicitly. Whatever minimum input level was set is now either gone or greatly reduced.

  2. I understand what you are saying here, but using CC 120 conflicts with the MIDI feedback from the Engine Muting button. There's no way to tell from the MIDI signal whether the tuner stopped or the Engine Mute button was pressed. Maybe you should use CC 123 value 0, which is "All Notes Off" instead of CC 120, "All Sound Off"

Rippert commented 4 years ago

I just checked it with my power amp on. The Noise Gate doesn't seem to work at all, and when I mute my strings a high pitched whine starts up.

Rippert commented 4 years ago

I thought maybe my sound-card had gone bad or something, so I tried the LV2 version of GxTuner. It worked normally, stopping trying to determine the note when I mute my strings. I'll try reverting to older commits next.

Rippert commented 4 years ago

So, very strange. I cannot get the constant tuner activity to stop even by reverting to what I built yesterday, or V0.40.0. Both of which had the tuner working normally when I first built them. I even tried sudo ./waf uninstall, ./waf clean and ./waf distclean and then a full rebuild and reinstall. I also tried putting the LV2 GxTuner in series with guitarix, both before and after. It keeps working normally, and the Guitarix tuner keeps constant activity.

I assume some file that the built in Guitarix tuner depends on changed when I first rebuilt today, but isn't included when I do an new install or even an uninstall and new install.

brummer10 commented 4 years ago

That's strange, indeed. I've nothing changed regarding the tuner threshold. The noise-gate haven't any influence on the tuner, the tuner snoop direct on the input, so that you could use it while the engine is muted. It has it's own threshold set in /src/gx_head/engine/gx_pitch_tracker.cpp line 37 + 38

static const float SIGNAL_THRESHOLD_ON = 0.001;
static const float SIGNAL_THRESHOLD_OFF = 0.0009;

this means a threshold of -60dB. For display only that suite very well, but maybe it's a bit to low for the new midi output. You may try to set it higher, for example 0.01 / 0.009 means -40dB, or 0.055 / 0.054 means -25dB, which should be enough anyway.

2\. I understand what you are saying here, but using CC 120 conflicts with the MIDI feedback from the Engine Muting button. There's no way to tell from the MIDI signal whether the tuner stopped or the Engine Mute button was pressed. Maybe you should use CC 123 value 0, which is "All Notes Off" instead of CC 120, "All Sound Off"

Ah yea. Good point, will do.

brummer10 commented 4 years ago

As a side note, in GxTuner I've implemented a high/low cut at 23/999Hz. So the issue may be noise input.

brummer10 commented 4 years ago

Okay, I've added the low/high cut to the guitarix tuner as well, and set the tuner threshold to -40dB.

Rippert commented 4 years ago

OK, your last comment about the high/low cut sent me in the right direction. I enabled the ADC High Pass Filter on my sound card, and the tuner now works fine. Must be something below 23 Hz since the LV2 plugin tuner was working well. I'll have to track down what happened, as I haven't needed that switch on before, but there is no bug in your code, at least in regards to the tuner ;).

The MIDI output does seem to be working well. When you make the change to CC 123, it should be just what I need. Thank You.

brummer10 commented 4 years ago

checkout the last commit, I've changed it to cc 123 already. Also, maybe you didn't need to enable the ADC filter (at least try it please) as I've added the low/high cut.

Rippert commented 4 years ago

I tried it. It is working, even with the ADC Filter off. There is still a whine with the filter off, but that's a hardware issue I have to track down. I think the -40dB is too high. I didn't mind the -60dB myself. If no one else has complained, maybe set it back to that. If other people want it raised, maybe -50dB?

One thing I just noticed. I can hear the filter cutting in and out in the audio output when I switch the tuner on and off. If someone was to leave the tuner on all the time, they might be annoyed with the loss of the highs. Can it be made to work only on the tuner signal path?

brummer10 commented 4 years ago

Okay, have set it back to -60dB.

One thing I just noticed. I can hear the filter cutting in and out in the audio output when I switch the tuner on and off. If someone was to leave the tuner on all the time, they might be annoyed with the loss of the highs. Can it be made to work only on the tuner signal path?

Umpf, all-time I forgot something. It's hard when you getting older. Okay, that should be fixed now as well. Please checkout and let me know if anything works.

Rippert commented 4 years ago

Everything is working as far as I can tell. I can't hear any change in the sound output when i turn the tuner on or off, and it doesn't cut out while I'm taking my time tuning those big clunky Bass strings. It also still doesn't have a problem when I turn off the ADC filter, so the low/high cut on the tuner was enough without the higher threshold. Thanks again Hermann.