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


C++ MidiEvent::getDurationInSeconds方法代码示例

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


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

示例1: main

int main(int argc, char** argv) {
   options.setOptions(argc, argv);
   checkOptions(options);

   int status;
   MidiFile midifile;
   if (options.getArgCount()) {
      status = midifile.read(options.getArg(1));
   } else {
      status = midifile.read(cin);
   }
   if (status == 0) {
      cerr << "Error: could not read MIDI file" << endl;
      exit(1);
   }

   int tpq = midifile.getTicksPerQuarterNote();
   midifile.linkNotePairs();
   if (joinQ) {
      midifile.joinTracks();
   }
   MidiEvent* mev;
   double duration;

   if (secondsQ) {
      midifile.doTimeAnalysis();
   }

   if (secondsQ) {
      cout << "SEC\tDUR\tTRACK\tNOTE\n";
   } else if (quarterQ) {
      cout << "QTRS\tDUR\tTRACK\tNOTE\n";
   } else {
      cout << "TICKS\tDUR\tTRACK\tNOTE\n";
   }
   cout << "============================\n";

   for (int track=0; track < midifile.getTrackCount(); track++) {
      for (int i=0; i<midifile[track].size(); i++) {
         mev = &midifile[track][i];
         if (!mev->isNoteOn()) {
            continue;
         }
         if (secondsQ) {
            duration = mev->getDurationInSeconds();
         } else {
            duration = mev->getTickDuration();
         }

         if (secondsQ) {
            cout << mev->seconds << '\t';
            cout << duration << '\t';
         } else if (quarterQ) {
            cout << mev->tick/tpq << '\t';
            cout << duration/tpq << '\t';
         } else {
            cout << mev->tick << '\t';
            cout << duration << '\t';
         }
         cout << mev->track << '\t';
         cout << mev->getKeyNumber();
         cout << endl;
      }
      if (midifile.getTrackCount() > 1) {
         cout << endl;
      }
   }

   return 0;
}
开发者ID:ManoShu,项目名称:midifile,代码行数:70,代码来源:durations.cpp

示例2: LoadMidiToDB


//.........这里部分代码省略.........
                newInst.Channel = mev->getChannel();
                newInst.Seconds = mev->seconds;
                newInst.InstrumentID = mev->getP1();

                _db->AddInstrument(trackID,&newInst);
#endif
            }

            if(mev->getCommandByte() == 0xFF && mev->getP1() == 0x03)//Title
            {
                printf("Title found\n");
                unsigned char* title = &midifile[track][i][3];//CMD + p1 + p2 are omitted

                int titleSize = mev->getP2();
                if(titleSize > 0)
                {
                    char* strTitle = new char[titleSize+1];

                    memcpy(strTitle,title,titleSize);
                    strTitle[titleSize] = '\0';

                    _db->SetTrackTitle(trackID, strTitle);
                }
                printf("Title end\n");
            }

            if(mev->isNote()) //if(false)
            {
                if(mev->isNoteOn())
                {
#ifdef PCH_USE_HEAP
                    PCH_ChartTrackNote* newNote = new PCH_ChartTrackNote();
                    newNote->Seconds = mev->seconds;
                    newNote->SecondsDuration = mev->getDurationInSeconds();
                    newNote->Channel = mev->getChannel();
                    newNote->KeyNumber =  mev->getKeyNumber();
                    newNote->Velocity = mev->getVelocity();

                    _db->AddNote(trackID, newNote);

                    delete newNote;
                    newNote = NULL;
#else
                    newNote.Seconds = mev->seconds;
                    newNote.SecondsDuration = mev->getDurationInSeconds();
                    newNote.Channel = mev->getChannel();
                    newNote.KeyNumber =  mev->getKeyNumber();
                    newNote.Velocity = mev->getVelocity();

                    _db->AddNote(trackID, &newNote);
#endif
                }
            }

            if(mev->isController())
            {
#ifdef PCH_USE_HEAP
                PCH_ControllerEvent* newEvent = new PCH_ControllerEvent();
                newEvent->Seconds = mev->seconds;
                newEvent->Channel = mev->getChannel();
                newEvent->ControllerID = mev->getP1();
                newEvent->Value = mev->getP2();

                _db->AddEvent(trackID, newEvent);

                delete newEvent;
开发者ID:ManoShu,项目名称:Champler,代码行数:67,代码来源:PCH_ChartManager.cpp


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