Skip to content

Commit

Permalink
more ove fixes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioBL committed Apr 29, 2015
1 parent e5b5aef commit 5d4d203
Show file tree
Hide file tree
Showing 36 changed files with 2,587 additions and 70 deletions.
76 changes: 63 additions & 13 deletions mscore/importove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ void OveToMScore::convertSignatures(){
}

// Tempo
std::map<int, int> tempos;
std::map<int, double> tempos;
for(i=0; i<ove_->getPartCount(); ++i){
int partStaffCount = ove_->getStaffCount(i);

Expand All @@ -892,25 +892,25 @@ void OveToMScore::convertSignatures(){

if(k==0 || ( k>0 && qAbs(measure->getTypeTempo()-ove_->getMeasure(k-1)->getTypeTempo())>0.01 )){
int tick = mtt_->getTick(k, 0);
tempos[tick] = (int)measure->getTypeTempo();
tempos[tick] = measure->getTypeTempo();
}

for(int l=0; l<tempoPtrs.size(); ++l) {
OVE::Tempo* ptr = static_cast<OVE::Tempo*>(tempoPtrs[l]);
int tick = mtt_->getTick(measure->getBarNumber()->getIndex(), ptr->getTick());
int tempo = ptr->getQuarterTempo()>0 ? ptr->getQuarterTempo() : 1;
double tempo = ptr->getQuarterTempo()>0 ? ptr->getQuarterTempo() : 1.0;

tempos[tick] = tempo;
}
}
}
}

