YMZ294 Player. modified from "Yamaguchi's YMZ294 Library" for LPC1114.

Dependencies:   mbed

Committer:
kohacraft
Date:
Wed Dec 09 01:38:08 2015 +0000
Revision:
0:7a56bf0441ea
YMZ294 Player. modified from "Yamaguchi's YMZ294 Library" for LPC1114

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kohacraft 0:7a56bf0441ea 1 #include "MusicString.h"
kohacraft 0:7a56bf0441ea 2
kohacraft 0:7a56bf0441ea 3 MusicString::MusicString(const char *s) : mstring(s), current(s) {
kohacraft 0:7a56bf0441ea 4 }
kohacraft 0:7a56bf0441ea 5
kohacraft 0:7a56bf0441ea 6 MusicString::MusicString(const MusicString& ms) : mstring(ms.mstring), current(ms.mstring) {
kohacraft 0:7a56bf0441ea 7 }
kohacraft 0:7a56bf0441ea 8
kohacraft 0:7a56bf0441ea 9 bool MusicString::isNull() {
kohacraft 0:7a56bf0441ea 10 return current == 0;
kohacraft 0:7a56bf0441ea 11 }
kohacraft 0:7a56bf0441ea 12
kohacraft 0:7a56bf0441ea 13 void MusicString::rewind() {
kohacraft 0:7a56bf0441ea 14 current = mstring;
kohacraft 0:7a56bf0441ea 15 }
kohacraft 0:7a56bf0441ea 16
kohacraft 0:7a56bf0441ea 17 Note MusicString::getNextNote() {
kohacraft 0:7a56bf0441ea 18 if (hasMoreNote()) {
kohacraft 0:7a56bf0441ea 19 char buf[16];
kohacraft 0:7a56bf0441ea 20 int i = 0;
kohacraft 0:7a56bf0441ea 21 do {
kohacraft 0:7a56bf0441ea 22 buf[i++] = *current++;
kohacraft 0:7a56bf0441ea 23 } while (*current && *current > ' ' && *current != '|' && *current != '(' && *current != ')');
kohacraft 0:7a56bf0441ea 24 buf[i] = 0;
kohacraft 0:7a56bf0441ea 25 return Note(buf);
kohacraft 0:7a56bf0441ea 26 } else
kohacraft 0:7a56bf0441ea 27 return Note();
kohacraft 0:7a56bf0441ea 28 }
kohacraft 0:7a56bf0441ea 29
kohacraft 0:7a56bf0441ea 30 bool MusicString::hasMoreNote() {
kohacraft 0:7a56bf0441ea 31 while (*current && *current <= ' ' || *current == '|' || *current == '(' || *current == ')')
kohacraft 0:7a56bf0441ea 32 current++;
kohacraft 0:7a56bf0441ea 33 return (*current);
kohacraft 0:7a56bf0441ea 34 }