jsbean / PitchSpelling

Repository containing musings related to the eighth-tone pitch spelling algorithm that shan't die.
MIT License
1 stars 1 forks source link

Complete an partially spelled pitch set #11

Open jsbean opened 8 years ago

jsbean commented 8 years ago

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]

mossheim commented 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).

jsbean commented 8 years ago

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.

mossheim commented 8 years ago

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.

jsbean commented 8 years ago

Totally. So, I'd say not to focus on this use case. But consider it a possibility down the line.

mossheim commented 8 years ago

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.