Ejemplo n.º 1
0
void MainWindow::noteOn(const int midiNote)
{
    int lastNote = this->widget_staff->widget()->width()-10;
    this->widget_staff->ensureVisible(lastNote, 0);
    std::vector<unsigned char> message;
    if((midiNote & MASK_SAFETY) == midiNote) {
        unsigned char chan = static_cast<unsigned char>(keybdChannel);
        unsigned char vel = static_cast<unsigned char>(keybdVelocity);
        message.push_back(STATUS_NOTEON + (chan & MASK_CHANNEL));
        message.push_back(midiNote & MASK_SAFETY);
        message.push_back(vel & MASK_SAFETY);
        messageWrapper( &message );
    }
    if(!this->staffEditable)
        return;
    if(currentSel == QPoint(-1, -1)) {
        if(midiNote>47) {
            if(rpStaff->isCompasCompleto(partitura)) {
                partitura->addCompas(new Compas());
                partitura->getAuxPent()->addCompas(new Compas());
                this->rpStaff->addNota(midiNote, PARTITURA1, COMPLETO);
            } else {
                this->rpStaff->addNota(midiNote, PARTITURA1, INCOMPLETO);
            }
        } else if(midiNote<48 && midiNote>-1){
            if(rpStaff->isCompasCompleto(partitura->getAuxPent())) {
                partitura->addCompas(new Compas());
                partitura->getAuxPent()->addCompas(new Compas());
                this->rpStaff->addNota(midiNote, PARTITURA2, COMPLETO);
            } else {
                this->rpStaff->addNota(midiNote, PARTITURA2, INCOMPLETO);
            }
        } else if(midiNote == -1){
            if(rpStaff->isCompasCompleto(partitura)) {
                partitura->addCompas(new Compas());
                partitura->getAuxPent()->addCompas(new Compas());
                this->rpStaff->addPause(PARTITURA1, COMPLETO);
            } else {
                this->rpStaff->addPause(PARTITURA1, INCOMPLETO);
            }
        } else if(midiNote == -2){
            if(rpStaff->isCompasCompleto(partitura->getAuxPent())) {
                partitura->addCompas(new Compas());
                partitura->getAuxPent()->addCompas(new Compas());
                this->rpStaff->addPause(PARTITURA2, COMPLETO);
            } else {
                this->rpStaff->addPause(PARTITURA2, INCOMPLETO);
            }
        }
    } else {
        if(midiNote>47) {
            this->rpStaff->addNota(midiNote, PARTITURA1, currentSel);
        } else if(midiNote<48 && midiNote>-1){
            this->rpStaff->addNota(midiNote, PARTITURA2, currentSel);
        }
    }
}
Ejemplo n.º 2
0
void VPiano::programChange(const int program)
{
    std::vector<unsigned char> message;
    unsigned char chan = static_cast<unsigned char>(dlgPreferences.getOutChannel());
    unsigned char pgm  = static_cast<unsigned char>(program);
    // Program: 0xC0 + channel, pgm
    message.push_back(STATUS_PROGRAM + (chan & MASK_CHANNEL));
    message.push_back(pgm & MASK_SAFETY);
    messageWrapper( &message );
}
Ejemplo n.º 3
0
void MainWindow::noteOff(const int midiNote)
{
    std::vector<unsigned char> message;
    if((midiNote & MASK_SAFETY) == midiNote) {
        unsigned char chan = static_cast<unsigned char>(keybdChannel);
        unsigned char vel = static_cast<unsigned char>(keybdVelocity);
        message.push_back(STATUS_NOTEOFF + (chan & MASK_CHANNEL));
        message.push_back(midiNote & MASK_SAFETY);
        message.push_back(vel & MASK_SAFETY);
        messageWrapper( &message );
    }
}
Ejemplo n.º 4
0
void VPiano::sendController(const int controller, const int value)
{
    std::vector<unsigned char> message;
    unsigned char chan = static_cast<unsigned char>(dlgPreferences.getOutChannel());
    unsigned char ctl  = static_cast<unsigned char>(controller);
    unsigned char val  = static_cast<unsigned char>(value);
    // Controller: 0xB0 + channel, ctl, val
    message.push_back(STATUS_CONTROLLER + (chan & MASK_CHANNEL));
    message.push_back(ctl & MASK_SAFETY);
    message.push_back(val & MASK_SAFETY);
    messageWrapper( &message );
}
Ejemplo n.º 5
0
void VPiano::bender(const int value)
{
    std::vector<unsigned char> message;
    int v = value + BENDER_MID; // v >= 0, v <= 16384
    unsigned char chan = static_cast<unsigned char>(dlgPreferences.getOutChannel());
    unsigned char lsb  = static_cast<unsigned char>(CALC_LSB(v));
    unsigned char msb  = static_cast<unsigned char>(CALC_MSB(v));
    // Program: 0xE0 + channel, lsb, msb
    message.push_back(STATUS_BENDER + (chan & MASK_CHANNEL));
    message.push_back(lsb);
    message.push_back(msb);
    messageWrapper( &message );
}
Ejemplo n.º 6
0
void VPiano::noteOff(const int midiNote)
{
    std::vector<unsigned char> message;
    if ((midiNote & MASK_SAFETY) == midiNote) {
        unsigned char chan = static_cast<unsigned char>(dlgPreferences.getOutChannel());
        unsigned char vel = static_cast<unsigned char>(dlgPreferences.getVelocity());
        // Note Off: 0x80 + channel, note, vel
        message.push_back(STATUS_NOTEOFF + (chan & MASK_CHANNEL));
        message.push_back(midiNote & MASK_SAFETY);
        message.push_back(vel & MASK_SAFETY);
        messageWrapper( &message );
    }
}