当前位置: 首页>>代码示例>>C++>>正文


C++ MidiMessage::p1方法代码示例

本文整理汇总了C++中MidiMessage::p1方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiMessage::p1方法的具体用法?C++ MidiMessage::p1怎么用?C++ MidiMessage::p1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MidiMessage的用法示例。


在下文中一共展示了MidiMessage::p1方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sillyKeyboard

void sillyKeyboard(int key, int chan /* = 0 */) {
   static int octave = 4;
   static int newkey = 0;
   static Voice voice;
   static MidiMessage message;

   // check to see if adjusting the octave:
   if (isdigit(key)) {
      octave = key - '0';
      return;
   }

   switch (key) {
      case 'z':  newkey = 12 * octave + 0;   break;   // C
      case 's':  newkey = 12 * octave + 1;   break;   // C#
      case 'x':  newkey = 12 * octave + 2;   break;   // D
      case 'd':  newkey = 12 * octave + 3;   break;   // D#
      case 'c':  newkey = 12 * octave + 4;   break;   // E
      case 'v':  newkey = 12 * octave + 5;   break;   // F
      case 'g':  newkey = 12 * octave + 6;   break;   // F#
      case 'b':  newkey = 12 * octave + 7;   break;   // G
      case 'h':  newkey = 12 * octave + 8;   break;   // G#
      case 'n':  newkey = 12 * octave + 9;   break;   // A
      case 'j':  newkey = 12 * octave + 10;  break;   // A#
      case 'm':  newkey = 12 * octave + 11;  break;   // B
      case ',':  newkey = 12 * octave + 12;  break;   // C
      case 'l':  newkey = 12 * octave + 12;  break;   // C#
      case '.':  newkey = 12 * octave + 12;  break;   // D
      case '\'': newkey = 12 * octave + 12;  break;   // D#
      case '/':  newkey = 12 * octave + 12;  break;   // E
      default: return;         // don't do anything if not a key
   }

   newkey = limit(newkey, 0, 127);

   // put note-off message in synth's input buffer:
   message.time = t_time;
   message.p0() = 0x90 | voice.getChan();
   message.p1() = voice.getKey();
   message.p2() = 0;
   synth.insert(message);

   // turn off the last note:
   voice.off();

   // set parameters for next note-on:
   voice.setChan(chan & 0x0f);      // limit channel to range from 0 to 15
   voice.setVel(rand() % 127 +1);   // random attack in range from 1 to 127
   voice.setKey(newkey);            // use the newly selected key number

   // play the MIDI note:
   voice.play();

   // insert the played note into synth's input MIDI buffer:
   message.command() = 0x90 | voice.getChan();
   message.p1() = voice.getKey();
   message.p2() = voice.getVel();
   synth.insert(message);

}
开发者ID:Isssmael,项目名称:improv,代码行数:60,代码来源:tumble.cpp

示例2: mainloopalgorithms

void mainloopalgorithms(void) { 
   if (synth.getNoteCount() > 0) {
      message = synth.extractNote();
      oldnote = checkForSquelch(message, memory, mintime, maxtime, t_time);
      if (!oldnote || sstate == 0) {
         cout << "New note from performer: " << message << endl;
         if (message.is_note_on()) {
            message.p1() += 7;
            outvel = message.p2() + veladd;
            if (outvel > 127) { outvel = 127; }
            synth.send(message.p0(), message.p1(), outvel);
            message.time = t_time;
            message.p2() = outvel;
            memory.insert(message);
         } else if (message.is_note_off()) {
            message.p1() += 7;
            synth.send(message.p0(), message.p1(), message.p2());
            message.time = t_time;
            memory.insert(message);
         }
      } else {
         cout << "Feedback note from piano: " << message << endl;
      }
   }

}
开发者ID:Isssmael,项目名称:improv,代码行数:26,代码来源:squelch.cpp

示例3: main

