aboutsummaryrefslogtreecommitdiffstats
path: root/ofxMaxim/openFrameworksExamples/windows/ofMaximExampleVS2010/src/testApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ofxMaxim/openFrameworksExamples/windows/ofMaximExampleVS2010/src/testApp.cpp')
-rwxr-xr-xofxMaxim/openFrameworksExamples/windows/ofMaximExampleVS2010/src/testApp.cpp156
1 files changed, 156 insertions, 0 deletions
diff --git a/ofxMaxim/openFrameworksExamples/windows/ofMaximExampleVS2010/src/testApp.cpp b/ofxMaxim/openFrameworksExamples/windows/ofMaximExampleVS2010/src/testApp.cpp
new file mode 100755
index 0000000..bfef498
--- /dev/null
+++ b/ofxMaxim/openFrameworksExamples/windows/ofMaximExampleVS2010/src/testApp.cpp
@@ -0,0 +1,156 @@
+#include "testApp.h"
+#include "maximilian.h"
+
+//--------------------------------------------------------------
+void testApp::setup(){
+
+ ofBackground(34, 34, 34);
+
+ // 2 output channels,
+ // 0 input channels
+ // 22050 samples per second
+ // 512 samples per buffer
+ // 4 num buffers (latency)
+
+ int bufferSize = 512;
+ sampleRate = 44100;
+
+ lAudio.assign(bufferSize, 0.0);
+ rAudio.assign(bufferSize, 0.0);
+
+ //soundStream.listDevices();
+
+ //if you want to set the device id to be different than the default
+ //soundStream.setDeviceID(1); //note some devices are input only and some are output only
+
+ soundStream.setup(this, 2, 0, sampleRate, bufferSize, 4);
+
+ ofSetFrameRate(60);
+}
+
+
+//--------------------------------------------------------------
+void testApp::update(){
+
+}
+
+//--------------------------------------------------------------
+void testApp::draw(){
+
+ ofSetColor(225);
+ ofDrawBitmapString("AUDIO OUTPUT EXAMPLE", 32, 32);
+ ofDrawBitmapString("press 's' to unpause the audio\npress 'e' to pause the audio", 31, 92);
+
+ ofNoFill();
+
+ // draw the left channel:
+ ofPushStyle();
+ ofPushMatrix();
+ ofTranslate(32, 150, 0);
+
+ ofSetColor(225);
+ ofDrawBitmapString("Left Channel", 4, 18);
+
+ ofSetLineWidth(1);
+ ofRect(0, 0, 900, 200);
+
+ ofSetColor(245, 58, 135);
+ ofSetLineWidth(3);
+
+ ofBeginShape();
+ for (int i = 0; i < lAudio.size(); i++){
+ float x = ofMap(i, 0, lAudio.size(), 0, 900, true);
+ ofVertex(x, 100 -lAudio[i]*180.0f);
+ }
+ ofEndShape(false);
+
+ ofPopMatrix();
+ ofPopStyle();
+
+ // draw the right channel:
+ ofPushStyle();
+ ofPushMatrix();
+ ofTranslate(32, 350, 0);
+
+ ofSetColor(225);
+ ofDrawBitmapString("Right Channel", 4, 18);
+
+ ofSetLineWidth(1);
+ ofRect(0, 0, 900, 200);
+
+ ofSetColor(245, 58, 135);
+ ofSetLineWidth(3);
+
+ ofBeginShape();
+ for (int i = 0; i < rAudio.size(); i++){
+ float x = ofMap(i, 0, rAudio.size(), 0, 900, true);
+ ofVertex(x, 100 -rAudio[i]*180.0f);
+ }
+ ofEndShape(false);
+
+ ofPopMatrix();
+ ofPopStyle();
+
+}
+
+
+//--------------------------------------------------------------
+void testApp::keyPressed (int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::keyReleased (int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseMoved(int x, int y ){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseDragged(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mousePressed(int x, int y, int button){
+
+}
+
+
+//--------------------------------------------------------------
+void testApp::mouseReleased(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::windowResized(int w, int h){
+
+}
+
+//--------------------------------------------------------------
+void testApp::audioOut(float * output, int bufferSize, int nChannels){
+
+
+ for (int i = 0; i < bufferSize; i++){
+
+ sample=test1.sinewave(440);
+
+ lAudio[i] = output[i*nChannels ] = sample;
+ rAudio[i] = output[i*nChannels + 1] = sample;
+
+ }
+
+}
+
+//--------------------------------------------------------------
+void testApp::gotMessage(ofMessage msg){
+
+}
+
+//--------------------------------------------------------------
+void testApp::dragEvent(ofDragInfo dragInfo){
+
+}