Inaccuracy in Click Track

It was noticed by Frankelstner that for some settings, Click Track produced a cumulative error on the bar length. (original post here: )

As a fix, he proposed changing lines 303 - 304 from:

(dotimes (x (- measures 1))
  (setf result (seq result measure)))


(dotimes (x (- measures 1))
  (setf result (sim result(at (* (+ x 1) sig beatlen) (cue measure)))))

This fix will work, but makes line numbers 272 - 273 redundant so I propose removing those lines and adding on the required trailing silence to complete the bar length at the end.

While working on this I noticed that the error checking of user input was in the form of:
“If not an error, set the error to the existing error, else (if it isn’t “not an error”), add an error message”.

I’ve updated most of these to the form:
“If error, add an error message”.

The initial fix of the inaccuracy issue is implemented in this version.

Current (recommended) version: clicktrack.ny

Gale suggested to update the comment block to include the GPL licence information, and to allow fractional BPM in the Tempo field.
These have now been added in my current version. I’ve also taken this opportunity to do a general tidy-up of the code, and in doing so I’ve spotted a few other errors, so I’ll fix those at the same time and post a revised version shortly.

There was also an error with the “tick” setting. This uses the “drip” function:

; function to generate drip sound clicks
; code by Paul Beach
; stretch-abs function makes this sound more like 'tick' sounds
(defun drip (p) ; p is pitch in hz
(stretch 1
(mult (exp-dec 0 0.015 0.25) 
( sim
(mult (hzosc (*  2.40483  p))  0.5 )
(mult (hzosc (*  5.52008  p))  0.25 )
(mult (hzosc (* 8.653  p))  0.125 )
(mult (hzosc (* 11.8  p))  0.0625 )

The comment says “; stretch-abs function makes this sound more like ‘tick’ sounds”, but then the code uses (stretch) rather than (stretch-abs) which makes the ticks too short. I assume that the comment was what was intended so I’ve corrected this which makes the “tick” sound the correct length (though it sounds a bit different to the previous version).

Also, the “drip” function may produce aliasing if the MIDI pitch is set too high for the current track sample rate, so I’ve limited the maximum frequency to a little less than the Nyquist frequency.

; function to generate drip sound clicks
; code by Paul Beach
; stretch-abs function makes this sound more like 'tick' sounds.
; limit hz to nyquist frequency.
(defun drip (p) ; p is pitch in hz
	(let* ((maxhz (/ *sound-srate* 2.1))
				(hz1 (min maxhz (* 2.40483  p)))
				(hz2 (min maxhz (* 5.52008  p)))
				(hz3 (min maxhz (* 8.653  p)))
				(hz4 (min maxhz (* 11.8  p))))
			(stretch-abs 1
				(mult (exp-dec 0 0.015 0.25) 
						(mult (hzosc hz1) 0.5)
						(mult (hzosc hz2)  0.25)
						(mult (hzosc hz3)  0.125)
						(mult (hzosc hz4)  0.0625))))

The total length of a click track should now be accurate to within a couple of samples for all settings. (track length is always rounded up to a whole number of bars).

I think this should be the final version unless I’ve made any new errors.

clicktrack2.ny (9.66 KB)
Current (recommended) version: clicktrack.ny

This seems to work flawlessly. When twiddling with all the different settings it would always return exactly what I expected. And good work on tidying the code too. :slight_smile:

Thanks for testing.

Thank you very much for submiting the correction.

It’s my first post on this forum as I have created an account specially to ask for help with Click Track. My drummer asked for the metronome with no accents on first sound, then I noticed the innacuracy…

Second version worked OK for me. I checked and it seems to be sample-to sample acurate. Thanks again!


Set it to 1 beat per bar.

This is what I did. It was just the “background story” - my problem was the wrong timing that I noticed after changing the beat per bar setting.

Now it works good.

Which was of course a bit more noticeable with one beat per bar - yes I’m with you now :wink:

Thanks for the feedback. Hopefully this new version will be included in the next Audacity release.

Actually, what I noticed was that the timing was slightly different, depending on beat per bar setting.

By the way I was a little surprised that Audacity does not run any kind of bugzilla site, where I could report my bug.

Actually there is a Bugzilla site. The “Contact” page on the main Audacity website has a bug reporting section that provides an e-mail link, a link to this forum, links to the release notes and a link to the “Reporting Bugs” page of the Audacity wiki.

For most users it is far more convenient if bugs are either reported via the e-mail address or via this forum. I would estimate that less than one out of a hundred “bugs” reported here on the forum are actually Audacity bugs. Out of those that really are bugs, the majority are known issues that are already release noted both in the “ReadMe” file that is included with the software (which of course hardly anyone reads :wink: ) and in the Release Notes on the wiki. It therefore make more sense (and is a lot more economical for the limited manpower) if people report issues in the first instance to either the e-mail address or here on the forum.

Another nice bonus of using the forum rather than Bugzilla is that issues can be discussed more easily with the to and fro dialogue, so that when a report is submitted to Bugzilla, it will (hopefully) be a clear description of the bug with precise steps to reproduce. This makes it a lot easier for the developers to pinpoint and fix the issue.

Of course you don’t have to be reporting a bug to come to the forum. You’re more than welcome to drop in any time to discuss any issues relating to Audacity, whether it’s asking for suggestions, or helping other users with their questions, suggesting future enhancements to the program, or passing on your own recording/editing tips. So hopefully see you around again :wink:

Updated Click Track plug-in.
This version is a drop in replacement for the version included with Audacity 1.3.x

All bugs in the standard Audacity version should be fixed in this version.
The character spacing in the code has been updated in this version to conform with LISP programming standards.

Unfortunately this version has not yet been included in the standard release version of Audacity 1.3.13 and will not be in Audacity 1.3.14 as the developers have been too busy fixing some more serious bugs.

clicktrack.ny (9.93 KB)

Missed one - now fixed.

I’ve also made the progress bar functional in this version.
This version has now been accepted into the official Audacity code, so it will be available in Audacity 1.3.15 (or whatever the next version is called).
clicktrack.ny (10 KB)