123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #define __devloglevel__ 4
- #include "score.h"
- #include "ustjkeys.h"
- QtauScore::QtauScore(const QJsonArray& ust,TempoMap* tmap)
- {
- float lastNoteEndTime=0;
- for (int i = 0; i < ust.count(); ++i)
- {
- auto o = ust[i].toObject();
- if(!o.contains(NOTE_KEY_NUMBER)) {
- continue;
- }
- synthNote note;
- int noteOffset = o[NOTE_PULSE_OFFSET].toInt();
- int noteLength = o[NOTE_PULSE_LENGTH].toInt();
- QString lyric = o[NOTE_LYRIC].toString();
- int pitch = o[NOTE_KEY_NUMBER].toInt();
- float timeSt;
- float timeEd;
- int barSt;
- int barEd;
- int st = noteOffset;
- int ed = noteOffset+noteLength-1;
- tmap->getBar(st,timeSt,barSt,0);
- tmap->getBar(ed,timeEd,barEd,1);
- //int rest = noteOffset-lastNoteEnd;
- float rest = timeSt-lastNoteEndTime;
- if(rest<0) {
- // invalid=true;
- break;
- }
- note.rest = rest;
- note.start = timeSt;
- note.lenght = timeEd-timeSt;
- note.pitch = pitch;
- note.lyric = lyric;
- lastNoteEndTime = timeEd;
- notes.push_back(note);
- // noteCount++;
- }
- }
- int QtauScore::getNoteCount()
- {
- return notes.size();
- }
- synthNote QtauScore::getNote(int index)
- {
- return notes[index];
- }
|