Skip to content

Commit 15ce977

Browse files
committed
finish off parse/unparse for fieldeditors
1 parent cd0363c commit 15ce977

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

fieldeditors.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@ namespace microcode {
242242
return result
243243
}
244244

245+
function notesToMelody(txt: string) {
246+
const seq = txt.split(" ")
247+
let res = ""
248+
seq.forEach((note, index) => {
249+
if (note == "-") res += "."
250+
else res += noteNames.indexOf(note).toString
251+
})
252+
return { notes: res, tempo: 120 }
253+
}
254+
245255
export const MELODY_LENGTH = 4
246256
export const NUM_NOTES = 5
247257

@@ -302,8 +312,7 @@ namespace microcode {
302312
return melodyToNotes(melody)
303313
}
304314
fromText(txt: string): Melody {
305-
// TODO
306-
return undefined
315+
return notesToMelody(txt)
307316
}
308317
}
309318

0 commit comments

Comments
 (0)