rt300@0: /* rt300@0: * Copyright (c) 2011 Dan Wilcox rt300@0: * rt300@0: * BSD Simplified License. rt300@0: * For information on usage and redistribution, and for a DISCLAIMER OF ALL rt300@0: * WARRANTIES, see the file, "LICENSE.txt," in this distribution. rt300@0: * rt300@0: * See https://github.com/danomatika/ofxPd for documentation rt300@0: * rt300@0: */ rt300@0: #pragma once rt300@0: rt300@0: #include "ofMain.h" rt300@11: #include "boost/bind.hpp" rt300@11: #include "boost/function.hpp" rt300@11: #include "ofxPd.h" rt300@11: #include "globalVariables.h" rt300@0: rt300@0: rt300@0: // a namespace for the Pd types rt300@0: using namespace pd; rt300@0: rt300@0: class AppCore : public PdReceiver, public PdMidiReceiver { rt300@0: rt300@0: public: rt300@0: string patchName; rt300@0: // main rt300@0: void setup(const int numOutChannels, const int numInChannels, rt300@0: const int sampleRate, const int ticksPerBuffer); rt300@0: void update(); rt300@0: void draw(); rt300@0: void exit(); rt300@0: rt300@0: // do something rt300@0: void playTone(int pitch); rt300@0: rt300@0: // input callbacks rt300@0: void keyPressed(int key); rt300@0: rt300@0: // audio callbacks rt300@0: void audioReceived(float * input, int bufferSize, int nChannels); rt300@0: void audioRequested(float * output, int bufferSize, int nChannels); rt300@0: rt300@0: // pd message receiver callbacks rt300@0: void print(const std::string& message); rt300@0: rt300@0: void receiveBang(const std::string& dest); rt300@0: void receiveFloat(const std::string& dest, float value); rt300@0: void receiveSymbol(const std::string& dest, const std::string& symbol); rt300@0: void receiveList(const std::string& dest, const List& list); rt300@0: void receiveMessage(const std::string& dest, const std::string& msg, const List& list); rt300@0: rt300@0: // pd midi receiver callbacks rt300@0: void receiveNoteOn(const int channel, const int pitch, const int velocity); rt300@0: void receiveControlChange(const int channel, const int controller, const int value); rt300@0: void receiveProgramChange(const int channel, const int value); rt300@0: void receivePitchBend(const int channel, const int value); rt300@0: void receiveAftertouch(const int channel, const int value); rt300@0: void receivePolyAftertouch(const int channel, const int pitch, const int value); rt300@0: rt300@0: void receiveMidiByte(const int port, const int byte); rt300@0: rt300@0: // demonstrates how to manually poll for messages rt300@0: void processEvents(); rt300@0: rt300@0: ofxPd pd; rt300@0: vector scopeArray; rt300@0: rt300@0: int midiChan; rt300@11: vector tickListeners; rt300@11: rt300@11: // register for a clock tick rt300@11: void clockTickSender(int stepNo){ rt300@11: for(auto tli = tickListeners.begin(); tli < tickListeners.end(); tli++){ rt300@11: (*tli)(stepNo); rt300@11: } rt300@11: }; rt300@11: rt300@11: void addTickListener(TickListenerFunction listenerFunction) // virtual? rt300@11: { rt300@11: cout << "added tick listener" << endl; rt300@11: tickListeners.push_back(listenerFunction); rt300@11: }; rt300@0: };