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


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

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


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

示例1: PK_STRING

static PyObject *
PyMidiMessage_str(PyObject *self) {
  MidiMessage *m = ((PyMidiMessage*)self)->m;
  static char s[256];
  if(m->isNoteOn()) {
    sprintf(s, "<NOTE ON, note: %d (%s), velocity: %d, channel: %d>",
            m->getNoteNumber(),
            m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
            m->getVelocity(),
            m->getChannel());
  } else if(m->isNoteOff()) {
    sprintf(s, "<NOTE OFF, note: %d (%s), channel: %d>",
            m->getNoteNumber(),
            m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
            m->getChannel());
  } else if(m->isProgramChange()) {
    sprintf(s, "<PROGRAM CHANGE: program: %d, channel: %d>", m->getProgramChangeNumber(), m->getChannel());
  } else if(m->isPitchWheel()) {
    sprintf(s, "<PITCH WHEEL: value: %d, channel: %d>", m->getPitchWheelValue(), m->getChannel());
  } else if(m->isAftertouch()) {
    sprintf(s, "<AFTERTOUCH: note: %d (%s) value: %d, channel: %d>",
            m->getNoteNumber(),
            m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
            m->getAfterTouchValue(),
            m->getChannel());
  } else if(m->isChannelPressure()) {
    sprintf(s, "<CHANNEL PRESSURE: pressure: %d, channel: %d>", m->getChannelPressureValue(), m->getChannel());
  } else if(m->isController()) {
    const char *name = m->getControllerName(m->getControllerNumber());
    if(strlen(name) > 0) {
      sprintf(s, "<CONTROLLER: %d (\"%s\"), value: %d, channel: %d>",
              m->getControllerNumber(),
              m->getControllerName(m->getControllerNumber()),
              m->getControllerValue(),
              m->getChannel());
    } else {
      sprintf(s, "<CONTROLLER: %d, value: %d, channel: %d>",
              m->getControllerNumber(),
              m->getControllerValue(),
              m->getChannel());
    }
  } else {
    sprintf(s, "<MidiMessage (misc type)>");
  }

  return PK_STRING(s);
}
开发者ID:,项目名称:,代码行数:47,代码来源:

示例2: main


//.........这里部分代码省略.........
                MidiMessage message = pEvent->message;
                double time_stamp = message.getTimeStamp();

                if (message.isTextMetaEvent())
                {
                    String text = message.getTextFromTextMetaEvent();
                    char buf[1024];
                    memset( buf, '\0', sizeof(buf) );
                    text.copyToBuffer( buf, sizeof(buf)-1 );
                    // printf("Track %d is %s\n", track, buf );
                    l_ossGCode.str("");
                    l_ossGCode << "(Text track " << track << " is " << buf << ")";
                    gcode.push_back(l_ossGCode.str());
                    printf("%s\n", l_ossGCode.str().c_str());

                    std::ostringstream l_ossHeeks;
                    l_ossHeeks << "<Text text=\"" << buf << "\" font=\"OpenGL\" col=\"0\" m0=\"-0.0443342566\" m1=\"-0.999016753\" m2=\"0\" m3=\"" << (double) (time_stamp * mm_per_second) << "\" m4=\"0.999016753\" m5=\"-0.0443342566\" m6=\"0\" m7=\"" << (double) ((track_width + space_between_tracks) * track) << "\" m8=\"0\" m9=\"0\" ma=\"1\" mb=\"0\" id=\"" << id++ << "\" />";
                    heeks.push_back( l_ossHeeks.str() );
                }

                if (message.isTrackNameEvent())
                {
                    String text = message.getTextFromTextMetaEvent();
                    char buf[1024];
                    memset( buf, '\0', sizeof(buf) );
                    text.copyToBuffer( buf, sizeof(buf)-1 );
                    printf("Track %d is %s\n", track, buf );
                }

                if (message.isNoteOn())
                {
                    char note_name[256];
                    memset( note_name, '\0', sizeof(note_name) );
                    message.getMidiNoteName(message.getNoteNumber(), true, true, middle_c_octave).copyToBuffer( note_name, sizeof(note_name)-1 );

                    notes.insert( message.getNoteNumber() );

                    // printf("time %lf note %s\n", time_stamp, note_name );
                    std::string l_ssNoteName(note_name);
                    std::string::size_type offset;
                    bool sharp_found = false;
                    while ((offset = l_ssNoteName.find("#")) != std::string::npos)
                    {
                        l_ssNoteName = l_ssNoteName.erase(offset,1);
                        sharp_found = true;
                    }

                    strncpy( note_name, l_ssNoteName.c_str(), sizeof(note_name)-1 );

                    const int blue = 16711680;
                    const int black = 0;
                    const int red = 255;

                    int colour = blue;
                    Keys_t::iterator l_itLegalKey = std::find( legal_keys.begin(), legal_keys.end(), note_name );
                    if (l_itLegalKey == legal_keys.end())
                    {
                        colour = red;
                    }

                    // Find the note name in the keys we're interested in.
                    Keys_t::iterator l_itKey = std::find( keys.begin(), keys.end(), note_name );
                    if (l_itKey != keys.end())
                    {
                        double x = time_stamp * mm_per_second * time_scale;
                        double y = double(double(std::distance( keys.begin(), l_itKey )) - double(middle_c_key)) * distance_between_notes_in_mm;
开发者ID:DavidNicholls,项目名称:heekscnc,代码行数:67,代码来源:main.cpp


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