int main(void) {
   MidiInput midiin;
   MidiOutput midiout;
   midiout.setPort(0);
   midiout.open();
   midiin.setPort(0);
   midiin.open();

   MidiMessage message;
   int sysexloc;
   unsigned char *sysexdata = NULL;
   int sysexsize = 0;
   int i;
   int running = 1;
   cout << "sysexio -- display and echo SYSEX messages from MIDI input" << endl;
   cout << "Press Middle C to quit." << endl;
   while (running) {
      if (midiin.getCount() > 0) {
         message = midiin.extract();
         if (message.p0() == 0xf0) {
            sysexloc = message.p1();
            sysexdata = midiin.getSysex(sysexloc);
            sysexsize = midiin.getSysexSize(sysexloc);

            // print out the sysex data to the screen:
            for (i=0; i<sysexsize; i++) {
               cout << hex << (int)sysexdata[i] << " ";
               if ((i + 1) % 30 == 0) {
                  cout << endl;
               }
            }
            cout << endl;

            // Now echo the messages to MIDI output (as a demo
            // for how to send Sysex outputs)
            midiout.rawsend(sysexdata, sysexsize);

            // As a courtesy, mark the midiin sysex buffer free
            // but this is not necessay (it will be erased when
            // more space is needed for storing a sysex.
            midiin.clearSysex(sysexloc);
            
         } else if ((message.p0() & 0xf0) == 0x90) {
            // Exit the program when a middle C note is pressed.
            if (message.p1() == 60 && message.p2() > 0) {
               running = 0;
            }
         }
      }
   }

   return 0;
}
开发者ID:Isssmael,项目名称:improv,代码行数:53,代码来源:sysexio.cpp

示例4: mainloopalgorithms

void mainloopalgorithms(void) { 
   if (synth.getNoteCount() > 0) {
      nextActionTime = t_time;
      message = synth.extractNote();
      if (message.p2() == 0) {   // note off
         keyCount--;
         if (keyCount < 0) {
            keyCount = 0;
         }
         switch (message.p1()) {
            case C3:   lastOffTime[1]  = t_time;   break;
            case D3:   lastOffTime[2]  = t_time;   break;
            case E3:   lastOffTime[3]  = t_time;   break;
            case F3:   lastOffTime[4]  = t_time;   break;
            case G3:   lastOffTime[5]  = t_time;   break;
            case C4:   lastOffTime[6]  = t_time;   break;
            case D4:   lastOffTime[7]  = t_time;   break;
            case E4:   lastOffTime[8]  = t_time;   break;
            case F4:   lastOffTime[9]  = t_time;   break;
            case G4:   lastOffTime[10] = t_time;   break;
         }
      } else {                   // note on
         keyCount++;
         keysOn.insert(message.p1());
         onKey2 = onKey1;
         switch (message.p1()) {
            case C3:   lastOnTime[1]  = t_time;  onKey1 = 1;   break;
            case D3:   lastOnTime[2]  = t_time;  onKey1 = 2;   break;
            case E3:   lastOnTime[3]  = t_time;  onKey1 = 3;   break;
            case F3:   lastOnTime[4]  = t_time;  onKey1 = 4;   break;
            case G3:   lastOnTime[5]  = t_time;  onKey1 = 5;   break;
            case C4:   lastOnTime[6]  = t_time;  onKey1 = 6;   break;
            case D4:   lastOnTime[7]  = t_time;  onKey1 = 7;   break;
            case E4:   lastOnTime[8]  = t_time;  onKey1 = 8;   break;
            case F4:   lastOnTime[9]  = t_time;  onKey1 = 9;   break;
            case G4:   lastOnTime[10] = t_time;  onKey1 = 10;  break;
         }
      }
   }

   if (nextActionTime + repeatRate <= t_time) {
      nextActionTime = t_time;
   }    

   event = makeEventDecision();
   if (event > 0) {
      if (shift) {
         event = toupper(event);
      }
      cout << (char)event << flush;
   }

}
开发者ID:Isssmael,项目名称:improv,代码行数:53,代码来源:keykey.cpp

