You are here

Qtractor source - Metronome function

Hi.

I want to try to make a private addition to the Qtractor source.
In Qtractor main window there is the button to activate/deactivate the metronome.

Where to find the related functions/code to this button?

Thanks

Forums: 
rncbc's picture

hi,

for the UI part:

qtractorMainForm::transportMetro()

for the audio and MIDI metronomes resp. it follows from:

qtractorAudioEngine::setMetronome(bool) ...
qtractorMidiEngine::setMetronome(bool)
...

may I ask whet kind of additions are you up to?

seeya

TAERSH's picture

In the early days I used Hydrogen for the Drums. In 2009/2011 I created Hydrogen drum kits from samples recorded of my huge Sonor Force 3007 drum kit. Last year I created a .sf2 sound file from that samples, so I'm using Hydrogen now for the metronome only. I want to get rid of the use of Hydrogen. So, by now I have added a small line (using command "system()") to the source code in function "transportMetro()", calling a script "qtractor_SwitchKlick". Within this script I'm switching program "klick" for the use of the metronome.

The script is either calling "klick -j -P" to enable the metronome, make it following JACK transport and auto-connect to JACK or calling "killall klick" to disable the metronome. Works good so far. The only problem by now is: when I'm accidentally exiting Qtractor with Metronome enabled, "klick" will run on disabling the Metronome and revert. But I can live with that for now.

Though, I got a warning when compiling about something unused (return value?) on the "system()" command. But it doesn't seem to have any negative effect.

Thanks a lot!!!

rncbc's picture

why don't you just use the audio sample files for the bar/beats in View > Options... > Audio > Metronome?
would save you a lot of hassle, I suppose :)

cheers

TAERSH's picture

Like many others already mentioned overall in the web, the audio-metronome has lots of problems to stay synchronized during a song. I tried to use it, but it doesn't really satisfy, even though I'm using a real-time kernel 5.0.21-rt15. Without the real-time kernel it's really trouble and completely unusable.

That's why I kept using the MIDI-metronome. By now using "klick -j -P" works great so far. Also it's just a single line I have to add to the source code, it's no trouble for me to do so at each new compiling. The only thing I would like to know: how would I check (in C) if the option/metronome is active/de-active.

rncbc's picture

what exactly are the problems you're facing with the audio metronome that requires a real-time kernel to mitigate ??

puzzled

TAERSH's picture

It goes out of sync and it doesn't play the samples exactly to the beat. With real-time kernel it seems to be a little behind the beat.
I'm a drummer, I know when something goes out of sync or is not exactly on the beat. I played for years in bands playing to loops and programs like Ableton Live playing complex rhythms and sequences.

rncbc's picture

does it drift? or is it just a fixed delay/latency to it that you can compensate with the audio metronome "latency" setting to account for the system and acoustic delay ?

of course, you can also take the "systemic" latency to a bearable low on the JACK side of settings, like the buffer-size set to a bearable minimum of at least 128 (frames/period) or can't you?

cheers

TAERSH's picture

My JACK settings is 44100 sample rate and 1024 frames/period with 2 buffers/period. When I'm changing any of these settings I'm getting lots of XRUNS. I tried 48000 sample rate, I tried also 2048 frames/period as well as 512 frames/period in different combinations. With my current settings I get XRUNS only one time directly after Qtractor started and is ready for a use.

To try to compensate by changing latency settings for the audio metronome would be much more hassle to me than to just add this one-liner to the source code. The "klick" metronome is good to hear/listen and very stable following the JACK transport.

On songs with long duration the audio metronome gets completely out of sync, so it drifts to be syncopated to the beat.

rncbc's picture

with a barely tuned PREEMPT_RT kernel you ought to be running @48000/128/2 (or 3), no xruns, no sweat... and this is the minimum sane and (trust me) conservative system spec you should ever consider as a baseline on modern GNU/Linux... anything above that is, erm. yeah you get what I mean :)

otoh. you could just have klick running standalone, responding to JACK transport at large, I don't really see the need to hack the qtractor source to launching it inline, or am I missing the point?

cheers
cheers

TAERSH's picture

Ok, may I ask again:

How would I check inside the function "transportMetro()" if the option/metronome is active/de-active?

rncbc's picture

for the audio metronome,
... pAudioEngine->isMetronome() ?
or, for the MIDI one,
... pMidiEngine->isMetronome() ?

byee

TAERSH's picture

Hi.

"otoh. you could just have klick running standalone, responding to JACK transport at large, I don't really see the need to hack the qtractor source to launching it inline, or am I missing the point?"

To run "klick" as standalone I would need either to run it by GUI GtkKlick, but this doesn't follow JACK transport and it doesn't seem to have any option to set it up to follow JACK transport. Also, if it could do, it would force me to enter the menu to run it each time I want to use the metronome. The other way would be to run "klick" by entering "klick -j -P" into a terminal. Both of this options is a waste of time on a long term use. Also I don't like to run programs by a terminal command, except for debugging, compiling, development etc.

Apart from a few tasks, using the terminal to run programs is the ugliest way for a good workflow. ;)

Having that one-liner added (which calls my script) makes me able to start/quit "klick" from within Qtractor's main window.

From my point of view and use of Qtractor it's just the best solution to have a good working metronome running in addition to Qtractor. No extra GUI on the desktop, no extra program in the task bar, no terminal running which would immediately close the program if the terminal was accidentally closed.

***

I'm not asking how to check if either audio metronome or midi metronome is active. I'm asking how to check, if the metronome option (the button for parameter transport/Metronome in config file) is active/de-active.

rncbc's picture

... m_ui.transportMetroAction->isChecked() ?

TAERSH's picture

I tried 48000/128/2 but I get hundreds of XRUNS. I have setup my system for real-time priority above 90%. Even at 48000/512/2 I get lots of XRUNS. My computer is an AMD Ryzen 5 2600X Six-Core Processor. Maybe I should try Intel processors next time. On that AMD processor I couldn't even use CPU governor. In BIOS I set all processor related settings to full performance, so all threads are running at around 3900+ MHZ.

Don't know how to get a better performance and much less XRUNS out of this system using settings different to my 44100/1024/2 which gives me a latency of 46.4 ms.

rncbc's picture

TAERSH's picture

Yes, it's all pretty much setup like it's listed in the wiki.

I have AV Linux MX edition on a USB flash drive (for live use and testings only, as I don't like to run my OS being a USER - I'm running my own OS being ROOT). When I find some time, I will try to install Qtractor for one session and checking everything out. Since I have my own build of a very special GNU/Linux, it might cause some strange behavior compared to AV Linux?

We'll see...

Thanks.

Add new comment