const FrequencyTable = {
"''A":27.5, "''B":29.1, "''H":30.9,
"'C":32.7, "'Des":34.7, "'D":36.7, "'Es":38.9, "'E":41.2, "'F":43.7,
"'Ges":46.3, "'G":49.0, "'As":51.9, "'A":55.0, "'B":58.3, "'H":61.7,
"C":65.4, "Des":69.3, "D":73.4, "Es":77.8, "E":82.4, "F":87.3,
"Ges":92.5, "G":98.0, "As":104, "A":110, "B":117, "H":123,
"c":131, "des":139, "d":147, "es":156, "e":165, "f":175,
"ges":185, "g":196, "as":208, "a":220, "b":233, "h":247,
"c'":262, "des'":277, "d'":294, "es'":311, "e'":330, "f'":349,
"ges'":370, "g'":392, "as'":415, "a'":440, "b'":466, "h'":494,
"c''":523, "des''":554, "d''":587, "es''":622, "e''":659, "f''":698,
"ges''":740, "g''":784, "as''":831, "a''":880, "b''":932, "h''":988,
"c'''":1047, "des'''":1109, "d'''":1175, "es'''":1245, "e'''":1319, "f'''":1397,
"ges'''":1480, "g'''":1568, "as'''":1661, "a'''":1760, "b'''":1865, "h'''":1976,
"c''''":2093, "des''''":2217, "d''''":2349, "es''''":2489, "e''''":2637, "f''''":2794,
"ges''''":2960, "g''''":3136, "as''''":3322, "a''''":3520, "b''''":3729, "h''''":3951,
"c'''''":4186
};
const DurationTable = {
'/1':1000, '/2':500, '/4':250, '/8':125
}
function pause (Length) {
return new Promise ((resolve,reject) => {
setTimeout(resolve, DurationTable[Length || ''] || 50);
})
}
function playTone (Tone, Length) {
return Bangle.beep(DurationTable[Length], FrequencyTable[Tone]).then(() => pause)
}
let ToneScale = []
for (let Tone in FrequencyTable) {
if (FrequencyTable.hasOwnProperty(Tone)) {
ToneScale.push(Tone);
}
}
function playNextTone () {
let Tone = ToneScale.shift();
if (Tone != null) {
playTone(Tone,'/4').then(playNextTone)
}
}
playNextTone();