示例5: processNote

void processNote(MidiMessage& message) {
   int velocity = message.p2();
   int key = message.p1();
   int channel = message.p0() & 0x0f;
   int state = 1;
   int duration = 0;
   if (((message.p0() & 0xf0) == 0x80) || velocity == 0) {
      state = 0;
   }

   if (key == A0) {
      cout << "A0 Triggered" << endl;
      for (int i=0; i<decaystates.getSize(); i++) {
         decaystates[i] *= -1.0;
      }
      return;
   }

   if (state == 1) {
      notestates[key] = message.time;
      onvels[key] = velocity;
   } else {
      if (notestates[key] == 0) {
         // do nothing
      } else {
         duration = message.time - notestates[key];
         if (decaystates[key] == 0.0) {
            createDecay(channel, key, duration, onvels[key]);
         }
      }
      notestates[key] = 0;
   }
}
开发者ID:UIKit0,项目名称:improv,代码行数:33,代码来源:decay.cpp

示例6: main

int main(int argc, char* argv[]) {
    int incount = MidiInPort::getNumPorts();
    int outcount = MidiOutPort::getNumPorts();

    Array<ArrayInt> connections;
    connections.setSize(incount);
    int i, j;
    for (i=0; i<incount; i++) {
        connections[i].setSize(outcount);
        connections[i].setAll(1);
    }

    // temporary connections for now:
    //  connections[0][2] = 0;
    //  connections[1][2] = 0;

    cout << "There are " << incount  << " MIDI inputs" << endl;
    cout << "and " << outcount << " MIDI outputs" << endl;

    MidiMessage message;
    Array<MidiInput> midiins;
    for (i=0; i<incount; i++) {
        midiins[i].setPort(i);
        midiins[i].open();
    }

    Array<MidiOutPort> midiouts;
    midiouts.setSize(outcount);
    for (i=0; i<outcount; i++) {
        midiouts[i].setPort(i);
        midiouts[i].open();
        cout << "opened MIDI output number " << i << endl;
    }

    connections[0][3] = 0;

    displayPatchBay(connections);
    int done = 0;
    while (!done) {
        for (i=0; i<incount; i++) {
            while (midiins[i].getCount() > 0) {
                message = midiins[i].extract();
                if (message.p1() == A0) {
                    done = 1;
                }
                cout << "[" << i << ":";
                for (j=0; j<outcount; j++) {
                    if (connections[i][j]) {
                        cout << j << " ";
                        sendData(message, midiouts[j], midiins[i]);
                    }
                }
                cout << "]" << flush;
            }
        }
    }

    return 0;
}
开发者ID:mdsmus,项目名称:humdrum,代码行数:59,代码来源:midithru.cpp

示例7: mainloopalgorithms

void mainloopalgorithms(void) { 
   eventBuffer.checkPoll();        // see if any notes to play

   while (synth.getNoteCount() > 0) {
      message = synth.extractNote();
      if (message.p2() != 0) {
         lastnotes.insert(message.p1());
         lasttimes.insert(message.time);
         distancee = lastnotes[0] - lastnotes[1];
         duration = lasttimes[0] - lasttimes[1];
         channel = 0x0f & message.p0();
         if (distancee != 0) {
            playgliss(message.p1(), message.p2(), channel,  duration, distancee);
         }
      }
   }
}
开发者ID:UIKit0,项目名称:improv,代码行数:17,代码来源:ripple.cpp

示例8: sendData

void sendData(MidiMessage& m, MidiOutPort& output,
              MidiInput& input) {
    int count = m.getParameterCount();
    if (count >= 0 && count <= 2) {
        if (count >= 0) output.rawsend(m.p0());
        if (count >= 1) output.rawsend(m.p0(), m.p1());
        if (count >= 2) output.rawsend(m.p0(), m.p1(), m.p2());
    }
}
开发者ID:mdsmus,项目名称:humdrum,代码行数:9,代码来源:midithru.cpp

