Open jsbean opened 8 years ago
Hmmmm, interesting problem. Could partially-spelled elements be a possibility? For instance, the spelled pitch (0.25, C, nil, nil), which could be spelled either as (0.25, C, nat., up), (0.25, C, q-sharp, down).
Hmmmm, that hasn't cropped up in my use cases, but I can very easily imagine scenarios where that would be helpful.
For example, I am imagining a scenario where a performer would want to dynamically respell a pitch, or chord, and might select the staff-location (letterName
) of a note, and the options, sorted by score, are presented automatically.
I'd say that's would be a second extension, building up from the first.
Ok! Good to know. I can't imagine that it would be a very frequent occurrence, since eighth-tone intervals are the only ones that have two possible spellings from a given letter name.
Totally. So, I'd say not to focus on this use case. But consider it a possibility down the line.
Just made the update, haven't tested it rigorously but it seems to work. Example:
input: [ 0, 0.75, 1.5, 2.25, 3, 3.75 ] output:
best graphs (cost 24):
1 - [ C (0), C# dn (0.75), Dd (1.5), Dt dn (2.25), Eb (3), E dn (3.75) ]
2 - [ C (0), C# dn (0.75), Dd (1.5), D up (2.25), Eb (3), E dn (3.75) ]
------------
time to run: 0.011008569003025 seconds.
input: [ 0, 0.75, 1.5, D up (2.25), 3, 3.75 ] output:
best graphs (cost 24):
1 - [ C (0), C# dn (0.75), Dd (1.5), D up (2.25), Eb (3), E dn (3.75) ]
------------
time to run: 0.0053342350001913 seconds.
This is for once we've got a solid algorithm running for completely unspelled pitch set, but I am just gonna put this here.
Given a pitch set that has some of its elements spelled coming in, choose the best spelling for the set.
E.g.,
[(.e, .flat), 0.25, 2.5]