Esempio n. 1
0
QString
NotationStrings::makeNoteMenuLabel(timeT duration,
                                   bool brief,
                                   timeT &errorReturn,
                                   bool plural)
{
    Note nearestNote = Note::getNearestNote(duration);
    bool triplet = false;
    errorReturn = 0;

    if (duration == 0) return "0";

    if (nearestNote.getDuration() != duration) {
        Note tripletNote = Note::getNearestNote(duration * 3 / 2);
        if (tripletNote.getDuration() == duration * 3 / 2) {
            nearestNote = tripletNote;
            triplet = true;
        } else {
            errorReturn = duration - nearestNote.getDuration();
            duration = nearestNote.getDuration();
        }
    }

    QSettings settings;
    settings.beginGroup( GeneralOptionsConfigGroup );

    GeneralConfigurationPage::NoteNameStyle noteNameStyle =
            (GeneralConfigurationPage::NoteNameStyle) settings.value
            ("notenamestyle", GeneralConfigurationPage::Local).toUInt();

    settings.endGroup();

    if (brief) {

        timeT wholeNote = Note(Note::Semibreve).getDuration();
        if ((wholeNote / duration) * duration == wholeNote) {
            return QString("1/%1").arg(wholeNote / duration);
        } else if ((duration / wholeNote) * wholeNote == duration) {
            return QString("%1/1").arg(duration / wholeNote);
        } else if ((wholeNote /(duration*2/3)) * (duration*2/3) == wholeNote) {
            return QString("3/%1").arg(wholeNote / (duration*1/3));
        } else {
            return tr("%1 ticks").arg(duration);
            plural = false;
        }

    } else {
        QString noteName;

        switch (noteNameStyle) {

        case GeneralConfigurationPage::American:
            noteName = getAmericanName(nearestNote, plural, triplet);
            break;

        case GeneralConfigurationPage::Local:
            noteName = getNoteName(nearestNote, plural, triplet);
            break;
        }

        // Already internationalised, if appropriate
        return noteName;
    }

    // "control reached end of non-void function" warning:
    return "0";
}
Esempio n. 2
0
 bool Measure::canAdd( const Note& note ) const
 {
     return canAdd( note.getDuration() );
 }
void PlayBack::process()
{
    for(unsigned int i=0; i<staff.getNumOfNotes(); i++){

        Note note = staff.getNoteByNum(i+1);

        switch (staff.getNoteByNum(i+1).getPitch()) {
        case -24:
            if(accents.at(i)->getAccent() == Accent::flat){
                note--;
            }
            break;
        case -20:
            if(accents.at(i)->getAccent() == Accent::sharp){
                note++;
            }
            break;
        case -19:
            if(accents.at(i)->getAccent() == Accent::flat){
                note--;
            }
            break;
        case -13:
            if(accents.at(i)->getAccent() == Accent::sharp){
                note++;
            }
            break;
        case -12:
            if(accents.at(i)->getAccent() == Accent::flat){
                note--;
            }
            break;
        case -8:
            if(accents.at(i)->getAccent() == Accent::sharp){
                note++;
            }
            break;
        case -7:
            if(accents.at(i)->getAccent() == Accent::flat){
                note--;
            }
            break;
        case -1:
            if(accents.at(i)->getAccent() == Accent::sharp){
                note++;
            }
            break;
        case 0:
            if(accents.at(i)->getAccent() == Accent::flat){
                note--;
            }
            break;
        case 4:
            if(accents.at(i)->getAccent() == Accent::sharp){
                note++;
            }
            break;
        case 5:
            if(accents.at(i)->getAccent() == Accent::flat){
                note--;
            }
            break;
        case 11:
            if(accents.at(i)->getAccent() == Accent::sharp){
                note++;
            }
            break;
        case 12:
            if(accents.at(i)->getAccent() == Accent::flat){
                note--;
            }
            break;
        case 16:
            if(accents.at(i)->getAccent() == Accent::sharp){
                note++;
            }
            break;
        case 17:
            if(accents.at(i)->getAccent() == Accent::flat){
                note--;
            }
            break;
        case 23:
            if(accents.at(i)->getAccent() == Accent::sharp){
                note++;
            }
            break;
        case 24:
            if(accents.at(i)->getAccent() == Accent::flat){
                note--;
            }
            break;
        default:

            break;
        }

        if(!midi->isConnected()){
            emit finished();
            return;
        }else{
            midi->noteOn(/* note */ note.getPitch()+60, /* voice */ voice , velocity /*velocity */);
        }

        //        midi.noteOn(/* note */ svm->getNoteByNum(2,i+1).getPitch()+60, /* voice */ 1 /* , velocity */);
        //qDebug() << "noteon\n";
        switch (note.getDuration()) {
        case 1:
            QThread::msleep(tempo*8);
            break;
        case 2:
            QThread::msleep(tempo*4);
            break;
        case 4:
            QThread::msleep(tempo*2);
            break;
        case 8:
            QThread::msleep(tempo);
            break;
        default:
            break;
        }
        if(!midi->isConnected()){
            emit finished();
            return;
        }else{
            midi->noteOff(/* note */ note.getPitch()+60, /* voice */ voice);
        }
        //qDebug() << "noteoff";
        //        midi.noteOff(/* note */ svm->getNoteByNum(2,i+1).getPitch()+60, /* voice */ 1 /* , velocity */);
    }
    emit finished();
    //this->exit();

}