summaryrefslogtreecommitdiff
path: root/vamphost
diff options
context:
space:
mode:
Diffstat (limited to 'vamphost')
-rw-r--r--vamphost/src/ofxVamphost.cpp5
-rw-r--r--vamphost/src/testApp.cpp129
-rwxr-xr-xvamphost/vamphost.cbp51
3 files changed, 121 insertions, 64 deletions
diff --git a/vamphost/src/ofxVamphost.cpp b/vamphost/src/ofxVamphost.cpp
index fc8bbf0..1ba2b4e 100644
--- a/vamphost/src/ofxVamphost.cpp
+++ b/vamphost/src/ofxVamphost.cpp
@@ -143,8 +143,8 @@ void Vamphost::process_frame(float *data,int samples_in_frame){
//when the frame is finished leave the partial block for the next frame
while(sample<samples_in_frame) {
while(sample<samples_in_frame&&in_block<blockSize) {
- for (int i=0;i<channels;i++) {}
- plugbuf[i][in_block]=data[0]; //sample];
+ for (int i=0;i<channels;i++) {
+ plugbuf[i][in_block]=data[sample];
}
in_block++;
sample++;
@@ -174,6 +174,7 @@ void Vamphost::process_frame(float *data,int samples_in_frame){
currentStep++;
}
}
+}
void Vamphost::cleanup(){
diff --git a/vamphost/src/testApp.cpp b/vamphost/src/testApp.cpp
index d04ce5c..b431fce 100644
--- a/vamphost/src/testApp.cpp
+++ b/vamphost/src/testApp.cpp
@@ -5,56 +5,56 @@ void testApp::setup() {
ofSetVerticalSync(true);
ofSetCircleResolution(80);
- ofBackground(54, 54, 54);
-
- // 0 output channels,
+ ofBackground(54, 54, 54);
+
+ // 0 output channels,
// 2 input channels
// 44100 samples per second
// 256 samples per buffer
// 4 num buffers (latency)
-
+
soundStream.listDevices();
-
- //if you want to set a different device id
+
+ //if you want to set a different device id
//soundStream.setDeviceID(0); //bear in mind the device id corresponds to all audio devices, including input-only and output-only devices.
-
+
int rate =44100;
- int channels=2;
+ int channels=1;
int outputNo=0;
string soname="qm-vamp-plugins";
string id="qm-tempotracker";
int bufferSize = vamphost.init(soname,id,channels,rate,outputNo);
-
-
+
+
left.assign(bufferSize, 0.0);
right.assign(bufferSize, 0.0);
volHistory.assign(400, 0.0);
-
+
bufferCounter = 0;
drawCounter = 0;
smoothedVol = 0.0;
scaledVol = 0.0;
-
- //if you want to set a different device id
+
+ //if you want to set a different device id
//soundStream.setDeviceID(0); //bear in mind the device id corresponds to all audio devices, including input-only and output-only devices.
-
+
soundStream.setup(this, 0, channels, rate, bufferSize, 4);
-
-
+
+ ofSetFrameRate(25);
}
//--------------------------------------------------------------
void testApp::update(){
- //lets scale the vol up to a 0-1 range
+ //lets scale the vol up to a 0-1 range
scaledVol = ofMap(smoothedVol, 0.0, 0.17, 0.0, 1.0, true);
//lets record the volume into an array
volHistory.push_back( scaledVol );
-
+
//if we are bigger the the size we want to record - lets drop the oldest value
if( volHistory.size() >= 400 ){
volHistory.erase(volHistory.begin(), volHistory.begin()+1);
@@ -66,121 +66,126 @@ void testApp::draw(){
ofSetColor(225);
ofDrawBitmapString("AUDIO INPUT EXAMPLE", 32, 32);
ofDrawBitmapString("press 's' to unpause the audio\n'e' to pause the audio", 31, 92);
-
+
ofNoFill();
-
+
// draw the left channel:
ofPushStyle();
ofPushMatrix();
ofTranslate(32, 170, 0);
-
+
ofSetColor(225);
ofDrawBitmapString("Left Channel", 4, 18);
-
- ofSetLineWidth(1);
+
+ ofSetLineWidth(1);
ofRect(0, 0, 512, 200);
ofSetColor(245, 58, 135);
ofSetLineWidth(3);
-
+
ofBeginShape();
- for (int i = 0; i < left.size(); i++){
- ofVertex(i*2, 100 -left[i]*180.0f);
+ for (int i = 0; i < left.size()/2; i++){
+ ofVertex(i, 100 -left[i*2]*180.0f);
}
ofEndShape(false);
-
+
ofPopMatrix();
ofPopStyle();
-
+ /*
// draw the right channel:
ofPushStyle();
ofPushMatrix();
ofTranslate(32, 370, 0);
-
+
ofSetColor(225);
ofDrawBitmapString("Right Channel", 4, 18);
-
- ofSetLineWidth(1);
+
+ ofSetLineWidth(1);
ofRect(0, 0, 512, 200);
ofSetColor(245, 58, 135);
ofSetLineWidth(3);
-
+
ofBeginShape();
- for (int i = 0; i < right.size(); i++){
- ofVertex(i*2, 100 -right[i]*180.0f);
+ for (int i = 0; i < right.size()/2; i++){
+ ofVertex(i, 100 -right[i*2]*180.0f);
}
ofEndShape(false);
-
+
ofPopMatrix();
ofPopStyle();
-
+
+ */
// draw the average volume:
ofPushStyle();
ofPushMatrix();
ofTranslate(565, 170, 0);
-
+
ofSetColor(225);
ofDrawBitmapString("Scaled average vol (0-100): " + ofToString(scaledVol * 100.0, 0), 4, 18);
ofRect(0, 0, 400, 400);
-
+
ofSetColor(245, 58, 135);
- ofFill();
+ ofFill();
ofCircle(200, 200, scaledVol * 190.0f);
-
+
//lets draw the volume history as a graph
ofBeginShape();
for (int i = 0; i < volHistory.size(); i++){
if( i == 0 ) ofVertex(i, 400);
ofVertex(i, 400 - volHistory[i] * 70);
-
+
if( i == volHistory.size() -1 ) ofVertex(i, 400);
}
- ofEndShape(false);
-
+ ofEndShape(false);
+
+ //draw the features history as alternate polygons in a 400x400 box : 16 seconds @ 25fps
+
ofPopMatrix();
ofPopStyle();
-
+
drawCounter++;
-
+
ofSetColor(225);
string reportString = "buffers received: "+ofToString(bufferCounter)+"\ndraw routines called: "+ofToString(drawCounter)+"\nticks: " + ofToString(soundStream.getTickCount());
+ reportString +="\nfeatures found: "+ofToString(vamphost.features.size());
ofDrawBitmapString(reportString, 32, 589);
-
+
}
-void testApp::audioIn(float * input, int bufferSize, int nChannels){
+void testApp::audioIn(float * input, int bufferSize, int nChannels){
float curVol = 0.0;
-
+
// samples are "interleaved"
- int numCounted = 0;
+ int numCounted = 0;
- //lets go through each sample and calculate the root mean square which is a rough way to calculate volume
+ //lets go through each sample and calculate the root mean square which is a rough way to calculate volume
for (int i = 0; i < bufferSize; i++){
- left[i] = input[i*2]*0.5;
- right[i] = input[i*2+1]*0.5;
+ //left[i] = input[i*2]*0.5;
+ //right[i] = input[i*2+1]*0.5;
+ left[i] = input[i]*0.5;
curVol += left[i] * left[i];
- curVol += right[i] * right[i];
- numCounted+=2;
+ //curVol += right[i] * right[i];
+ numCounted++;
}
-
- //this is how we get the mean of rms :)
+
+ //this is how we get the mean of rms :)
curVol /= (float)numCounted;
-
- // this is how we get the root of rms :)
+
+ // this is how we get the root of rms :)
curVol = sqrt( curVol );
-
+
smoothedVol *= 0.93;
smoothedVol += 0.07 * curVol;
-
+
bufferCounter++;
vamphost.process_frame(input,bufferSize);
-
+
}
//--------------------------------------------------------------
@@ -193,7 +198,7 @@ void testApp::keyPressed(int key){
if( key == 's' ){
soundStream.start();
}
-
+
if( key == 'e' ){
soundStream.stop();
}
diff --git a/vamphost/vamphost.cbp b/vamphost/vamphost.cbp
new file mode 100755
index 0000000..4137986
--- /dev/null
+++ b/vamphost/vamphost.cbp
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+ <FileVersion major="1" minor="6" />
+ <Project>
+ <Option title="vamphost" />
+ <Option makefile_is_custom="1" />
+ <Option pch_mode="2" />
+ <Option compiler="gcc" />
+ <Option virtualFolders="src/;build config/;" />
+ <Build>
+ <Target title="Debug">
+ <Option output="bin/$(PROJECT_NAME)_debug" prefix_auto="1" extension_auto="1" />
+ <Option working_dir="bin" />
+ <Option object_output="obj/Debug/" />
+ <Option external_deps="../openFrameworks/libs/openFrameworksCompiled/lib/linux/libopenFrameworksDebug.a;" />
+ <Option type="1" />
+ <Option compiler="gcc" />
+ <Option projectLinkerOptionsRelation="2" />
+ </Target>
+ <Target title="Release">
+ <Option output="bin/$(PROJECT_NAME)" prefix_auto="1" extension_auto="1" />
+ <Option working_dir="bin" />
+ <Option object_output="obj/Release/" />
+ <Option external_deps="../openFrameworks/libs/openFrameworksCompiled/lib/linux/libopenFrameworks.a;" />
+ <Option type="1" />
+ <Option compiler="gcc" />
+ <Option projectLinkerOptionsRelation="2" />
+ </Target>
+ </Build>
+ <Unit filename="addons.make">
+ <Option virtualFolder="build config/" />
+ </Unit>
+ <Unit filename="config.make">
+ <Option virtualFolder="build config" />
+ </Unit>
+ <Unit filename="src/main.cpp">
+ <Option virtualFolder="src/" />
+ </Unit>
+ <Unit filename="src/testApp.cpp">
+ <Option virtualFolder="src/" />
+ </Unit>
+ <Unit filename="src/testApp.h">
+ <Option virtualFolder="src/" />
+ </Unit>
+ <Extensions>
+ <code_completion />
+ <envvars />
+ <debugger />
+ </Extensions>
+ </Project>
+</CodeBlocks_project_file>