From b86dfa8f6f99713ee4605c30ebb1a58309aaeb8a Mon Sep 17 00:00:00 2001 From: mick grierson Date: Mon, 29 Jun 2015 15:57:31 +0100 Subject: Updating post-hackday --- .../src/main.cpp | 8 - .../src/ofApp.cpp | 264 --------------------- .../ofxMaximExample_0.8.4_OSX_Granular/src/ofApp.h | 77 ------ 3 files changed, 349 deletions(-) delete mode 100755 ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/main.cpp delete mode 100755 ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/ofApp.cpp delete mode 100755 ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/ofApp.h (limited to 'ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src') diff --git a/ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/main.cpp b/ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/main.cpp deleted file mode 100755 index a2c9990..0000000 --- a/ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/main.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "ofMain.h" -#include "ofApp.h" - -int main(){ - ofSetupOpenGL(1024,768, OF_WINDOW); // <-------- setup the GL context - - ofRunApp(new ofApp); -} diff --git a/ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/ofApp.cpp b/ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/ofApp.cpp deleted file mode 100755 index f6a08e8..0000000 --- a/ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/ofApp.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* This is an example of how to integrate maximilain into openFrameworks, - including using audio received for input and audio requested for output. - - - You can copy and paste this and use it as a starting example. - - */ - -#include "ofApp.h" -//#include "maximilian.h"/* include the lib */ -#include "time.h" - - -//-------------------------------------------------------------- -void ofApp::setup(){ - - /* This is stuff you always need.*/ - - sender.setup(HOST, SENDPORT); - receiver.setup(RECEIVEPORT); - - - //samples from http://freesound.org - samp.load(ofToDataPath("2630__Jovica__133_bpm_ATTACK_LOOP_04_electrified_analog_kit_variation_16_mono.wav")); - samp2.load(ofToDataPath("24620__anamorphosis__GMB_Kantilan_1.wav")); - samp3.load(ofToDataPath("26393__brfindla__Calango1berimbau.wav")); - samp4.load(ofToDataPath("68373__juskiddink__Cello_open_string_bowed.wav")); - samp5.load(ofToDataPath("71515__Microscopia__Wilhelm_Bruder_Sohne_Organ.wav")); - // samp5.load(ofToDataPath("sine1sec.wav")); - - - ofEnableAlphaBlending(); - ofSetupScreen(); - ofBackground(0, 0, 0); - ofSetFrameRate(60); - - sampleRate = 44100; /* Sampling Rate */ - bufferSize = 512; /* Buffer Size. you have to fill this buffer with sound using the for loop in the audioOut method */ - - - - ts = new maxiTimestretch(&samp); - ts2 = new maxiTimestretch(&samp2); - ts3 = new maxiTimestretch(&samp3); - ts4 = new maxiTimestretch(&samp4); - ts5 = new maxiTimestretch(&samp5); - stretches.push_back(ts); - stretches.push_back(ts2); - stretches.push_back(ts3); - stretches.push_back(ts4); - stretches.push_back(ts5); - speed = 1; - grainLength = 0.05; - current=0; - - fft.setup(1024, 512, 256); - oct.setup(44100, 1024, 10); - - int current = 0; - ofxMaxiSettings::setup(sampleRate, 2, initialBufferSize); - - ofSetVerticalSync(true); - ofEnableAlphaBlending(); - ofEnableSmoothing(); - - /* Anything that you would normally find/put in maximilian's setup() method needs to go here. For example, Sample loading. - - */ - - isTraining=true; - - ofBackground(255,255,255); - - ofSoundStreamSetup(2,2,this, sampleRate, bufferSize, 4); /* this has to happen at the end of setup - it switches on the DAC */ - - -} - -//-------------------------------------------------------------- -void ofApp::update(){ - - //WEKINATOR - if (!isTraining) { - - - while(receiver.hasWaitingMessages()){ - // get the next message - ofxOscMessage m; - receiver.getNextMessage(&m); - - // check for mouse moved message - if(m.getAddress() == "/wek/outputs"){ - - cout << m.getArgAsFloat(0); - speed = ((double ) m.getArgAsFloat(0) * 4.0) - 2.0; - grainLength = (m.getArgAsFloat(1) * 0.1) + 0.001; - pos = ((double) m.getArgAsFloat(0) * 2.0); - - } - } - - } - - -} - -//-------------------------------------------------------------- -void ofApp::draw(){ - - /* You can use any of the data from audio received and audiorequested to draw stuff here. - Importantly, most people just use the input and output arrays defined above. - Clever people don't do this. This bit of code shows that by default, each signal is going to flip - between -1 and 1. You need to account for this somehow. Get the absolute value for example. - */ - - ofSetColor(160,32,240, 150); - ofDrawBitmapString(":: ofxMaxim Granular Timestretching Example ::", 10,20); - ofDrawBitmapString("Move the mouse left to right to change playback speed and direction.", 10,40); - ofDrawBitmapString("Move the mouse up and down to change the grain length.", 10,60); - ofDrawBitmapString("Click to cycle through samples.", 10,80); - - stringstream s; - s << "Speed: " << speed; - ofDrawBitmapString(s.str(), 10,750); - s.str(""); - s << "Grain length: " << round(grainLength*1000.0) << " ms"; - ofDrawBitmapString(s.str(), 180,750); - - ofNoFill(); - for(int i=0; i < oct.nAverages; i++) { - ofSetColor(200 + ((int)(ofGetFrameNum() * 0.8) % 255), - 100 + ((int)(ofGetFrameNum() * 1.4) % 255), - ofGetFrameNum() % 255, - oct.averages[i] / 20.0 * 255.0); - // ofCircle(ofGetWidth() / 2, ofGetHeight()/2, i * 5); - glPushMatrix(); - glTranslatef(ofGetWidth()/2,ofGetHeight()/2, 0); - glRotatef(0.01 * ofGetFrameNum() * speed * i, 1, 0.1, 0); - // glutWireSphere(i * 5, 2 + (10 - (fabs(speed) * 10)), 2 + (fabs(speed) * 10)); - ofSphere(0, 0, i * 5); - glPopMatrix(); - } - - - - -} - -//-------------------------------------------------------------- -void ofApp::audioOut(float * output, int bufferSize, int nChannels) { - - - for (int i = 0; i < bufferSize; i++){ - - /* Stick your maximilian 'play()' code in here ! Declare your objects in testApp.h. - - For information on how maximilian works, take a look at the example code at - - http://www.maximilian.strangeloop.co.uk - - under 'Tutorials'. - - */ - - - // wave = stretches[current]->play(speed, grainLength, 5, 0); - wave = stretches[current]->play(speed, 0.1, 4, 0); - // wave = stretches[current]->play2(pos, 0.1, 4); - if (fft.process(wave)) { - oct.calculate(fft.magnitudes); - } - - //play result - mymix.stereo(wave, outputs, 0.5); - output[i*nChannels ] = outputs[0]; /* You may end up with lots of outputs. add them here */ - output[i*nChannels + 1] = outputs[1]; - - - - /* You may end up with lots of outputs. add them here */ - - - } - -} - -//-------------------------------------------------------------- -void ofApp::audioIn(float * input, int bufferSize, int nChannels){ - - // samples are "interleaved" - for(int i = 0; i < bufferSize; i++){ - /* you can also grab the data out of the arrays*/ - - } - -} - - -//-------------------------------------------------------------- -void ofApp::keyPressed(int key){ - - isTraining=!isTraining; - - cout << isTraining; - -} - -//-------------------------------------------------------------- -void ofApp::keyReleased(int key){ - -} - -//-------------------------------------------------------------- -void ofApp::mouseMoved(int x, int y){ - - if (isTraining) { - - speed = ((double ) x / ofGetWidth() * 4.0) - 2.0; - grainLength = ((double) y / ofGetHeight() * 0.1) + 0.001; - pos = ((double) x / ofGetWidth() * 2.0); - // cout << pos << endl; - - ofxOscMessage m; - m.setAddress("/wekinator/control/outputs"); - m.addFloatArg((float)x/ofGetWidth()); - m.addFloatArg((float)y/ofGetHeight()); - m.addFloatArg((float)current/stretches.size()-1); - sender.sendMessage(m); - cout << "messageSent" << "\n"; - } - - -} - -//-------------------------------------------------------------- -void ofApp::mouseDragged(int x, int y, int button){ - -} - -//-------------------------------------------------------------- -void ofApp::mousePressed(int x, int y, int button){ - if (++current > stretches.size()-1) current = 0; - -} - -//-------------------------------------------------------------- -void ofApp::mouseReleased(int x, int y, int button){ - -} - -//-------------------------------------------------------------- -void ofApp::windowResized(int w, int h){ - -} - -//-------------------------------------------------------------- -void ofApp::gotMessage(ofMessage msg){ - -} - -//-------------------------------------------------------------- -void ofApp::dragEvent(ofDragInfo dragInfo){ - -} diff --git a/ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/ofApp.h b/ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/ofApp.h deleted file mode 100755 index bad37f9..0000000 --- a/ofxMaxim/HACKDAY/ofxMaximExample_0.8.4_OSX_Granular/src/ofApp.h +++ /dev/null @@ -1,77 +0,0 @@ -#pragma once - -#include "ofMain.h" -#include "ofxMaxim.h" -#include "ofxMaxim.h" -#include "maxiGrains.h" -#include "ofxOsc.h" -#include - -#define HOST "localhost" -#define RECEIVEPORT 12000 -#define SENDPORT 6448 - -typedef hannWinFunctor grainPlayerWin; - - -class ofApp : 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 audioOut(float * output, int bufferSize, int nChannels); - void audioIn(float * input, int bufferSize, int nChannels); - - int bufferSize; - - /* stick you maximilian declarations below - - For information on how maximilian works, take a look at the example code at - - http://www.maximilian.strangeloop.co.uk - - under 'Tutorials'. - - - */ - - - int initialBufferSize; /* buffer size */ - int sampleRate; - - - /* stick your maximilian stuff below */ - - double wave,sample,outputs[2]; - maxiSample samp, samp2, samp3, samp4, samp5; - vector*> stretches; - maxiMix mymix; - maxiTimestretch *ts, *ts2, *ts3, *ts4, *ts5; - double speed, grainLength; - - ofxMaxiFFT fft; - ofxMaxiFFTOctaveAnalyzer oct; - int current; - double pos; - - //osc - ofxOscSender sender; - ofxOscReceiver receiver; - - bool isTraining; - -}; - - -- cgit v1.3