andrew@0: #ifndef _TEST_APP andrew@0: #define _TEST_APP andrew@0: andrew@0: andrew@0: #include "ofMain.h" andrew@0: #include "sndfile.h" andrew@0: #include "ofxFileDialogOSX.h" andrew@0: #include "AudioFile.h" andrew@1: #include "AudioAnalysis.h" andrew@1: #include "SoundFileLoader.h" andrew@0: andrew@0: //note the dependency on sndfile (libsndfile library needs to be accessible) andrew@0: //also the file dialogue addon andrew@0: andrew@0: //#include andrew@0: //#include andrew@0: andrew@0: andrew@0: //main commands: andrew@0: //O: open a new file andrew@0: //see the key pressed function for other bits - e.g. can view spectral difference andrew@0: andrew@0: andrew@1: //#define FRAMESIZE 512 andrew@1: andrew@0: //length in terms of frames (at 512 samples per frame - there are 90 per second) => 900: 10 seconds andrew@0: andrew@0: class testApp : public ofBaseApp{ andrew@0: andrew@0: public: andrew@0: andrew@0: andrew@0: void setup(); andrew@0: void update(); andrew@0: void draw(); andrew@0: andrew@0: void keyPressed (int key); andrew@0: void keyReleased(int key); andrew@0: void mouseMoved(int x, int y ); andrew@0: void mouseDragged(int x, int y, int button); andrew@0: void mousePressed(int x, int y, int button); andrew@0: void mouseReleased(int x, int y, int button); andrew@0: void windowResized(int w, int h); andrew@0: andrew@0: void audioRequested (float * input, int bufferSize, int nChannels); andrew@0: void loadSndfile(); andrew@0: andrew@0: double getEnergyOfFrame(); andrew@0: // void putEnergyInFrame(); andrew@0: andrew@0: void initialiseVariables(); andrew@0: andrew@0: andrew@0: typedef std::vector DoubleVector; andrew@0: typedef std::vector DoubleMatrix; andrew@0: andrew@1: // DoubleMatrix chromaMatrix; andrew@1: // DoubleMatrix* matrixPtr; andrew@0: andrew@1: andrew@0: andrew@1: void drawDoubleMatrix(DoubleMatrix* dMatrix); andrew@1: // void drawSpectralDifference(DoubleMatrix* dMatrix); andrew@0: andrew@1: // DoubleVector firstEnergyVector; andrew@0: andrew@1: // void drawEnergyVectorFromPointer(DoubleVector* energyVec); andrew@0: andrew@1: // void processAudioToDoubleMatrix(Chromagram* chromaG, DoubleMatrix* myDoubleMatrix, DoubleVector* energyVector); andrew@0: andrew@0: void loadNewAudio(string soundFileName); andrew@0: andrew@0: void openFileDialogBox(); andrew@0: void loadLibSndFile(const char * filename); andrew@0: bool getFilenameFromDialogBox(string* fileNameToSave); andrew@0: void openNewAudioFileWithdialogBox(); andrew@0: andrew@0: double audioScale; andrew@0: andrew@0: string soundFileName; andrew@0: andrew@0: float pan; andrew@0: int sampleRate; andrew@0: bool bNoise; andrew@0: float volume; andrew@0: andrew@0: float * lAudio; andrew@0: float * rAudio; andrew@0: andrew@0: bool moveOn; andrew@0: bool drawSpectralDifferenceFunction; andrew@1: andrew@0: // int frameIndex; andrew@0: // float energy[ENERGY_LENGTH]; andrew@0: andrew@0: // float chromoGramVector[CHROMA_LENGTH][12]; andrew@0: // int rootChord[CHROMA_LENGTH]; andrew@0: andrew@0: // int energyIndex; andrew@1: andrew@1: // int totalFrames; andrew@0: int screenToDraw; andrew@0: andrew@0: int scrollWidth;// 1600 andrew@0: andrew@0: bool audioPlaying, audioPaused; andrew@0: andrew@0: andrew@0: andrew@0: //------------------- for the simple sine wave synthesis andrew@0: /* andrew@0: float targetFrequency; andrew@0: float phase; andrew@0: float phaseAdder; andrew@0: float phaseAdderTarget; andrew@0: */ andrew@0: string sndfileInfoString, textString; andrew@0: int xIndex; andrew@1: andrew@1: SoundFileLoader fileLoader; andrew@1: andrew@0: ofSoundPlayer loadedAudio; andrew@0: float audioPosition; andrew@0: float width, height; andrew@0: // int chromaIndex; andrew@0: int totalNumberOfFrames; andrew@1: andrew@0: string chordString; andrew@0: andrew@1: // Chromagram chromoGramm; andrew@0: andrew@1: // ChordDetect chord; andrew@1: andrew@1: // SNDFILE *infile; // define input and output sound files andrew@1: // SF_INFO sfinfo ; // struct to hold info about sound file andrew@0: andrew@0: andrew@0: }; andrew@0: andrew@0: #endif