summaryrefslogtreecommitdiff
path: root/audioin/src
diff options
context:
space:
mode:
Diffstat (limited to 'audioin/src')
-rw-r--r--audioin/src/ofApp.h43
1 files changed, 1 insertions, 42 deletions
diff --git a/audioin/src/ofApp.h b/audioin/src/ofApp.h
index 3ac6b39..8965aef 100644
--- a/audioin/src/ofApp.h
+++ b/audioin/src/ofApp.h
@@ -22,37 +22,7 @@ public:
if (data){
//delete[] data; //why is this throwing an error
}
- }
-/*
-if the size is 1000 and the num is 600
-1st frame: writePoint=0
-memcpy(&data[0],input,min(600,1000-0))
--> we copied the whole 600 starting at 0 and ending at 599
-2nd frame: writePoint=600
-memcpy(&data[600],input, min(600,1000-600))
--> we copied 400 starting at 600 and ending at 999
-yes (1000-600<600)
- so
- memcpy(data,&input[1000-600],600-(1000-600))
- -> we copied 200 starting at input:400 and ending at 599 to the start of data
- writePoint=600-(1000-600)
-3rd frame: writePoint=200
-memcpy(&data[200],input, min(600,1000-200))
--> we copied the whole 600 starting at 200 and ending at 799
-4th frame: writePoint=800
-memcpy(&data[800],input, min(600,1000-800))
--> we copied 200 starting at 800 and ending at 999
-yes (1000-800<600)
- so
- memcpy(data,&input[1000-800],600-(1000-800))
- -> we copied 400 starting at input:200 and ending at 599 to the start of data
- writePoint=600-(1000-800)
-5th frame: writePoint=400
-memcpy(&data[400],input, min(600,1000-400))
--> we copied the whole 600 starting at 400 and ending at 999
-
-back to square one. 5*600=3000
-*/
+ }
void add(float * input, int num){
memcpy(&data[writePoint],input,min(num,size-writePoint)*sizeof(float));
if (size-writePoint<num){ //we have to wrap
@@ -62,17 +32,6 @@ back to square one. 5*600=3000
}
else writePoint+=num;
}
-/*
-if size is 1000 and writePoint is 1000
-0: return data[1000]
-writePoint can never be 1000?
-
-if size is 1000 and writePoint is 800
-0: return data[800]
-1: return data[799]
-799: return data[1] --> this should be data[0] !?
-800: return data[1000-(800-800)->1000] -> this should be data[999]
-*/
float operator [] (int i) const {
return data[(writePoint>i?writePoint-i:size-(i-writePoint))-1];
}