本文整理汇总了C++中Patch::dollarZeroStr方法的典型用法代码示例。如果您正苦于以下问题:C++ Patch::dollarZeroStr方法的具体用法?C++ Patch::dollarZeroStr怎么用?C++ Patch::dollarZeroStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Patch
的用法示例。
在下文中一共展示了Patch::dollarZeroStr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
//--------------------------------------------------------------
void AppCore::setup(const int numOutChannels, const int numInChannels,
const int sampleRate, const int ticksPerBuffer) {
ofSetFrameRate(60);
ofSetVerticalSync(true);
//ofSetLogLevel(OF_LOG_VERBOSE);
// double check where we are ...
cout << ofFilePath::getCurrentWorkingDirectory() << endl;
if(!pd.init(numOutChannels, numInChannels, sampleRate, ticksPerBuffer)) {
ofLog(OF_LOG_ERROR, "Could not init pd");
OF_EXIT_APP(1);
}
midiChan = 1; // midi channels are 1-16
// subscribe to receive source names
pd.subscribe("toOF");
pd.subscribe("env");
// add message receiver, disables polling (see processEvents)
pd.addReceiver(*this); // automatically receives from all subscribed sources
pd.ignore(*this, "env"); // don't receive from "env"
//pd.ignore(*this); // ignore all sources
//pd.receive(*this, "toOF"); // receive only from "toOF"
// add midi receiver
pd.addMidiReceiver(*this); // automatically receives from all channels
//pd.ignoreMidi(*this, 1); // ignore midi channel 1
//pd.ignoreMidi(*this); // ignore all channels
//pd.receiveMidi(*this, 1); // receive only from channel 1
// add the data/pd folder to the search path
pd.addToSearchPath("pd");
// audio processing on
pd.start();
cout << endl << "BEGIN Patch Test" << endl;
// open patch
Patch patch = pd.openPatch("test.pd");
cout << patch << endl;
// close patch
pd.closePatch(patch);
cout << patch << endl;
// open patch
patch = pd.openPatch("test.pd");
cout << patch << endl;
cout << "FINISH Patch Test" << endl;
cout << endl << "BEGIN Message Test" << endl;
// test basic atoms
pd.sendBang("fromOF");
pd.sendFloat("fromOF", 100);
pd.sendSymbol("fromOF", "test string");
// stream interface
pd << Bang("fromOF")
<< Float("fromOF", 100)
<< Symbol("fromOF", "test string");
// send a list
pd.startMessage();
pd.addFloat(1.23);
pd.addSymbol("a symbol");
pd.finishList("fromOF");
// send a message to the $0 receiver ie $0-toOF
pd.startMessage();
pd.addFloat(1.23);
pd.addSymbol("a symbol");
pd.finishList(patch.dollarZeroStr()+"-fromOF");
// send a list using the List object
List testList;
testList.addFloat(1.23);
testList.addSymbol("sent from a List object");
pd.sendList("fromOF", testList);
pd.sendMessage("fromOF", "msg", testList);
// stream interface for list
pd << StartMessage() << 1.23 << "sent from a streamed list" << FinishList("fromOF");
cout << "FINISH Message Test" << endl;
cout << endl << "BEGIN MIDI Test" << endl;
// send functions
pd.sendNoteOn(midiChan, 60);
pd.sendControlChange(midiChan, 0, 64);
//.........这里部分代码省略.........
示例2: setup
void AudioGenerativeApp::setup()
{
mAudioBuff = (float*) malloc(1000000 * sizeof(float));
mPd = new ofxPd();
mPdListener = new PdListener();
// Audio capture set up
//
//iterate input devices and print their names to the console
audio::InputDeviceRef builtInMic = audio::Input::findDeviceByName("Built-in Microphone");
audio::InputDeviceRef builtInInput = audio::Input::findDeviceByName("Built-in Input");
const std::vector<audio::InputDeviceRef>& devices = audio::Input::getDevices();
for( std::vector<audio::InputDeviceRef>::const_iterator iter = devices.begin(); iter != devices.end(); ++iter ) {
console() << (*iter)->getName() << std::endl;
}
if (builtInMic){// && false) {
console() << "Using Built-in Microphone\n";
mInput = new audio::Input(builtInMic);
}
else if (builtInInput) {
console() << "Using Built-in Input\n";
mInput = new audio::Input(builtInInput);
}
else {
console() << "Using default input\n";
mInput = new audio::Input();
}
ofxPd& pd = *mPd;
// libpd ticks per buffer, 8 ticks * 64 bytes = buffer len 512
int ticksPerBuffer = 8;
int outChannels = 2;
int inChannels = inputChannelCount;
int sampleRate = 44100;
if (!pd.init(outChannels, inChannels, sampleRate, ticksPerBuffer)) {
console() << "ERROR: libpd didn't initialize." << std::endl;
}
// audio processing on
pd.dspOn();
// Everything beyond this point is test code to demonstrate usage
// add receive source names
pd.addSource("toOF");
pd.addSource("env");
// add listener
pd.addListener(*mPdListener);
pd.subscribe(*mPdListener); // listen to everything
pd.unsubscribe(*mPdListener, "env"); // don't listen to "env"
//pd.subscribe(*this, "toOF"); // listen to "toOF"
//pd.unsubscribe(*this); // don't listen to anything
// add the data/pd folder to the search path
pd.addToSearchPath("pd");
cout << endl << "BEGIN Patch Test" << endl;
//DataSourceRef data = app::App::loadResource(RES_TEST_PD);
//Buffer& buffer = data->getBuffer();
//const char* text = (const char*) buffer.getData();
Patch patch = pd.openPatch("resources", "test.pd"); //pd.openPatchFromText(text);
cout << patch << endl;
// close patch
pd.closePatch(patch);
cout << patch << endl;
// open patch
patch = pd.openPatch("resources", "test.pd"); //pd.openPatchFromText(text);
cout << patch << endl;
cout << "FINISH Patch Test" << endl;
cout << endl << "BEGIN Message Test" << endl;
// test basic atoms
pd.sendBang("fromOF");
pd.sendFloat("fromOF", 100);
pd.sendSymbol("fromOF", "test string");
// send a list
pd.startList("fromOF");
pd.addFloat(1.23);
pd.addSymbol("a symbol");
pd.finish();
// send a message to the $0 reciever ie $0-toOF
pd.startList(patch.dollarZeroStr()+"-fromOF");
pd.addFloat(1.23);
pd.addSymbol("a symbol");
pd.finish();
// send a list using the List object
List testList;
//.........这里部分代码省略.........
示例3: main
// Howdy gentle libpd user,
//
// This is just a simple test to make sure message passing in the libpd c++ layer
// is working. Like the C test, this simulates 10 seconds of logical audio time
// by calling processFloat in a for loop. Running this app will not produce any
// sound as it is not using an audio api. You need to add that yourself using
// something like PortAudio, Jack, etc as C++ does not have a default audio library.
//
int main(int argc, char **argv) {
// our pd engine
PdBase pd;
// one input channel, two output channels
// block size 64, one tick per buffer
float inbuf[64], outbuf[128];
// custom receiver object for messages and midi
PdObject pdObject;
// init pd
int srate = 44100;
if(!pd.init(1, 2, srate)) {
cerr << "Could not init pd" << endl;
exit(1);
}
int midiChan = 1; // midi channels are 0-15
// subscribe to receive source names
pd.subscribe("toCPP");
pd.subscribe("env");
// set receivers
pd.setReceiver(&pdObject);
pd.setMidiReceiver(&pdObject);
// add the data/pd folder to the search path
pd.addToSearchPath("pd");
// audio processing on
pd.computeAudio(true);
cout << endl << "BEGIN Patch Test" << endl;
// open patch
Patch patch = pd.openPatch("test.pd", ".");
cout << patch << endl;
// close patch
pd.closePatch(patch);
cout << patch << endl;
// open patch again
patch = pd.openPatch(patch);
cout << patch << endl;
cout << "FINISH Patch Test" << endl;
cout << endl << "BEGIN Message Test" << endl;
// test basic atoms
pd.sendBang("fromCPP");
pd.sendFloat("fromCPP", 100);
pd.sendSymbol("fromCPP", "test string");
// stream interface
pd << Bang("fromCPP")
<< Float("fromCPP", 100)
<< Symbol("fromCPP", "test string");
// send a list
pd.startMessage();
pd.addFloat(1.23);
pd.addSymbol("a symbol");
pd.finishList("fromCPP");
// send a message to the $0 receiver ie $0-toOF
pd.startMessage();
pd.addFloat(1.23);
pd.addSymbol("a symbol");
pd.finishList(patch.dollarZeroStr()+"-fromCPP");
// send a list using the List object
List testList;
testList.addFloat(1.23);
testList.addSymbol("sent from a List object");
pd.sendList("fromCPP", testList);
pd.sendMessage("fromCPP", "msg", testList);
// stream interface for list
pd << StartMessage() << 1.23 << "sent from a streamed list" << FinishList("fromCPP");
cout << "FINISH Message Test" << endl;
cout << endl << "BEGIN MIDI Test" << endl;
//.........这里部分代码省略.........
示例4: setup
//.........这里部分代码省略.........
// close patch
pd.closePatch(patch);
cout << patch << endl;
// open patch again
patch = pd.openPatch(patch);
cout << patch << endl;
cout << "FINISH Patch Test" << endl;
// -----------------------------------------------------
cout << endl << "BEGIN Message Test" << endl;
// test basic atoms
pd.sendBang("fromOF");
pd.sendFloat("fromOF", 100);
pd.sendSymbol("fromOF", "test string");
// stream interface
pd << Bang("fromOF")
<< Float("fromOF", 100)
<< Symbol("fromOF", "test string");
// send a list
pd.startMessage();
pd.addFloat(1.23);
pd.addSymbol("a symbol");
pd.finishList("fromOF");
// send a message to the $0 receiver ie $0-fromOF
pd.startMessage();
pd.addFloat(1.23);
pd.addSymbol("a symbol");
pd.finishList(patch.dollarZeroStr()+"-fromOF");
// send a list using the List object
List testList;
testList.addFloat(1.23);
testList.addSymbol("sent from a List object");
pd.sendList("fromOF", testList);
pd.sendMessage("fromOF", "msg", testList);
// stream interface for list
pd << StartMessage() << 1.23 << "sent from a streamed list" << FinishList("fromOF");
cout << "FINISH Message Test" << endl;
// -----------------------------------------------------
cout << endl << "BEGIN MIDI Test" << endl;
// send functions
pd.sendNoteOn(midiChan, 60);
pd.sendControlChange(midiChan, 0, 64);
pd.sendProgramChange(midiChan, 100); // note: pgm num range is 1 - 128
pd.sendPitchBend(midiChan, 2000); // note: ofxPd uses -8192 - 8192 while [bendin] returns 0 - 16383,
// so sending a val of 2000 gives 10192 in pd
pd.sendAftertouch(midiChan, 100);
pd.sendPolyAftertouch(midiChan, 64, 100);
pd.sendMidiByte(0, 239); // note: pd adds +2 to the port number from [midiin], [sysexin], & [realtimein]
pd.sendSysex(0, 239); // so sending to port 0 gives port 2 in pd
pd.sendSysRealTime(0, 239);
// stream
pd << NoteOn(midiChan, 60) << ControlChange(midiChan, 100, 64)
<< ProgramChange(midiChan, 100) << PitchBend(midiChan, 2000)
<< Aftertouch(midiChan, 100) << PolyAftertouch(midiChan, 64, 100)