diff options
| author | Chris Kiefer <chrisk13fer@gmail.com> | 2012-07-26 16:04:47 +0100 |
|---|---|---|
| committer | Chris Kiefer <chrisk13fer@gmail.com> | 2012-07-26 16:04:47 +0100 |
| commit | 8963994c4769d32db3b36b03c7923e15f1133385 (patch) | |
| tree | 53d45c6acfd5a05b1a756ad0f116a8b275f59f54 | |
| parent | 0b4fcbac0ce9ede039355d4ece6d3ba5a4c6a92c (diff) | |
misc
| -rw-r--r-- | ofxMaxim/ofxMaxim/libs/fft.cpp | 2 | ||||
| -rw-r--r-- | ofxMaxim/ofxMaxim/libs/maxiFFT.cpp | 2 | ||||
| -rw-r--r-- | ofxMaxim/ofxMaxim/libs/maximilian.cpp | 31 | ||||
| -rwxr-xr-x | ofxMaxim/ofxMaxim/libs/maximilian.h | 11 | ||||
| -rw-r--r-- | ofxMaxim/ofxMaxim/src/ofxMaxim.h | 63 |
5 files changed, 97 insertions, 12 deletions
diff --git a/ofxMaxim/ofxMaxim/libs/fft.cpp b/ofxMaxim/ofxMaxim/libs/fft.cpp index 9fe812f..dddcd2a 100644 --- a/ofxMaxim/ofxMaxim/libs/fft.cpp +++ b/ofxMaxim/ofxMaxim/libs/fft.cpp @@ -597,7 +597,7 @@ void fft::inversePowerSpectrum_vdsp(int start, float *finalOut, float *window, f vDSP_fft_zrip(setupReal, &A, 1, log2n, FFT_INVERSE); vDSP_ztoc(&A, 1, (COMPLEX*) out_real, 2, half); - static float scale = 1./n; + float scale = 1./n; vDSP_vsmul(out_real, 1, &scale, out_real, 1, n); //multiply by window diff --git a/ofxMaxim/ofxMaxim/libs/maxiFFT.cpp b/ofxMaxim/ofxMaxim/libs/maxiFFT.cpp index 866be40..2ddefb4 100644 --- a/ofxMaxim/ofxMaxim/libs/maxiFFT.cpp +++ b/ofxMaxim/ofxMaxim/libs/maxiFFT.cpp @@ -203,7 +203,7 @@ void maxiFFTOctaveAnalyzer::setup(float samplingRate, int nBandsInTheFFT, int nA // fe: 2f for octave bands, sqrt(2) for half-octave bands, cuberoot(2) for third-octave bands, etc if (nAveragesPerOctave==0) // um, wtf? nAveragesPerOctave = 1; - nAveragesPerOctave = nAveragesPerOctave; +// nAveragesPerOctave = nAveragesPerOctave; averageFrequencyIncrement = pow(2.0f, 1.0f/(float)(nAveragesPerOctave)); // this isn't currently configurable (used once here then no effect), but here's some reasoning: // 43 is a good value if you want to approximate "computer" octaves: 44100/2/2/2/2/2/2/2/2/2/2 diff --git a/ofxMaxim/ofxMaxim/libs/maximilian.cpp b/ofxMaxim/ofxMaxim/libs/maximilian.cpp index 63c86cc..4a15aef 100644 --- a/ofxMaxim/ofxMaxim/libs/maximilian.cpp +++ b/ofxMaxim/ofxMaxim/libs/maximilian.cpp @@ -413,6 +413,7 @@ bool maxiSample::read() length=myDataSize*(0.5/myChannels); inFile.close(); // close the input file + cout << "Ch: " << myChannels << ", len: " << length << endl; if (myChannels>1) { int position=0; int channel=readChannel*2; @@ -441,16 +442,25 @@ double maxiSample::play() { } double maxiSample::playOnce() { - // long length=myDataSize*(0.5/myChannels); short* buffer = (short *)myData; - position=(position+1); - double remainder = position - (long) position; + position++; if ((long) position<length) - output = (double) ((1-remainder) * buffer[1+ (long) position] + remainder * buffer[2+(long) position])/32767;//linear interpolation - else - output=0; - - return(output); + output = (double) buffer[(long)position]/32767.0; + else { + output=0; + } + return output; + + // long length=myDataSize*(0.5/myChannels); +// short* buffer = (short *)myData; +// position=(position+1); +// double remainder = position - (long) position; +// if ((long) position<length) +// output = (double) ((1-remainder) * buffer[1+ (long) position] + remainder * buffer[2+(long) position])/32767;//linear interpolation +// else +// output=0; +// +// return(output); } double maxiSample::playOnce(double speed) { @@ -863,6 +873,11 @@ void maxiSample::clear() { memset(myData, 0, myDataSize); } +void maxiSample::reset() { + position=0; +} + + diff --git a/ofxMaxim/ofxMaxim/libs/maximilian.h b/ofxMaxim/ofxMaxim/libs/maximilian.h index 54e9ed6..eaae0d7 100755 --- a/ofxMaxim/ofxMaxim/libs/maximilian.h +++ b/ofxMaxim/ofxMaxim/libs/maximilian.h @@ -256,6 +256,8 @@ public: } void clear(); + + void reset(); double play(); @@ -308,9 +310,13 @@ public: // return 0; // } // write out the wav file - bool save() + bool save() { + save(myPath); + } + + bool save(string filename) { - fstream myFile (myPath.c_str(), ios::out | ios::binary); + fstream myFile (filename.c_str(), ios::out | ios::binary); // write the wav file per the wav file format myFile.seekp (0, ios::beg); @@ -508,6 +514,7 @@ public: env = release * (env - input) + input; return env; } + void reset() {env=0;} private: double attack, release, env; }; diff --git a/ofxMaxim/ofxMaxim/src/ofxMaxim.h b/ofxMaxim/ofxMaxim/src/ofxMaxim.h index ec8c539..b197723 100644 --- a/ofxMaxim/ofxMaxim/src/ofxMaxim.h +++ b/ofxMaxim/ofxMaxim/src/ofxMaxim.h @@ -52,4 +52,67 @@ typedef maxiSettings ofxMaxiSettings; typedef maxiMFCC ofxMaxiMFCC; +//typedef maxiSignal vector<double>; +// +//class maxiBase { +// virtual maxiSignal play() = {}; +//}; +// +//class ofMaxiSine : public maxiBase { +// maxiOsc osc; +// double freq; +// +// void update(double freq) { +// freq = freq; +// } +// void play() { +// osc.sine(freq); +// } +//} +// +// +//class maxiNoise : public maxiBase { +// maxiBase* update() { +// //do something? +// }; +// +// double play() { +// return rand() / (float)RAND_MAX; +// } +//}; +// +//class maxiAnotherUGen : public maxiBase { +// maxiBase* update(double param1, bool param2); +//}; +// +//class maxiYetAnotherUGen : public maxiBase { +// maxiBase* update(int something, float somethingElse); +//}; +// +//void maxiProcess(maxiSignal &signal, maxiBase *ugen) { +// double val = ugen->play(); +// for(int i=0; i < signal.size(); i++) { +// signal[i] = val; +// } +//} +// +//void maxiBlock(maxiSignal &signal, maxiBase *ugen) { +// for (int i=0; i < 64; i++) { +// maxiProcess(signal, ugen); +// } +//} +// +//typedef maxiUGens vector<maxiBase> +// +//maxiNoise ugen1; +//maxiAnotherUGen ugen2; +//maxiUGens ugen1 = createUGens(maxiNoise, 2); +// +//maxiSignal sig(2); +//maxiProcess(sig, ugen1.update()); +//maxiProcess(sig, ugen2.update(8.2, false)); +// +//ugen.update(2,3)->play(); + + #endif |
