annotate src/timeWarp.h @ 1:6842ff391568

getting rid of pointer use in processAudio - not many changes
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Wed, 18 May 2011 16:47:12 +0100
parents 572c856e38ac
children f40577e6b30d
rev   line source
andrew@0 1 /*
andrew@0 2 * timeWarp.h
andrew@0 3 * chromaReader13
andrew@0 4 *
andrew@0 5 * Created by Andrew on 16/05/2011.
andrew@0 6 * Copyright 2011 QMUL. All rights reserved.
andrew@0 7 *
andrew@0 8 */
andrew@0 9
andrew@0 10 #ifndef _TIME_WARP
andrew@0 11 #define _TIME_WARP
andrew@0 12
andrew@0 13
andrew@0 14 #include "ofMain.h"
andrew@0 15 #include "chromaGram.h"
andrew@0 16 #include "ChordDetect.h"
andrew@0 17 #include "sndfile.h"
andrew@0 18 #include "ofxFileDialogOSX.h"
andrew@0 19
andrew@0 20
andrew@0 21 #define FRAMESIZE 512
andrew@0 22 #define ENERGY_LENGTH 80000
andrew@0 23 #define CHROMA_LENGTH 12000
andrew@0 24 #define CHROMA_CONVERSION_FACTOR 16 //16 times as many frames in energy as in chroma
andrew@0 25 //length in terms of frames (at 512 samples per frame - there are 90 per second) => 900: 10 seconds
andrew@0 26
andrew@0 27 class timeWarp : public ofBaseApp{
andrew@0 28
andrew@0 29 public:
andrew@0 30
andrew@0 31 /*
andrew@0 32 void setup();
andrew@0 33 void update();
andrew@0 34 void draw();
andrew@0 35
andrew@0 36 void keyPressed (int key);
andrew@0 37 void keyReleased(int key);
andrew@0 38 void mouseMoved(int x, int y );
andrew@0 39 void mouseDragged(int x, int y, int button);
andrew@0 40 void mousePressed(int x, int y, int button);
andrew@0 41 void mouseReleased(int x, int y, int button);
andrew@0 42 void windowResized(int w, int h);
andrew@0 43
andrew@0 44 void audioRequested (float * input, int bufferSize, int nChannels);
andrew@0 45 void loadSndfile();
andrew@0 46 */
andrew@0 47
andrew@0 48 double getEnergyOfFrame();
andrew@0 49 void putEnergyInFrame();
andrew@0 50
andrew@0 51 // void drawChromoGram();
andrew@0 52 // void loadFirstAudioFile();
andrew@0 53 void initialiseVariables();
andrew@0 54
andrew@0 55 //variables
andrew@0 56 typedef std::vector<double> DoubleVector;
andrew@0 57 typedef std::vector<DoubleVector> DoubleMatrix;
andrew@0 58
andrew@0 59 DoubleMatrix chromaMatrix;
andrew@0 60 DoubleMatrix secondMatrix;
andrew@0 61 DoubleMatrix* matrixPtr;
andrew@0 62
andrew@0 63 // void drawDoubleMatrix(DoubleMatrix* dMatrix);//DoubleMatrix* dMatrix); WOULD BE NICE TO USE POINTER BUT NOT WORKING YET
andrew@0 64 // void drawSpectralDifference(DoubleMatrix* dMatrix);
andrew@0 65
andrew@0 66 DoubleVector firstEnergyVector;
andrew@0 67 DoubleVector secondEnergyVector;
andrew@0 68
andrew@0 69 DoubleMatrix similarityMatrix;
andrew@0 70
andrew@0 71 void calculateSimilarityMatrix();
andrew@0 72
andrew@0 73 // bool drawSimilarity;
andrew@0 74 // void drawSimilarityMatrix();
andrew@0 75 // void printSimilarityMatrix(int sizeToPrint);
andrew@0 76
andrew@1 77 Chromagram chromoGramm;
andrew@1 78 Chromagram secondChromoGramm;
andrew@1 79
andrew@1 80
andrew@1 81 DoubleMatrix alignmentMeasureMatrix;//just the choma alignment
andrew@0 82 DoubleVector minimumAlignmentPath;
andrew@0 83
andrew@1 84 //new addition
andrew@1 85 DoubleMatrix superAlignmentMeasureMatrix; //for the onset + chromagram alignment
andrew@1 86 DoubleVector superMinimumAlignmentPath;
andrew@1 87
andrew@0 88 // void drawAlignmentPath(int startingChromaXFrame, int startingChromaYFrame);
andrew@0 89 int findStartWidthFrame();
andrew@0 90
andrew@0 91 // void printScoreForRow(int row, int max);
andrew@0 92
andrew@0 93 // int numberOfScrollWidthsForFirstFile;
andrew@0 94 // int numberOfScrollWidthsForSecondFile;
andrew@0 95 // void checkIfAudioPositionExceedsWidthForFirstFile();
andrew@0 96
andrew@0 97 typedef std::vector<int> IntVector;
andrew@0 98 typedef std::vector<IntVector> IntMatrix;
andrew@0 99
andrew@0 100 // void updateAlignmentPathIndex(int idenifier);
andrew@0 101
andrew@0 102 IntMatrix backwardsAlignmentPath;
andrew@0 103 int backwardsAlignmentIndex;
andrew@0 104
andrew@0 105 bool findPreviousMinimumInBackwardsPath();
andrew@0 106 bool testForNewAlignmentMinimum(double *previousMinimum, int i, int j);
andrew@0 107
andrew@0 108 void calculateAlignmentMatrix();
andrew@0 109 double getDistance(int i, int j);
andrew@1 110 // void printAlignmentMatrix();
andrew@0 111 double getMinimum(int i, int j, float newValue);
andrew@0 112 bool extendAlignmentUp();
andrew@0 113 bool extendAlignmentAlong();
andrew@0 114 void calculateMinimumAlignmentPath();
andrew@0 115 int findMinimumOfVector(DoubleVector *d);
andrew@0 116 // void swapBetweenPlayingFilesUsingAlignmentMatch();
andrew@0 117 // int findMatchFromAlignment(bool whichFileToTest);
andrew@0 118
andrew@0 119 // void drawEnergyVectorFromPointer(DoubleVector* energyVec);
andrew@0 120
andrew@0 121 // void processAudioToDoubleMatrix(Chromagram* chromaG, DoubleMatrix* myDoubleMatrix, DoubleVector* energyVector);
andrew@0 122
andrew@0 123
andrew@0 124
andrew@0 125
andrew@0 126
andrew@0 127
andrew@0 128
andrew@0 129 // void loadNewAudio(string soundFileName);
andrew@0 130 // void loadSecondAudio(string soundFileName);
andrew@0 131
andrew@0 132 // void loadSoundFiles();
andrew@0 133 // void openFileDialogBox();
andrew@0 134 // void loadLibSndFile(const char * filename);
andrew@0 135 // bool getFilenameFromDialogBox(string* fileNameToSave);
andrew@0 136 // void openNewAudioFileWithdialogBox();
andrew@0 137
andrew@0 138 //int* firstAudioLength, secondAudioLength;
andrew@0 139
andrew@0 140 // string soundFileName, secondFileName;
andrew@0 141
andrew@0 142 // float screenHeight, screenWidth;
andrew@0 143
andrew@0 144
andrew@0 145 // bool moveOn;
andrew@0 146 // bool drawSpectralDifferenceFunction;
andrew@0 147
andrew@0 148 float frame[FRAMESIZE];
andrew@0 149
andrew@0 150 float diagonalPenalty;
andrew@0 151
andrew@0 152 // int frameIndex;
andrew@0 153
andrew@0 154 // float chromoGramVector[CHROMA_LENGTH][12];
andrew@0 155 // int rootChord[CHROMA_LENGTH];
andrew@0 156
andrew@0 157 // int energyIndex;
andrew@0 158 // int totalFrames;
andrew@0 159
andrew@0 160 // int scrollWidth;// 1600
andrew@0 161 // float chromoLength;
andrew@0 162
andrew@0 163 // bool audioPlaying, audioPaused;
andrew@0 164 // bool drawSecondMatrix;
andrew@0 165
andrew@0 166 /*
andrew@0 167
andrew@0 168
andrew@0 169 //------------------- for the simple sine wave synthesis
andrew@0 170 float targetFrequency;
andrew@0 171 float phase;
andrew@0 172 float phaseAdder;
andrew@0 173 float phaseAdderTarget;
andrew@0 174
andrew@0 175 string sndfileInfoString, textString;
andrew@0 176 int xIndex;
andrew@0 177
andrew@0 178 bool firstAudioFilePlaying;
andrew@0 179 ofSoundPlayer loadedAudio;
andrew@0 180 ofSoundPlayer secondAudio;
andrew@0 181 ofSoundPlayer *playingAudio;
andrew@0 182
andrew@0 183 */
andrew@0 184 // float audioPosition;
andrew@0 185 // float width, height;
andrew@0 186 // int chromaIndex;
andrew@0 187 // int totalNumberOfFrames;
andrew@0 188 // int currentPlayingFrame;
andrew@0 189 // int currentChromaFrame ;
andrew@0 190
andrew@0 191 // string chordString;
andrew@0 192
andrew@0 193 //Chromagram* chromoGrammPtr;
andrew@0 194
andrew@0 195
andrew@0 196
andrew@0 197
andrew@0 198 // string userInfoString;
andrew@0 199 // ChordDetect chord;
andrew@0 200 //sndfile part
andrew@0 201 // SNDFILE *infile; // define input and output sound files
andrew@0 202 // SF_INFO sfinfo ; // struct to hold info about sound file
andrew@0 203
andrew@0 204
andrew@0 205 };
andrew@0 206
andrew@0 207 #endif