示例9: processMidiCommand

void processMidiCommand(MidiMessage& message) {
   if (message.p0() != 0x90 || message.p2() == 0) {
      return;
   }

   switch (message.p1()) {
      case 60:                     // Middle C = beat
         keyboardchar(' ');
         break;
      case 61:                     // C# = amplitude control
         {
         double amp = performance.getAmp();
         amp = amp * message.p2() / 64;
         if (amp < 0) {
            amp = 0;
         } else if (amp > 127) {
            amp = 127;
         }
         performance.setAmp((int)amp);
         }
         break;
      case 71:                      // B  = 1 beat tempo follow
         keyboardchar('1');
         break;
      case 72:                      // C  = 2 beat tempo follow
         keyboardchar('2');
         break;
      case 73:                      // C# = 3 beat tempo follow
         keyboardchar('3');
         break;
      case 74:                      // D  = 4 beat tempo follow
         keyboardchar('4');
         break;
      case 79:                      // G  = constant tempo follow
         keyboardchar('9');
         break;
      case 80:                      // G# = automatic
         keyboardchar('0');
         break;
      case 62:                      // amplitude decrease
         keyboardchar('[');
         break;
      case 63:                      // amplitude increase
         keyboardchar(']');
         break;
      case 64:                      // tempo decrease
         keyboardchar('-');
         break;
      case 65:                      // tempo increase
         keyboardchar('=');
         break;
   }

}
开发者ID:UIKit0,项目名称:improv,代码行数:54,代码来源:midiperform2.cpp

示例10: mainloopalgorithms

void mainloopalgorithms(void) {
   eventBuffer.checkPoll();

   while (synth.getNoteCount() > 0) {
      message = synth.extractNote();
      if (message.is_note_on() && message.p1() == A0) {
         direction = -direction;
         cout << "Direction = " << direction << endl;
      } else if (message.is_note_on() && message.p1() == C7) {
         // add one to the length of the tumble sequence
         length = limit(length+1, 2, 200);
         cout << "Sequence length = " << length << endl;
      } else if (message.is_note_on() && message.p1() == B6) {
         // subtract one from the length of the tumble sequence
         length = limit(length-1, 2, 200);
         cout << "Sequence length = " << length << endl;
      } else {
         processNote(message, length, direction);
      }
   }
}
开发者ID:Isssmael,项目名称:improv,代码行数:21,代码来源:tumble.cpp

示例11: mainloopalgorithms

void mainloopalgorithms(void) { 
   while (synth.getNoteCount() > 0) {
      noteMessage = synth.extractNote();
      if (noteMessage.p2() != 0) {              // ignore note off commands
         synth.play(0, shadowNote, 0);          // turn off last note
         shadowNote = noteMessage.p1() + shadowSide * shadowDistance;
         if (shadowNote > 0 && shadowNote < 128) {
            synth.play(0, shadowNote, noteMessage.p2());
         } else {
            shadowNote = 0;
         }
      }
   }
}
开发者ID:Isssmael,项目名称:improv,代码行数:14,代码来源:shadow1.cpp

示例12: mainloopalgorithms

