Initial
This commit is contained in:
80
music/emitter.cpp
Normal file
80
music/emitter.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include <music/emitter.hpp>
|
||||
#include <music/scansymbols.hpp>
|
||||
#include <common/stringbuffer.hpp>
|
||||
|
||||
namespace Music
|
||||
{
|
||||
|
||||
void Emitter::emit(const Byte &byte,const String &value)
|
||||
{
|
||||
int length(value.length());
|
||||
insert(&byte);
|
||||
insert(&Byte(length));
|
||||
for(int index=0;index<length;index++)insert(&Byte(value.charAt(index)));
|
||||
}
|
||||
|
||||
void Emitter::emit(const Byte &byte)
|
||||
{
|
||||
insert(&byte);
|
||||
}
|
||||
|
||||
String Emitter::toString(void)const
|
||||
{
|
||||
StringBuffer sb;
|
||||
String verb;
|
||||
int length;
|
||||
int i;
|
||||
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
switch(((Emitter&)*this).operator[](index))
|
||||
{
|
||||
case ScanSymbols::Note1 :
|
||||
sb.append("Note='").append((char)((Emitter&)*this).operator[](++index)).append("'\n");
|
||||
break;
|
||||
case ScanSymbols::HalfDiminished1 :
|
||||
sb.append("Half Diminished").append("\n");
|
||||
break;
|
||||
case ScanSymbols::Degree1 :
|
||||
sb.append("Degree=").append(String().fromInt((int)((Emitter&)*this).operator[](index+1))).append("\n");
|
||||
index++;
|
||||
break;
|
||||
case ScanSymbols::Alter1 :
|
||||
sb.append("Altered=");
|
||||
if(ScanSymbols::Flat1==((Emitter&)*this).operator[](index+1))sb.append("Flat");
|
||||
else if(ScanSymbols::Sharp1==((Emitter&)*this).operator[](index+1))sb.append("Sharp1");
|
||||
sb.append("\n");
|
||||
index++;
|
||||
break;
|
||||
case ScanSymbols::Verb1 :
|
||||
sb.append("Verb='");
|
||||
index++;
|
||||
length=((Emitter&)*this).operator[](index);
|
||||
verb.reserve(length+1);
|
||||
index++;
|
||||
for(i=0;i<length;i++)verb.setAt(i,((Emitter&)*this).operator[](index++));
|
||||
sb.append(verb);
|
||||
sb.append("'\n");
|
||||
break;
|
||||
case ScanSymbols::Slash1 :
|
||||
sb.append("Slash\n");
|
||||
index++;
|
||||
break;
|
||||
case ScanSymbols::Flat1 :
|
||||
sb.append("Flat\n");
|
||||
index++;
|
||||
break;
|
||||
case ScanSymbols::Major71 :
|
||||
sb.append("Major 7\n");
|
||||
break;
|
||||
case ScanSymbols::Minor1 :
|
||||
sb.append("Minor\n");
|
||||
break;
|
||||
case ScanSymbols::Stop1 :
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user