allow for double, breve note durations

This commit is contained in:
Peli de Halleux 2016-11-30 16:06:17 -08:00
parent 47ef096b0f
commit af8ce3fccf
2 changed files with 16 additions and 6 deletions

View File

@ -9,6 +9,8 @@
"AcceleratorRange.TwoG|block": "2g",
"BaudRate.BaudRate115200|block": "115200",
"BaudRate.BaudRate9600|block": "9600",
"BeatFraction.Breves|block": "4",
"BeatFraction.Double|block": "2",
"BeatFraction.Eighth|block": "1/8",
"BeatFraction.Half|block": "1/2",
"BeatFraction.Quarter|block": "1/4",

View File

@ -119,7 +119,11 @@ enum BeatFraction {
//% block="1/8"
Eighth = 8,
//% block="1/16"
Sixteenth = 16
Sixteenth = 16,
//% block="2"
Double = 32,
//% block="4",
Breve = 64
}
/**
@ -188,11 +192,15 @@ namespace music {
init();
if (fraction == null) fraction = BeatFraction.Whole;
let beat = 60000 / beatsPerMinute;
if (fraction == BeatFraction.Whole) return beat;
else if (fraction == BeatFraction.Half) return beat / 2;
else if (fraction == BeatFraction.Quarter) return beat / 4
else if (fraction == BeatFraction.Eighth) return beat / 8;
else return beat / 16;
switch (fraction) {
case BeatFraction.Half: return beat / 2;
case BeatFraction.Quarter: return beat / 4;
case BeatFraction.Eighth: return beat / 8;
case BeatFraction.Sixteenth: return beat / 16;
case BeatFraction.Double: return beat * 2;
case BeatFraction.Breve: return beat * 4;
default: return beat;
}
}
/**