Created
August 11, 2017 06:36
-
-
Save MayamaTakeshi/8a9ca72f801943935fd21136d0c08d98 to your computer and use it in GitHub Desktop.
Minimal sample using Chord-Detector-and-Chromagram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile with: | |
// g++ -DUSE_FFTW src/Chromagram.cpp src/ChordDetector.cpp main.cpp -I src/ -l fftw3 | |
#include "Chromagram.h" | |
#include "ChordDetector.h" | |
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
int FSIZE = 512; | |
int main(int argc, char *argv[]) { | |
int frameSize = FSIZE; | |
int sampleRate = 44100; | |
Chromagram c(frameSize, sampleRate); | |
vector<double> chroma; | |
int counter = 0; | |
ifstream myfile; | |
char *file = argv[1]; | |
myfile.open(file); | |
while(counter < 1000) { | |
cout << "counter: " << counter++ << endl; | |
double frame[FSIZE*2]; | |
myfile.read((char*)&frame,FSIZE*2); | |
c.processAudioFrame(frame); | |
if(c.isReady()) { | |
cout << "isReady" << endl; | |
chroma = c.getChromagram(); | |
cout << chroma.size() << endl; | |
break; | |
} | |
} | |
ChordDetector cd; | |
cd.detectChord(chroma); | |
std::cout << cd.rootNote << endl; | |
std::cout << cd.quality << endl; | |
std::cout << cd.intervals << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment