annotate src/testApp.h @ 2:fa2af670b5c5 tip

SoundFileLoader might have moved
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Fri, 06 Jan 2012 00:23:26 +0000
parents ba2a17cf81bf
children
rev   line source
andrew@0 1 #ifndef _TEST_APP
andrew@0 2 #define _TEST_APP
andrew@0 3
andrew@0 4
andrew@0 5 #include "ofMain.h"
andrew@0 6 #include "sndfile.h"
andrew@0 7 #include "ofxFileDialogOSX.h"
andrew@0 8 #include "AudioFile.h"
andrew@1 9 #include "AudioAnalysis.h"
andrew@1 10 #include "SoundFileLoader.h"
andrew@0 11
andrew@0 12 //note the dependency on sndfile (libsndfile library needs to be accessible)
andrew@0 13 //also the file dialogue addon
andrew@0 14
andrew@0 15 //#include <vector>
andrew@0 16 //#include <cstdlib>
andrew@0 17
andrew@0 18
andrew@0 19 //main commands:
andrew@0 20 //O: open a new file
andrew@0 21 //see the key pressed function for other bits - e.g. can view spectral difference
andrew@0 22
andrew@0 23
andrew@1 24 //#define FRAMESIZE 512
andrew@1 25
andrew@0 26 //length in terms of frames (at 512 samples per frame - there are 90 per second) => 900: 10 seconds
andrew@0 27
andrew@0 28 class testApp : public ofBaseApp{
andrew@0 29
andrew@0 30 public:
andrew@0 31
andrew@0 32
andrew@0 33 void setup();
andrew@0 34 void update();
andrew@0 35 void draw();
andrew@0 36
andrew@0 37 void keyPressed (int key);
andrew@0 38 void keyReleased(int key);
andrew@0 39 void mouseMoved(int x, int y );
andrew@0 40 void mouseDragged(int x, int y, int button);
andrew@0 41 void mousePressed(int x, int y, int button);
andrew@0 42 void mouseReleased(int x, int y, int button);
andrew@0 43 void windowResized(int w, int h);
andrew@0 44
andrew@0 45 void audioRequested (float * input, int bufferSize, int nChannels);
andrew@0 46 void loadSndfile();
andrew@0 47
andrew@0 48 double getEnergyOfFrame();
andrew@0 49 // void putEnergyInFrame();
andrew@0 50
andrew@0 51 void initialiseVariables();
andrew@0 52
andrew@0 53
andrew@0 54 typedef std::vector<double> DoubleVector;
andrew@0 55 typedef std::vector<DoubleVector> DoubleMatrix;
andrew@0 56
andrew@1 57 // DoubleMatrix chromaMatrix;
andrew@1 58 // DoubleMatrix* matrixPtr;
andrew@0 59
andrew@1 60
andrew@0 61
andrew@1 62 void drawDoubleMatrix(DoubleMatrix* dMatrix);
andrew@1 63 // void drawSpectralDifference(DoubleMatrix* dMatrix);
andrew@0 64
andrew@1 65 // DoubleVector firstEnergyVector;
andrew@0 66
andrew@1 67 // void drawEnergyVectorFromPointer(DoubleVector* energyVec);
andrew@0 68
andrew@1 69 // void processAudioToDoubleMatrix(Chromagram* chromaG, DoubleMatrix* myDoubleMatrix, DoubleVector* energyVector);
andrew@0 70
andrew@0 71 void loadNewAudio(string soundFileName);
andrew@0 72
andrew@0 73 void openFileDialogBox();
andrew@0 74 void loadLibSndFile(const char * filename);
andrew@0 75 bool getFilenameFromDialogBox(string* fileNameToSave);
andrew@0 76 void openNewAudioFileWithdialogBox();
andrew@0 77
andrew@0 78 double audioScale;
andrew@0 79
andrew@0 80 string soundFileName;
andrew@0 81
andrew@0 82 float pan;
andrew@0 83 int sampleRate;
andrew@0 84 bool bNoise;
andrew@0 85 float volume;
andrew@0 86
andrew@0 87 float * lAudio;
andrew@0 88 float * rAudio;
andrew@0 89
andrew@0 90 bool moveOn;
andrew@0 91 bool drawSpectralDifferenceFunction;
andrew@1 92
andrew@0 93 // int frameIndex;
andrew@0 94 // float energy[ENERGY_LENGTH];
andrew@0 95
andrew@0 96 // float chromoGramVector[CHROMA_LENGTH][12];
andrew@0 97 // int rootChord[CHROMA_LENGTH];
andrew@0 98
andrew@0 99 // int energyIndex;
andrew@1 100
andrew@1 101 // int totalFrames;
andrew@0 102 int screenToDraw;
andrew@0 103
andrew@0 104 int scrollWidth;// 1600
andrew@0 105
andrew@0 106 bool audioPlaying, audioPaused;
andrew@0 107
andrew@0 108
andrew@0 109
andrew@0 110 //------------------- for the simple sine wave synthesis
andrew@0 111 /*
andrew@0 112 float targetFrequency;
andrew@0 113 float phase;
andrew@0 114 float phaseAdder;
andrew@0 115 float phaseAdderTarget;
andrew@0 116 */
andrew@0 117 string sndfileInfoString, textString;
andrew@0 118 int xIndex;
andrew@1 119
andrew@1 120 SoundFileLoader fileLoader;
andrew@1 121
andrew@0 122 ofSoundPlayer loadedAudio;
andrew@0 123 float audioPosition;
andrew@0 124 float width, height;
andrew@0 125 // int chromaIndex;
andrew@0 126 int totalNumberOfFrames;
andrew@1 127
andrew@0 128 string chordString;
andrew@0 129
andrew@1 130 // Chromagram chromoGramm;
andrew@0 131
andrew@1 132 // ChordDetect chord;
andrew@1 133
andrew@1 134 // SNDFILE *infile; // define input and output sound files
andrew@1 135 // SF_INFO sfinfo ; // struct to hold info about sound file
andrew@0 136
andrew@0 137
andrew@0 138 };
andrew@0 139
andrew@0 140 #endif