M3: Measure Label-er

…released July 2012

TYPE: Generate
DEV/TESTED ON: Vista64/Audi126

  1. Creates labels for measures based on supplied measure length (up to six decimal spaces)
    and number of measures wanted (up to 420).
  2. Can measure a selection of audio and then create measure labels for it based on the
    user supplied number of measures. EXAMPLE: You know you have 4 measures, you highlight
    the 4 measures, you then put in [ 4 ] into “measures” on the plug-in, the plug-in then calculates
    the length of each measure.
  3. Also, both modes have ability to have labels printed for 16 “buttons” inside each measure,
    thus helpful if you program with a 16 step sequencer.
  4. 44.1 khz audio (for auto-measure)
  5. 420 measures
  6. 13.000000 seconds (for manual measure)

Some UI Notes:
MODE 1 = Auto-On (No Buttons)
MODE 2 = AUto-On (Buttons)
MODE 3 = Manual (No Buttons)
MODE 4 = Manual (Buttons)

Differences between 2.0 and 2.1:
Modified the code a bit to make changing the text Graphics for buttons a bit cooler.
Before, buttons would print out: #…
Now, they print out: #—=—=—=— (and can be modified more completely)
…this is so you can tell where the “bar” or 5th, 9th, 13th button are (or count it easier),
also it’s more useful for screenshots (which is the main reason I modified it).

2.1 Version:
M3-v02.1.NY (37.1 KB)
2.0 (OLD) Version:
M3-v02.0.NY (33.4 KB)

For a more general “measure labeller” that works at any sample rate, unlimited number of measures (bars) and user defined number of beats per bar, you may be interested in the “Beat Per Minute labels” plug-in: https://forum.audacityteam.org/t/beat-per-minute-labels/20785/1
You’ll notice that it is very much faster than “M3” so looking at the code of “Beat Per Minute labels” may provide some ideas for how to make “M3” more efficient.

Oww, you must have used that “format” command to change your numbers into text.
I thought about that too, but I got a bad feeling about it.

It continues to amaze me the ability of the modern computer to synthesize versus using
provided materials. For instance, the first arcade video games used synthesizers to create
music, and when I learned BASIC as a adolescent in the mid 1980s, the audio was all done
in a style of MIDI that also used synthesizers.

Seems odd that “modern” computing would start that way. Logically, creating something
from scratch takes much longer than using something supplied. But not our computers!
Our computers can create something from nothing, much faster and easier than using
supplied data.

Not sure how this is accomplished, or any possible side effects.

Yes. The format function is specifically designed for outputting as (formatted) text and is extremely useful.

Here’s a short (and extensively commented) plug-in to demonstrate a method of “converting” between numbers and strings:

;nyquist plug-in
;version 3
;type generate
;name "Text In and Out"
;info "Enter two numbers:"

;control text1 "First number by text input" string ""  
;control text2 "Second number by text input" string ""  

;;; Turns the input string into a stream that can then be read
;;; If the read value is a number, return the number
;;; else return nil.
(defun get-number (string)
  (let ((num (read (make-string-input-stream string))))
    (if (numberp num) num nil)))

(let ((a (get-number text1))    ;get the first value
      (b (get-number text2)))   ;get the second value
  (if (and a b)                 ;check that values are not nil
    ;; Create output string.
    ;; The value of each argument after the string is
    ;; substituted for the corresponding "~a".
    ;; ~% creates a new line.
    (format nil "~a x ~a = ~a" a b (* a b)) ;output result
    (format nil "Error.~%Two numbers must be entered."))) ;output error message

The format function is documented here: http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/xlisp/xlisp-ref/xlisp-ref-121.htm

I thought you might find this little plug-in interesting. It demonstrates a simple method of entering array data using the text input widget:

;nyquist plug-in
;version 3
;type generate
;name "Input Array"
;info "by Steve Daulton (www.easyspacepro.com).nnStrings must be either single quoted: 'textnor double quoted: ''Text''nDouble quoted text retain upper/lower case.nNumbers may be integers or floating point.n"

;control text "Enter numbers and/or quoted strings" string ""  

; set an error message in case evaluation fails:
(format nil "Error.~%all text input must be quoted.")
(setf myarray
  (eval (read (make-string-input-stream (format nil "(vector ~a)" text)))))
(format nil "An array has been created:~%~A" myarray)

Arrays. That’s on the list of computer things I dislike.
Many a day of my youth was spent entering note data into my Atari XL into arrays.
1 dimensional arrays, 2 dimensional arrays, 3 dimensional arrays
Never liked 'em.
I (however) have been working on text based databases to replace all of my
spreadsheets. There’s something about a text based spreadsheet with text
lines and bars, etc that is just so cool.
Never use a TAB though… :sunglasses:

Can’t really get away from them in Nyquist or LISP, it’s one of the basic data types. Stereo sounds are arrays, system variables are stored in an array, and arrays are one of the fundamental ways of accessing sounds. You may be pleased to know however that XLISP and Nyquist only support one dimensional arrays. If ever you need to use a multi-dimensional array you can “fake” it by nesting arrays within arrays.

I hope you like “lists” :sunglasses: