我正在使用libpd将纯数据引擎嵌入到我的项目中,并试图从该补丁程序接收信号消息。如何使用libpd从纯数据修补程序接收命名信号?
如果我放置一个非信号消息(即)控制在补丁:
|
|
|
[s toCPP]
我没有麻烦接收到该消息。但是,如果我尝试做一个〜相同的消息,表示信号的消息,我的处理一直没有收到,一个例子补丁如下:
[osc~ 440]
|
|
|
[s~ toCPP]
这个补丁将不会收到任何“toCPP”的消息,不管我是否使用投票或回调。这里是我的[精简]示例代码:
#include <PdBase.hpp>
#include <iostream>
using namespace pd;
class PdRec : public pd::PdReceiver
{
public:
void receiveFloat(const std::string & dest, float num)
{
std::cout << "received float: " << dest << ": " << num << std::endl;
}
void receiveSymbol(const std::string & dest, const std::string & symbol)
{
std::cout << "Received symbol: " << dest << ": " << symbol << std::endl;
}
void receiveMessage(const std::string & dest, const std::string & msg, const pd::List& list)
{
std::cout << "Received message: " << dest << ": " << msg << std::endl;
}
void receiveList(const std::string & dest, const pd::List & list)
{
std::cout << "Received list: " << dest << std::endl;
}
}
int main(int argc, char** argv)
{
float inbuf[64], outbuf[64];
pd::PdBase pdEngine;
if(!pdEngine.init(1, 1, 44100))
{
std::cout << "Failed to initialize pd!" << std::endl;
exit(1);
}
std::cout << "Init success!" << std::endl;
pd::Patch patch = pdEngine.openPatch("a440test.pd", "./");
std::cout << patch << std::endl;
PdRec rec;
pdEngine.subscribe("toCPP");
pdEngine.setReceiver(&rec);
pdEngine.computeAudio(true);
for(int i = 0; i < 30 * 44100/64; i++)
{
pdEngine.processFloat(1, inbuf, outbuf);
}
return 0;
}
人们会想到这个代码以接收来自补丁符号toCPP每滴答周期的浮动(或浮点值列表),但是,这是不是这样的。此测试代码将收到消息的[s到CPP]版本,但不会收到[s〜toCPP]。另外,如果我将它连接到一个[dac_]对象并通过outbuf读入数据,我会接收[osc〜440]的输出,但是这对于我的用途并不是最佳的,我可以可以就像避免它一样(主要原因是我可能需要输出8组或更多组声音数据,并且在创建和使用具有许多通道的dac_对象的补丁程序中有点不便)。
我的问题是这样的:
是否有可能使用libpd钯补丁接收基于信号的消息?
如何在C++端使用libpd从Pd补丁接收基于信号的消息?