Created
October 25, 2022 05:29
-
-
Save colinfwren/4e5443408a8eb2c740262ff324197232 to your computer and use it in GitHub Desktop.
reverse power time signature resolve
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function getTimeSignatureinSemiQuavers(timeSignature: MidiTimeSignatureEvent): TimeSignatureValues { | |
const { numerator, denominator } = timeSignature | |
const deltaFromSemiQuaver = 4 - denominator | |
if (deltaFromSemiQuaver > 0) { | |
return Array(deltaFromSemiQuaver).fill(0).reduce((agg) => { | |
return { | |
numerator: agg.numerator * 2, | |
denominator: agg.denominator * 2 | |
} | |
}, { numerator, denominator: 2**denominator }) | |
} else if (deltaFromSemiQuaver < 0) { | |
return Array(Math.abs(deltaFromSemiQuaver)).fill(0).reduce((agg) => { | |
return { | |
numerator: agg.numerator / 2, | |
denominator: agg.denominator / 2 | |
} | |
}, { numerator, denominator: 2**denominator }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment