On 2021-03-30 5:30 pm, Callum Cassidy-Nolan wrote:
[...]
I would love to use it, but I have a particular way I interact with
music.
Particularly I don't use letter names, but instead I use numbers, to
understand what I mean, please take a look at my document:
https://gitlab.com/cuppajoeman/music/-/blob/master/diagrams/standard_to_semitones.pdf
I just saw a basic example in the documentation, something like this:
\version "2.22.0"
{
c' e' g' e'
}
In my system I would write something like this:
\version "2.22.0"
{
0' 4' 7' 4'
}
[...]
Not sure why I have done this, but here are some rather horrendous*
things that can be accomplished entirely within LilyPond so as to not
require pre-processing:
(* This is entering the nearly indecipherable territory of esoteric
languages.)
%%%%
\version "2.22.0"
%% -----
%% Option 1:
%% Use a procedure to convert a number to pitch:
#(define (: n)
(apply
ly:make-pitch
(cons (1- (floor (/ n 12)))
(list-ref `((0 0) (0 ,SHARP) (1 0) (1 ,SHARP)
(2 0) (3 0) (3 ,SHARP) (4 0)
(4 ,SHARP) (5 0) (5 ,SHARP) (6 0))
(modulo n 12)))))
{ $(: 0)' 8. $(: 9) 16 $(: 2)' $(: 6)' $(: 9)' 8 $(: 4)'' 2 }
%% Pros:
%% - Values outside the interval [0,11] work.
%% - Octave marks can appear snugly next to the expression.
%% Cons:
%% - Requires five extra characters to input than the number,
%% assuming the procedure is named with a single character.
%% -----
%% Option 2:
%% Define appropriately named variables with pitches:
defineNoteIndices =
#(define-void-function
(music) (ly:music?)
(let ((pitches (music-pitches music)))
(for-each
(lambda (idx pitch)
(module-define! (current-module)
(string->symbol (format #f ":~a" idx)) pitch))
(iota (length pitches))
pitches)))
\defineNoteIndices { c cis d dis e f fis g gis a ais b }
{ $:0 ' 8. $:9 16 $:2 ' $:6 ' $:9 ' 8 $:4 '' 2 }
%% Pros:
%% - Can work with as many or as few notes as needed.
%% (Think of pentatonic music without alterations.)
%% - Easier to customize as pitches are entered naturally.
%% - Only two additional characters to input a pitch*.
%% Cons:
%% - Only supports exactly as many indices as defined.
%% - Whitespace needed between pitch and octave mark.
%% * So potentially, three additional characters needed.
%% -----
%%%%
NOTE: I only used a colon above as it was not yet a defined symbol.
However, colons are used in LilyPond syntax as the short-hand for
tremolo repeats. So, almost certainly a different character would be
better.
-- Aaron Hill