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