aboutsummaryrefslogtreecommitdiffstats
path: root/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src
diff options
context:
space:
mode:
authorChris Kiefer <chrisk13fer@gmail.com>2012-02-22 12:10:20 +0000
committerChris Kiefer <chrisk13fer@gmail.com>2012-02-22 12:10:20 +0000
commit0c65d2ad2162db3ffbea3e3175675ad4b4598688 (patch)
tree5b1d6bd8b9dbe4069b8bf1a9bddb374d957c2cab /ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src
parent9f073116e8b21af58415204edecf42fec5f2c3ed (diff)
parentbb60cd352f53f4600913d2152032dd4aff228520 (diff)
resolved merge conflicts
Diffstat (limited to 'ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src')
-rw-r--r--ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/main.cpp16
-rw-r--r--ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp108
-rw-r--r--ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h37
-rw-r--r--ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/pyOSCDebug.cpp45
-rw-r--r--ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/pyOSCDebug.h24
5 files changed, 230 insertions, 0 deletions
diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/main.cpp b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/main.cpp
new file mode 100644
index 0000000..b232966
--- /dev/null
+++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/main.cpp
@@ -0,0 +1,16 @@
+#include "ofMain.h"
+#include "mp.h"
+#include "ofAppGlutWindow.h"
+
+//========================================================================
+int main( ){
+
+ ofAppGlutWindow window;
+ ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context
+
+ // this kicks off the running of my app
+ // can be OF_WINDOW or OF_FULLSCREEN
+ // pass in width and height too:
+ ofRunApp( new mp());
+
+}
diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp
new file mode 100644
index 0000000..57970cf
--- /dev/null
+++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp
@@ -0,0 +1,108 @@
+#include "mp.h"
+
+//--------------------------------------------------------------
+void mp::setup(){
+ ofEnableAlphaBlending();
+ ofSetupScreen();
+ ofBackground(0, 0, 0);
+ ofSetVerticalSync(true);
+// pyd.setup("localhost", 23612);
+// pyd.clear();
+
+
+ maxiAtomBook::loadMPTKXmlBook(ofToDataPath("book100.xml"), book);
+ sort(book.atoms.begin(), book.atoms.end(), maxiAtom::atomSortPositionAsc);
+ atomBuffer.resize(512);
+ atomData.resize(book.atoms[0]->length);
+
+ ofxMaxiSettings::setup(44100, 2, 512);
+ ofSoundStreamSetup(maxiSettings::channels,0,this, maxiSettings::sampleRate, maxiSettings::bufferSize, 4);/* Call this last ! */
+
+// flArr test;
+// maxiCollider::createGabor(test, maxiMap::linexp(atom->frequency, 0, 0.2, 20, 20000), 44100, atom->length, atom->phase, 0.3, atom->amp / 40.0);
+
+}
+
+
+
+//--------------------------------------------------------------
+void mp::update(){
+ flArr test;
+ //generate atoms from mouse position
+// maxiCollider::createGabor(test, maxiMap::linexp((float)mouseX/ofGetWidth(), 0, 1, 100, 10000) * (1.0 + (ofRandomuf() * 0.2)),
+// maxiSettings::sampleRate,
+// maxiMap::linlin((float)mouseY / ofGetHeight(), 0, 1, 2000, 40000) * (1.0 + (ofRandomuf() * 0.3)),
+// ofRandomf() * PI, 0.3, 0.05);
+// atomStream.addAtom(test);
+
+ //play book back one atom at a time
+// static int atomIdx=0;
+// maxiGaborAtom *atom = (maxiGaborAtom*) book.atoms[atomIdx % book.atoms.size()];
+// maxiCollider::createGabor(test, maxiMap::linlin(atom->frequency, 0.0, 1.0, 20, 20000), 44100, atom->length, atom->phase, 0.3, atom->amp / 30.0);
+// atomStream.addAtom(test);
+// atomIdx++;
+// cout << (atomIdx % book.atoms.size()) << ", " << maxiMap::linlin(atom->frequency, 0.0, 1.0, 20, 20000) << ", " << atom->amp << endl;
+
+}
+
+//--------------------------------------------------------------
+void mp::draw(){
+
+}
+
+void mp::audioRequested (float * output, int bufferSize, int nChannels){
+ atomPlayer.play(book, atomStream, output, bufferSize);
+
+ memset(&atomBuffer[0], 0, sizeof(float) * bufferSize);
+ atomStream.fillNextBuffer(&(atomBuffer[0]), bufferSize);
+ for (int i = 0; i < bufferSize; i++){
+ output[i*nChannels ] = output[i*nChannels + 1] = atomBuffer[i];
+ }
+
+}
+
+
+//--------------------------------------------------------------
+void mp::keyPressed(int key){
+
+}
+
+//--------------------------------------------------------------
+void mp::keyReleased(int key){
+
+}
+
+//--------------------------------------------------------------
+void mp::mouseMoved(int x, int y ){
+
+}
+
+//--------------------------------------------------------------
+void mp::mouseDragged(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void mp::mousePressed(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void mp::mouseReleased(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void mp::windowResized(int w, int h){
+
+}
+
+//--------------------------------------------------------------
+void mp::gotMessage(ofMessage msg){
+
+}
+
+//--------------------------------------------------------------
+void mp::dragEvent(ofDragInfo dragInfo){
+
+} \ No newline at end of file
diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h
new file mode 100644
index 0000000..1e8d6b6
--- /dev/null
+++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "ofMain.h"
+#include "ofxMaxim.h"
+#include "maxiAtoms.h"
+//#include "pyOSCDebug.h"
+
+class mp : public ofBaseApp{
+
+ public:
+ void setup();
+ void update();
+ void draw();
+
+ void keyPressed (int key);
+ void keyReleased(int key);
+ void mouseMoved(int x, int y );
+ void mouseDragged(int x, int y, int button);
+ void mousePressed(int x, int y, int button);
+ void mouseReleased(int x, int y, int button);
+ void windowResized(int w, int h);
+ void dragEvent(ofDragInfo dragInfo);
+ void gotMessage(ofMessage msg);
+
+ void audioRequested (float * input, int bufferSize, int nChannels); /* output method */
+
+// pyOSCDebug pyd;
+ maxiAccelerator atomStream;
+ maxiAtomBook book;
+ maxiAtomBookPlayer atomPlayer;
+
+ flArr atomBuffer;
+ flArr atomData;
+
+
+
+};
diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/pyOSCDebug.cpp b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/pyOSCDebug.cpp
new file mode 100644
index 0000000..3af8084
--- /dev/null
+++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/pyOSCDebug.cpp
@@ -0,0 +1,45 @@
+/*
+ * pyOSCDebug.cpp
+ * bastardPop
+ *
+ * Created by Chris on 25/10/2011.
+ * Copyright 2011 Goldsmiths Creative Computing. All rights reserved.
+ *
+ */
+
+#include "pyOSCDebug.h"
+
+pyOSCDebug::pyOSCDebug() {
+ ready = false;
+}
+
+void pyOSCDebug::setup(string host, int port) {
+ osc.setup(host, port);
+ ready = true;
+}
+
+void pyOSCDebug::clear() {
+ if (ready) {
+ ofxOscMessage m;
+ m.setAddress("/clear");
+ osc.sendMessage(m);
+ }
+}
+
+
+void pyOSCDebug::send(vector<float> data) {
+ send(&(data[0]), data.size());
+}
+
+void pyOSCDebug::send(float *data, unsigned int count) {
+ if (ready) {
+ ofxOscMessage m;
+ m.setAddress("/data");
+ for(int i=0; i < count; i++) {
+ m.addFloatArg(data[i]);
+ }
+ osc.sendMessage(m);
+ }
+}
+
+
diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/pyOSCDebug.h b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/pyOSCDebug.h
new file mode 100644
index 0000000..020f0fd
--- /dev/null
+++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/pyOSCDebug.h
@@ -0,0 +1,24 @@
+/*
+ * pyOSCDebug.h
+ * bastardPop
+ *
+ * Created by Chris on 25/10/2011.
+ * Copyright 2011 Goldsmiths Creative Computing. All rights reserved.
+ *
+ */
+
+#include "ofxOSC.h"
+#include <vector>
+
+class pyOSCDebug {
+public:
+ pyOSCDebug();
+ void setup(string host, int port);
+ void clear();
+ void send(vector<float> data);
+ void send(float *data, unsigned int count);
+private:
+ ofxOscSender osc;
+ bool ready;
+
+}; \ No newline at end of file