From 8963994c4769d32db3b36b03c7923e15f1133385 Mon Sep 17 00:00:00 2001 From: Chris Kiefer Date: Thu, 26 Jul 2012 16:04:47 +0100 Subject: misc --- ofxMaxim/ofxMaxim/libs/fft.cpp | 2 +- ofxMaxim/ofxMaxim/libs/maxiFFT.cpp | 2 +- ofxMaxim/ofxMaxim/libs/maximilian.cpp | 31 ++++++++++++----- ofxMaxim/ofxMaxim/libs/maximilian.h | 11 ++++-- 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; +// +//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 +// +//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 -- cgit v1.3