aboutsummaryrefslogtreecommitdiffstats
path: root/maximilian.cpp
diff options
context:
space:
mode:
authorMick Grierson <mickgrierson@strangebook.lan>2011-10-12 00:23:56 +0100
committerMick Grierson <mickgrierson@strangebook.lan>2011-10-12 00:23:56 +0100
commita9b7b73bc1bbe47affa034a7dec09b7acbd0e267 (patch)
treead038c6ad424bb4abe4b3a5bf651a7adac07def5 /maximilian.cpp
parent5172ef13c1e5949eb80ffced4e85f6cafbb5b173 (diff)
Support for loading a specific channel from a stereo wav file as an argument to the load function. Default is channel 0
Diffstat (limited to 'maximilian.cpp')
-rw-r--r--maximilian.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/maximilian.cpp b/maximilian.cpp
index 3b4d660..a9cdcfc 100644
--- a/maximilian.cpp
+++ b/maximilian.cpp
@@ -332,8 +332,9 @@ double *maxiMix::ambisonic(double input,double eight[8],double x,double y,double
}
-bool maxiSample::load(string fileName) {
+bool maxiSample::load(string fileName, int channel) {
myPath = fileName;
+ readChannel=channel;
return read();
}
@@ -396,6 +397,16 @@ bool maxiSample::read()
length=myDataSize*(0.5/myChannels);
inFile.close(); // close the input file
+ if (myChannels>1) {
+ int position=0;
+ int channel=readChannel*2;
+ for (int i=channel;i<myDataSize;i+=(myChannels*2)) {
+ myData[position]=myData[i];
+ myData[position+1]=myData[i+1];
+ position+=2;
+ }
+ }
+
}else {
cout << "ERROR: Could not load sample: " <<myPath << endl;
}