A simple “tuning fork” plug-in for Audacity, specifically for tuning a ukulele. This plug-in just generates a tone of the specified note, which is basically what a tuning fork does, except that a real (mechanical) tuning fork is restricted to just one frequency, whereas this plug-in allows you to select the required note.
Ukuleles are usually tuned to G, C, E, A, where the “G” is higher than the “C”. You could simply generate the tones with Audacity’s “Tone” generator, but this plug-in is probably easier. Rather than actually generating the notes into a track, the notes may be played using the “Preview” button.
How it works
;name "Ukelele Tuner"
;author "Steve Daulton"
;copyright "GPL v2+."
;control note "Note" choice "G,C,E,A" 0
;control dur "Length (seconds)" int "" 5 1 30
(let ((env (pwlv 0 0.1 0.8 (- dur 0.2) 0.8 dur)))
(0 (mult env (osc G5 dur)))
(1 (mult env (osc C5 dur)))
(2 (mult env (osc E5 dur)))
(t (mult env (osc A5 dur)))))
As usual, we start with the Nyquist plug-in “headers”. (More about plug-in headers HERE), then two “controls”: The first for selecting the required note, and the second to select the length of the note that will be generated (more about Nyquist plug-in control widgets HERE). Note that when using the “Preview” button, the length of the preview is limited by Audacity’s Preference setting – See: “Preferences > Playback > Effects Preview“.
The main code block is a “LET” block, the first line of which binds the result of a PWLV command to the variable “env”.
“PWLV” is one of a set of commands for creating slowly moving control signals. Each of the commands take a list “coordinates” (“time” and “value” pairs). The resulting signal interpolates between each of the coordinates to produce a control signal at 1/20th of the track’s sample rate (the “control rate”). A low sample rate is often best for control signals as they require much less memory when stored than normal “sounds”. More information about piece-wise approximations can be found HERE.
In this case, the control points for the envelope “env” are at:
- time = 0, value = 0
- time = 0.1, value = 0.8
- time = “duration” – 0.2, value = 0.8
- time = “duration”, value = 0
“duration” is set by the second control widget.
Thus, “env” is a control signal that rises from zero to 0.8 in the first 0.1 seconds, remains at a level of 0.8 until almost the end, then in the final 0.2 seconds it falls back to zero.
The “CASE” command is another block structure. It looks at the value of the variable “note” (set by the first control widget), and runs different code depending on the value of “note”. More information about “CASE” can be found HERE.
Because the first control widget has 4 choices, the variable “note” will have a value between 0 and 3 inclusive. Depending on the value, a tone is generated using the “OSC” command. More information about the OSC command can be found HERE.
The “MULT” command multiplies the control envelope with the generated tone, shaping the tone so that it has a short fade-in and a slightly longer fade-out.