c++ - 使用 Midi 库解析事件并存储在 Vector C++ 中

标签 c++ command-line-interface midi vst

我是一名 PHP 程序员,我决定通过开发一个简单的 MissWatson 替代品来投入到 C++ 中,它允许我通过 PHP 的命令行,通过 VST 处理 MIDI 文件。

我从 Steinberg VST SDK 开始,一直在使用这个 MIDI 库:https://ccrma.stanford.edu/software/stk/index.html .

我坚持使用 vector ,特别是将 MIDI 事件存储到的 vector 。这是要清理的最后一段代码(请记住,我对 C++ 完全是个菜鸟,并且可能做错了大部分):

std::string midiPath = "C:\\creative\\midi\\m1.mid";

if (argc > 1) {
    midiPath = argv[1];
}

//MidiFileIn::MidiFileIn(midiPath);
stk::MidiFileIn::MidiFileIn(midiPath);

//std::vector<_Ty> * midiEvents;
std::vector<_Ty> midiEvents(200);

stk::MidiFileIn::getNextEvent(midiEvents, 0);
//char* midiEvents[200];
//VstEvents* midiEvents;
//processMidi(effect, VstEvents*);

const char* wavPath = argv[2];
//processAudio(effect, 0, x, x);

这里是错误:

1>c:\users\andrew\downloads\vst_sdk2_4_rev2\vstsdk2.4\public.sdk\samples\vst2.x\minihost\source\score.cpp(370): error C2065: '_Ty' : undeclared identifier
1>c:\users\andrew\downloads\vst_sdk2_4_rev2\vstsdk2.4\public.sdk\samples\vst2.x\minihost\source\score.cpp(370): error C2514: 'std::vector' : class has no constructors
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(480) : see declaration of 'std::vector'
1>c:\users\andrew\downloads\vst_sdk2_4_rev2\vstsdk2.4\public.sdk\samples\vst2.x\minihost\source\score.cpp(372): error C2664: 'stk::MidiFileIn::getNextEvent' : cannot convert parameter 1 from 'std::vector' to 'std::vector<_Ty> *'
1>          with
1>          [
1>              _Ty=unsigned char
1>          ]
1>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>

那么,我该如何使用 _Ty 构造函数呢?我是在正确的轨道上还是疯了?

最佳答案

_Ty只是模板参数的占位符。你有 std::vector<_Ty>这是一个模板化类,但您需要定义要为它使用的类。在这种情况下,它将是您的 MIDI 事件类是什么 - 可能是 VstEvents

关于c++ - 使用 Midi 库解析事件并存储在 Vector C++ 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6484362/

相关文章:

c++ - 传递给虚拟析构函数的这个额外参数是什么?

java - 从命令行使用处理时出现 UnsupportedClassVersionError

linux - 将多个 PDF 文件合并/转换为一个 PDF

c++ - 错误 LNK2019 : unresolved external symbol classes

c++ - 建议使用 C++ 或 haskell 编写的 SAT 求解器。优点和缺点

java - 为什么 picocli 不能从命令行识别我的选项?

python - 在 python (numpy) 中将 MIDI 文件转录为钢琴卷轴

php - 将 MIDI 转换为 mp3

c++ - RtMidi MIDI 控制信号到 Ableton Live

c++ - recv() 结果必须等于缓冲区长度吗?