Mercurial > hg > audio-time-warp
view src/testApp.h @ 0:572c856e38ac
Starting up openFrameworks project for audio time warping. The ofxFileReader goes in addons of your OF folder, the libraries and source (chromogram, fftw and source code src+ timewarp) are probably best kept in the repository, then dragged into the project afresh. That way, as we update the repository, the code that the openFrameworks project looks for will be updated.
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Tue, 17 May 2011 08:48:58 +0100 |
parents | |
children | 6842ff391568 |
line wrap: on
line source
#ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" #include "chromaGram.h" #include "ChordDetect.h" #include "sndfile.h" #include "ofxFileDialogOSX.h" #include "timeWarp.h" //#include <vector> //#include <cstdlib> #define FRAMESIZE 512 #define ENERGY_LENGTH 80000 #define CHROMA_LENGTH 12000 #define CHROMA_CONVERSION_FACTOR 16 //16 times as many frames in energy as in chroma //length in terms of frames (at 512 samples per frame - there are 90 per second) => 900: 10 seconds class testApp : public ofBaseApp{ public: void setup(); void update(); void draw(); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); void audioRequested (float * input, int bufferSize, int nChannels); void loadSndfile(); double getEnergyOfFrame(); void drawChromoGram(); void loadFirstAudioFile(); void initialiseVariables(); typedef std::vector<double> DoubleVector; typedef std::vector<DoubleVector> DoubleMatrix; // DoubleMatrix chromaMatrix; // DoubleMatrix secondMatrix; DoubleMatrix* matrixPtr; void drawDoubleMatrix(DoubleMatrix* dMatrix);//DoubleMatrix* dMatrix); WOULD BE NICE TO USE POINTER BUT NOT WORKING YET void drawSpectralDifference(DoubleMatrix* dMatrix); // DoubleVector firstEnergyVector; // DoubleVector secondEnergyVector; // DoubleMatrix similarityMatrix; void calculateSimilarityMatrix(); bool drawSimilarity; void drawSimilarityMatrix(); void printSimilarityMatrix(int sizeToPrint); // DoubleMatrix alignmentMeasureMatrix; // DoubleVector minimumAlignmentPath; void drawAlignmentPath(int startingChromaXFrame, int startingChromaYFrame); int findStartWidthFrame(); void printScoreForRow(int row, int max); int numberOfScrollWidthsForFirstFile; int numberOfScrollWidthsForSecondFile; void checkIfAudioPositionExceedsWidthForFirstFile(); typedef std::vector<int> IntVector; typedef std::vector<IntVector> IntMatrix; // IntMatrix backwardsAlignmentPath; int backwardsAlignmentIndex;//used for drawing the path void updateAlignmentPathIndex(int idenifier); // bool checkWhetherOnAlignmentPath(int xcoord, int ycoord, int *indexOfAlignmentPathTested); bool findPreviousMinimumInBackwardsPath(); bool testForNewAlignmentMinimum(double *previousMinimum, int i, int j); void calculateAlignmentMatrix(); // void performNextAlignment(); double getDistance(int i, int j); void printAlignmentMatrix(); double getMinimum(int i, int j, float newValue); bool extendAlignmentUp(); bool extendAlignmentAlong(); void calculateMinimumAlignmentPath(); int findMinimumOfVector(DoubleVector *d); void swapBetweenPlayingFilesUsingAlignmentMatch(); int findMatchFromAlignment(bool whichFileToTest); void drawEnergyVectorFromPointer(DoubleVector* energyVec); void processAudioToDoubleMatrix(Chromagram* chromaG, DoubleMatrix* myDoubleMatrix, DoubleVector* energyVector); void loadNewAudio(string soundFileName); void loadSecondAudio(string soundFileName); void loadSoundFiles(); void openFileDialogBox(); void loadLibSndFile(const char * filename); bool getFilenameFromDialogBox(string* fileNameToSave); void openNewAudioFileWithdialogBox(); //int* firstAudioLength, secondAudioLength; string soundFileName, secondFileName; float screenHeight, screenWidth; float pan; int sampleRate; bool bNoise; float volume; float * lAudio; float * rAudio; bool moveOn; bool drawSpectralDifferenceFunction; float frame[FRAMESIZE]; int frameIndex; float energy[ENERGY_LENGTH]; float secondEnergy[ENERGY_LENGTH]; float chromoGramVector[CHROMA_LENGTH][12]; int rootChord[CHROMA_LENGTH]; // int energyIndex; // int totalFrames; int scrollWidth;// 1600 float chromoLength; bool audioPlaying, audioPaused; bool drawSecondMatrix; float diagonalPenalty; //------------------- for the simple sine wave synthesis float targetFrequency; float phase; float phaseAdder; float phaseAdderTarget; string sndfileInfoString, textString; int xIndex; bool firstAudioFilePlaying; ofSoundPlayer loadedAudio; ofSoundPlayer secondAudio; ofSoundPlayer *playingAudio; float audioPosition; float width, height; int chromaIndex; int totalNumberOfFrames; int currentPlayingFrame; int currentChromaFrame ; string chordString; //Chromagram* chromoGrammPtr; Chromagram chromoGramm; Chromagram secondChromoGramm; string userInfoString; ChordDetect chord; //sndfile part SNDFILE *infile; // define input and output sound files SF_INFO sfinfo ; // struct to hold info about sound file timeWarp tw; }; #endif