std::map<int, int>::iterator it;
std::map<int, double>::iterator it;
int lastTempo = 0;
for(it=tempos.begin(); it!=tempos.end(); ++it) {
if( it==tempos.begin() || (*it).second != lastTempo ) {
double tpo = ((double)(*it).second) / 60.0;
double tpo = ((*it).second) / 60.0;
score_->setTempo((*it).first, tpo);
}

Expand Down Expand Up @@ -1288,12 +1288,57 @@ void OveToMScore::convertMeasureMisc(Measure* measure, int part, int staff, int
OVE::Tempo* tempoPtr = static_cast<OVE::Tempo*>(tempos[i]);
TempoText* t = new TempoText(score_);
int absTick = mtt_->getTick(measure->no(), tempoPtr->getTick());
double tpo = ((double)tempoPtr->getQuarterTempo())/60.0;
double tpo = (tempoPtr->getQuarterTempo())/60.0;

score_->setTempo(absTick, tpo);

t->setTempo(tpo);
t->setPlainText(tempoPtr->getRightText());
QString durationTempoL;
QString durationTempoR;
if ((int)(tempoPtr->getLeftNoteType()))
durationTempoL = TempoText::duration2tempoTextString(OveNoteType_To_Duration(tempoPtr->getLeftNoteType()));
if ((int)(tempoPtr->getRightNoteType()))
durationTempoR = TempoText::duration2tempoTextString(OveNoteType_To_Duration(tempoPtr->getRightNoteType()));
QString textTempo;
if (tempoPtr->getShowBeforeText())
textTempo += (tempoPtr->getLeftText()).toHtmlEscaped();
if (tempoPtr->getShowMark()) {
if (!textTempo.isEmpty())
textTempo += " ";
if (tempoPtr->getShowParenthesis())
textTempo += "(";
textTempo += durationTempoL;
if (tempoPtr->getLeftNoteDot())
textTempo += "<sym>space</sym><sym>unicodeAugmentationDot</sym>";
textTempo += " = ";
switch (tempoPtr->getRightSideType()) {
case 1:
textTempo += durationTempoR;
if (tempoPtr->getRightNoteDot())
textTempo += "<sym>space</sym><sym>unicodeAugmentationDot</sym>";
break;
case 2:
textTempo += (tempoPtr->getRightText()).toHtmlEscaped();
break;
case 3:
textTempo += QString::number(qFloor(tempoPtr->getTypeTempo()));
break;
case 0:
default:
textTempo += QString::number(tempoPtr->getTypeTempo());
break;
}
if (tempoPtr->getShowParenthesis())
textTempo += ")";
}
if (textTempo.isEmpty()) {
textTempo = durationTempoL;
if (tempoPtr->getLeftNoteDot())
textTempo += "<sym>space</sym><sym>unicodeAugmentationDot</sym>";
textTempo += " = " + QString::number(tempoPtr->getTypeTempo());
t->setVisible(false);
}
t->setXmlText(textTempo);
t->setAbove(true);
t->setTrack(track);

Expand Down Expand Up @@ -1404,18 +1449,20 @@ void OveToMScore::convertNotes(Measure* measure, int part, int staff, int track)
cr->setDurationType(duration);
cr->setTrack(noteTrack);
cr->setVisible(container->getShow());
Segment* s = measure->getSegment(cr, tick);
s->add(cr);

QList<OVE::Note*> notes = container->getNotesRests();
for (j = 0; j < notes.size(); ++j) {
OVE::Note* notePtr = notes[j];
if(!isRestDefaultLine(notePtr, container->getNoteType()) && notePtr->getLine() != 0) {
double yOffset = -((double)notePtr->getLine()/2.0 * score_->spatium());
int stepOffset = cr->staff()->staffType()->stepOffset();
int lineOffset = static_cast<Ms::Rest*>(cr)->computeLineOffset();
yOffset -= (qreal(lineOffset + stepOffset) * .5) * score_->spatium();
cr->setUserYoffset(yOffset);
}
}

Segment* s = measure->getSegment(cr, tick);
s->add(cr);
}
else {
QList<OVE::Note*> notes = container->getNotesRests();
Expand Down Expand Up @@ -1494,7 +1541,8 @@ void OveToMScore::convertNotes(Measure* measure, int part, int staff, int track)
if(drumset != 0) {
if (!drumset->isValid(pitch) || pitch == -1) {
qDebug("unmapped drum note 0x%02x %d", note->pitch(), note->pitch());
} else {
}
else {
note->setHeadGroup(drumset->noteHead(pitch));
int line = drumset->line(pitch);
note->setLine(line);
Expand All @@ -1503,7 +1551,8 @@ void OveToMScore::convertNotes(Measure* measure, int part, int staff, int track)
setDirection = true;
}
}
} else {
}
else {
const int OCTAVE = 7;
OVE::ToneType clefMiddleTone;
int clefMiddleOctave;
Expand Down Expand Up @@ -1549,7 +1598,8 @@ void OveToMScore::convertNotes(Measure* measure, int part, int staff, int track)
}

// beam
Beam::Mode bm = container->getIsRest() ? Beam::Mode::NONE : Beam::Mode::AUTO;
//Beam::Mode bm = container->getIsRest() ? Beam::Mode::NONE : Beam::Mode::AUTO;
Beam::Mode bm = Beam::Mode::NONE;
if(container->getInBeam()){
OVE::MeasurePos pos = container->start()->shiftMeasure(0);
OVE::MusicData* data = getCrossMeasureElementByPos(part, staff, pos, container->getVoice(), OVE::MusicDataType::Beam);
Expand Down
115 changes: 76 additions & 39 deletions mscore/ove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2576,6 +2576,9 @@ Tempo::Tempo() {
rightText_ = QString();
swingEighth_ = false;
rightNoteType_ = 3;
leftNoteDot_ = false;
rightNoteDot_ = false;
rightSideType_ = 0;
}

void Tempo::setLeftNoteType(int type) {
Expand Down Expand Up @@ -2610,17 +2613,19 @@ bool Tempo::getShowParenthesis() const {
return showParenthesis_;
}

void Tempo::setTypeTempo(int tempo) {
void Tempo::setTypeTempo(double tempo) {
typeTempo_ = tempo;
}

int Tempo::getTypeTempo() const {
double Tempo::getTypeTempo() const {
return typeTempo_;
}

int Tempo::getQuarterTempo() const {
double Tempo::getQuarterTempo() const {
double factor = pow(2.0, int(NoteType::Note_Quarter) - int(getLeftNoteType()));
int tempo = int((double) getTypeTempo() * factor);
if (getLeftNoteDot())
factor *= 3.0/2.0;
double tempo = getTypeTempo() * factor;

return tempo;
}
Expand Down Expand Up @@ -2653,8 +2658,32 @@ void Tempo::setRightNoteType(int type) {
rightNoteType_ = type;
}

int Tempo::getRightNoteType() const {
return rightNoteType_;
NoteType Tempo::getRightNoteType() const {
return (NoteType) rightNoteType_;
}

void Tempo::setLeftNoteDot(bool showDot) {
leftNoteDot_ = showDot;
}

bool Tempo::getLeftNoteDot() const {
return leftNoteDot_;
}

void Tempo::setRightNoteDot(bool showDot) {
rightNoteDot_ = showDot;
}

bool Tempo::getRightNoteDot() const {
return rightNoteDot_;
}

void Tempo::setRightSideType(int type) {
rightSideType_ = type;
}

int Tempo::getRightSideType() const {
return rightSideType_;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -4718,15 +4747,14 @@ bool BarsParse::parseTempo(MeasureData* measureData, int /*length*/) {

Tempo* tempo = new Tempo();
measureData->addMusicData(tempo);

if( !jump(3) ) { return false; }

if( !jump(3) )
return false;
// common
if( !parseCommonBlock(tempo) ) { return false; }

if( !readBuffer(placeHolder, 1) ) { return false; }
if( !parseCommonBlock(tempo) )
return false;
if( !readBuffer(placeHolder, 1) )
return false;
thisByte = placeHolder.toUnsignedInt();

// show tempo
tempo->setShowMark( (getHighNibble(thisByte) & 0x4) == 0x4 );
// show before text
Expand All @@ -4735,47 +4763,56 @@ bool BarsParse::parseTempo(MeasureData* measureData, int /*length*/) {
tempo->setShowParenthesis( (getHighNibble(thisByte) & 0x1 ) == 0x1 );
// left note type
tempo->setLeftNoteType( getLowNibble(thisByte) );

if( !jump(1) ) { return false; }

// left note dot
tempo->setLeftNoteDot((getHighNibble(thisByte) & 0x2 ) == 0x2 );
if( !jump(1) ) // dimension of the note symbol
return false;
if( ove_->getIsVersion4() ) {
if( !jump(2) ) { return false; }

if( !jump(2) )
return false;
// tempo
if( !readBuffer(placeHolder, 2) ) { return false; }
tempo->setTypeTempo(placeHolder.toUnsignedInt()/100);
} else {
if( !readBuffer(placeHolder, 2) )
return false;
tempo->setTypeTempo(((double)placeHolder.toUnsignedInt())/100.0);
}
else {
// tempo
if( !readBuffer(placeHolder, 2) ) { return false; }
tempo->setTypeTempo(placeHolder.toUnsignedInt());

if( !jump(2) ) { return false; }
if( !readBuffer(placeHolder, 2) )
return false;
tempo->setTypeTempo((double)placeHolder.toUnsignedInt());
if( !jump(2) )
return false;
}

// offset
if( !parseOffsetElement(tempo) ) { return false; }

if( !jump(16) ) { return false; }

if( !parseOffsetElement(tempo) )
return false;
if( !jump(16) )
return false;
// 31 bytes left text
if( !readBuffer(placeHolder, 31) ) { return false; }
if( !readBuffer(placeHolder, 31) )
return false;
tempo->setLeftText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));

if( !readBuffer(placeHolder, 1) ) { return false; }
if( !readBuffer(placeHolder, 1) )
return false;
thisByte = placeHolder.toUnsignedInt();

// swing eighth
tempo->setSwingEighth(getHighNibble(thisByte)!=8);

tempo->setSwingEighth((getHighNibble(thisByte) & 0x4 ) == 0x4 );
// right note dot
tempo->setRightNoteDot((getHighNibble(thisByte) & 0x1 ) == 0x1 );
// compatibility with v3 files ?
tempo->setRightSideType((int)(getHighNibble(thisByte) & 0x2));
// right note type
tempo->setRightNoteType(getLowNibble(thisByte));

// right text
if( ove_->getIsVersion4() ) {
if( !readBuffer(placeHolder, 31) ) { return false; }
if( !readBuffer(placeHolder, 31) )
return false;
tempo->setRightText(ove_->getCodecString(placeHolder.fixedSizeBufferToStrByteArray()));

if( !jump(1) ) { return false; }
if( !readBuffer(placeHolder, 1) )
return false;
// 00 -> float 03 -> integer(floor) 01 -> notetype 02 -> text
tempo->setRightSideType(placeHolder.toInt());
}

return true;
Expand Down
22 changes: 17 additions & 5 deletions mscore/ove.h
Original file line number Diff line number Diff line change
Expand Up @@ -1819,9 +1819,9 @@ class Tempo: public MusicData {
void setShowParenthesis(bool show);
bool getShowParenthesis() const;

void setTypeTempo(int tempo); //0x2580 = 96.00
int getTypeTempo() const;
int getQuarterTempo() const;
void setTypeTempo(double tempo); //0x2580 = 96.00
double getTypeTempo() const;
double getQuarterTempo() const;

void setLeftText(const QString& str);// string at left of the mark
QString getLeftText() const;
Expand All @@ -1833,18 +1833,30 @@ class Tempo: public MusicData {
bool getSwingEighth() const;

void setRightNoteType(int type);
int getRightNoteType() const;
NoteType getRightNoteType() const;

void setLeftNoteDot(bool showDot);
bool getLeftNoteDot() const;

void setRightNoteDot(bool showDot);
bool getRightNoteDot() const;

void setRightSideType(int type);
int getRightSideType() const;

private:
int leftNoteType_;
bool showMark_;
bool showText_;
bool showParenthesis_;
int typeTempo_;
double typeTempo_;
QString leftText_;
QString rightText_;
bool swingEighth_;
int rightNoteType_;
bool leftNoteDot_;
bool rightNoteDot_;
int rightSideType_;
};

class Text: public MusicData, public LengthElement {
Expand Down
Loading

0 comments on commit 5d4d203

Please sign in to comment.