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


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

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


在下文中一共展示了MidiMessage::command方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: interpretCommand

void RadioBaton::interpretCommand(MidiMessage aMessage) {
   ushort value;  // for the buff value receive commands

   if (aMessage.command() == BAT_MIDI_COMMAND) {
      switch (aMessage.p1()) {
         case BAT_STICK1_RESPONSE_X:         // stick 1 responding to poll; x
            s1ps(aMessage.time);
            s1pd(DATA_X, aMessage.p2());
            break;
         case BAT_STICK1_RESPONSE_Y:         // stick 1 responding to poll; y
            s1pd(DATA_Y, aMessage.p2());
            break;
         case BAT_STICK1_RESPONSE_Z:         // stick 1 responding to poll; z
            s1pd(DATA_Z, aMessage.p2());
            break;
         case BAT_STICK2_RESPONSE_X:         // stick 2 responding to poll; x
            s2ps(aMessage.time);
            s2pd(DATA_X, aMessage.p2());
            break;
         case BAT_STICK2_RESPONSE_Y:         // stick 2 responding to poll; y
            s2pd(DATA_Y, aMessage.p2());
            break;
         case BAT_STICK2_RESPONSE_Z:         // stick 2 responding to poll; z
            s2pd(DATA_Z, aMessage.p2());
            break;
         case BAT_POT1_RESPONSE:             // pot 1 responding to poll
            d1p = aMessage.p2();             // update global state variable
            dial1position();
            recordState(aMessage.time, DIAL1RECORD, d1p);
            d1pb.insert(aMessage.p2());
            break;
         case BAT_POT2_RESPONSE:             // pot 2 responding to poll
            d2p = aMessage.p2();             // update global state variable
            dial2position();
            recordState(aMessage.time, DIAL2RECORD, d2p);
            d2pb.insert(aMessage.p2());
            break;
         case BAT_POT3_RESPONSE:             // pot 3 responding to poll
            d3p = aMessage.p2();             // update global state variable
            dial3position();
            recordState(aMessage.time, DIAL3RECORD, d3p);
            d3pb.insert(aMessage.p2());
            break;
         case BAT_POT4_RESPONSE:             // pot 4 responding to poll
            d4p = aMessage.p2();             // update global state variable
            dial4position();
            recordState(aMessage.time, DIAL4RECORD, d4p);
            d4pb.insert(aMessage.p2());
            break;
         case BAT_STICK1_TRIGGER:            // stick 1 got triggered
            s1ts(aMessage.time);
            s1td(DATA_W, aMessage.p2());
            break;
         case BAT_STICK1_TRIG_X:             // stick 1 got triggered
            s1td(DATA_X, aMessage.p2());
            break;
         case BAT_STICK1_TRIG_Y:             // stick 1 got triggered
            s1td(DATA_Y, aMessage.p2());
            break;
         case BAT_STICK2_TRIGGER:            // stick 2 got triggered
            s2ts(aMessage.time);
            s2td(DATA_W, aMessage.p2());
            break;
         case BAT_STICK2_TRIG_X:             // stick 2 got triggered
            s2td(DATA_X, aMessage.p2());
            break;
         case BAT_STICK2_TRIG_Y:             // stick 2 got triggered
            s2td(DATA_Y, aMessage.p2());
            break;

         case BAT_BUTTON_FOOT_TRIGGER:       // button or pedal was triggered
            switch (aMessage.p2()) {
               case BAT_B14p_TRIGGER:        // B14+ button pressed
                  b14pt = aMessage.time;
                  b14ptb.insert(b14pt);
                  recordState(aMessage.time, BUTTON1RECORD);
                  b14plustrig();
                  break;
               case BAT_B15p_TRIGGER:        // B15+ button pressed
                  b15pt = aMessage.time;
                  recordState(aMessage.time, BUTTON2RECORD);
                  b15plustrig();
                  b15ptb.insert(b15pt);
                  break;
               case BAT_B14m_DOWN_TRIGGER:   // B14- pedal was depressed
                  b14mdt = aMessage.time;
                  b14mdtb.insert(b14mdt);
                  recordState(b14mdt, FOOTPEDAL1RECORD, 1);
                  b14minusdowntrig();
                  break;
               case BAT_B14m_UP_TRIGGER:     // B14- pedal was released
                  b14mut = aMessage.time;
                  b14mutb.insert(b14mut);
                  recordState(b14mut, FOOTPEDAL1RECORD, 0);
                  b14minusuptrig();
                  break;
               case BAT_B15m_DOWN_TRIGGER:   // B15- pedal was depressed
                  b15mdt = aMessage.time;
                  b15mdtb.insert(b15mdt);
                  recordState(b15mut, FOOTPEDAL2RECORD, 1);
//.........这里部分代码省略.........
开发者ID:Isssmael,项目名称:improv,代码行数:101,代码来源:RadioBaton.cpp


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