void mainloopalgorithms(void) { 

   while (synth.getNoteCount() > 0) {
      message = synth.extractNote();
      if (message.is_note_off()) {
         continue;
      }
      returnpitch = message.p1();
      returnvelocity = message.p2();
      // returntime = message.time;
      returntime = t_time;
      
      dtime = (short)(returntime - outtimes[returnpitch]);
      if (dtime > 500) {   // ignore return times which take more than 0.5 sec
         continue;
      }

      vchange = returnvelocity - outvels[returnpitch];
      velchange[returnpitch][outvels[returnpitch]].append(vchange);
      deltatimes[returnpitch][outvels[returnpitch]].append(dtime);
   }

   if (!playstate) {
      return;
   }

   if (nextnotetime <= t_time) {
      currentnote += 11;
      if (currentnote > 127) {
         currentnote -= 127;
      }
      if (currentnote < A0 || currentnote > C8) {
         return;
      }
      velocity = rand() % 127 + 1;   // random velocity between 1 and 127

      voices[currvoice].off();
      outvels[currentnote] = velocity;
      outtimes[currentnote] = mainTimer.getTime();
      voices[currvoice++].play(0, currentnote, velocity);
      if (currvoice >= maxvoices) {
         currvoice = 0;
      }

      notecount++;
      nextnotetime = t_time + duration;
   }

}
开发者ID:Isssmael,项目名称:improv,代码行数:49,代码来源:pdiscal.cpp

示例13: processKeyboard

void processKeyboard(void) {
   MidiMessage message;
   int key;
   int vel;
   int command;
   
   while (synth.getNoteCount() > 0) {
      message = synth.extractNote();
      command = message.p0();
      key = message.p1();
      vel = message.p2();
 
      if (vel == 0 || (command & 0xf0 == 0x80)) {
         // note-off command section
         long duration = t_time - performerNotes[key];
         durations.insert(duration);
         durtimes.insert(t_time);

         performerNotes[key] = 0;
         performerPC[key%12]--;
         if (performerPC[key%12] < 0) {
            performerPC[key%12] = 0;
         }
      
      } else {   // note-on command
         performerNotes[key] = t_time;
         performerPC[key%12]++;
         performerPCHistory[key%12]++;
         keys.insert(key);
         keytimes.insert(t_time);
         volumes.insert(vel);
         voltimes.insert(t_time);

      } // end of the note-on command section

   }  // end of the while loop for processing notes from the performer

   // update the time that the performer last play a note on/off:
   lastPerformerTime = t_time;

   updatePerformRegions();
   updateDuration();
   updateVolume();
}
开发者ID:Isssmael,项目名称:improv,代码行数:44,代码来源:seny.cpp

示例14: checkForSquelch

int checkForSquelch(MidiMessage& message, CircularBuffer<MidiMessage>& memory, 
      int mintime, int maxtime, int curtime) {
   int i;
   if (memory.getSize() == 0) {
      return 0;
   }

   for (i=0; i<memory.getSize(); i++) {
      if ((curtime - (int)memory[i].time) < mintime) {
         continue;
      }
      if ((curtime - (int)memory[i].time) > maxtime) {
         break;
      }
      if ((memory[i].p0() == message.p0()) && (memory[i].p1() == message.p1())) {
         return 1;
      }
   }

   return 0;
}
开发者ID:Isssmael,项目名称:improv,代码行数:21,代码来源:squelch.cpp

示例15: initialization

void initialization(void) { 
   batonTimer.setPeriod(50);           // time to get new state of baton
   offTimer.setPeriod(200);            // time to check buffer for forgetting
   controlDisplayTimer.setPeriod(200); // time to check buffer for forgetting

   // set the voice channels all to be 0 for the disklavier and so
   // the channels do not have to be specified when playing the note.
   for (int i=0; i<MAXVOICES; i++) {
      voice[i].setChannel(0);
   }
   computer.setChannel(0);
   computerMessage.time = t_time;
   computerMessage.p0() = 0x90;
   computerMessage.p1() = 0;
   computerMessage.p2() = 0;

   keys.setSize(1000);        // store keys for memory of previous notes
   keytimes.setSize(1000);    // note times for keys buffer
   volumes.setSize(1000);     // duration of notes being held by performer
   voltimes.setSize(1000);    // duration of notes being held by performer
   durations.setSize(1000);   // duration of notes being held by performer
   durtimes.setSize(1000);    // duration of notes being held by performer
}
开发者ID:Isssmael,项目名称:improv,代码行数:23,代码来源:seny.cpp


注:本文中的MidiMessage::p1方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。