saebekassebil / teoria

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

Inverse Interval #48

Closed amitgur closed 10 years ago

amitgur commented 10 years ago

I need to implement an inverse interval

P4 -> P-5 m3 -> M-6

Any idea how to do it with the current implemented method, or some new method need to be written ?

saebekassebil commented 10 years ago

teoria is capable of this. Normally when we talk about interval inversion, we don't talk about inverting the interval direction, but inverting the absolute interval. Such that P4 -> P5, m3 -> M6, d5 -> A4, etc.

If you want to invert the direction as well, you just do that in another step. Directions are a bit awkward in teoria, since they're strings at the moment, but I've been thinking about making them booleans for easier toggling.

So inverting an interval is TeoriaInterval#invert() and changing an interval's direction is TeoriaInterval#direction()

var interval = teoria.interval('P4'); // or whatever other interval
var reverseInversion = interval.invert().direction(inveral.direction() == 'up' ? 'down' : 'up');

I hope this answered your question - do you have a better/simpler alternative to this method?

saebekassebil commented 10 years ago

Closing this as fixed - Please reopen if you feel this haven't been resolved properly.

amitgur commented 10 years ago

Thank you @saebekassebil this is very helpfull