saebekassebil / teoria

Javascript taught Music Theory
http://saebekassebil.github.io/teoria
MIT License
1.32k stars 114 forks source link

Note accidental gets 'undefined' sometimes (accidentalValue() > 2) #107

Open eagor opened 8 years ago

eagor commented 8 years ago
var scale = teoria.scale("cx", 'wholetone');
scale.simple();
> ["cx", "dx", "ex", "fundefined", "gundefined", "aundefined"]

I suspect this is a result of Note#accidental()

scale.notes()[3].accidentalValue()
> 3
scale.notes()[3].accidental()
> undefined

But the accidentalValue should not be greater than 2. If it is, then it should be another note name. Thus I think the root of the issue is in the way the intervals are calculated, particularly, how it finds the note that is some interval away from another note (from scale tonic in our case).

eagor commented 8 years ago

so this is it:

teoria.note("cx").interval("A4").toString()
>"fundefined3"

but seems to be like note name has to be F (as 4th note after C) what does music theory has to answer to this: C## + A4 = ?

saebekassebil commented 8 years ago

Yes. that's the problem. I don't think there's an answer for that - since we generally speaking never deal in "triple accidentals" like that.

I think throwing an error would be best - since you're trying to do something "impossible"