我是一名 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/