Mercurial > hg > multitrack-audio-matcher
annotate src/LiveAudioInput.cpp @ 56:4394c9490716 tip
minor changes
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Mon, 24 Dec 2012 18:58:39 +0000 |
parents | 9806a4f22fd0 |
children |
rev | line source |
---|---|
andrew@0 | 1 /* |
andrew@0 | 2 * LiveAudioInput.cpp |
andrew@0 | 3 * MultipleAudioMathcher |
andrew@0 | 4 * |
andrew@0 | 5 * Created by Andrew on 30/01/2012. |
andrew@0 | 6 * Copyright 2012 QMUL. All rights reserved. |
andrew@0 | 7 * |
andrew@0 | 8 */ |
andrew@0 | 9 |
andrew@0 | 10 #include "LiveAudioInput.h" |
andrew@0 | 11 |
andrew@37 | 12 //Keeping track of incoming events |
andrew@37 | 13 //more useful as data than anything else. But in fact, not particularly useful it seems at present |
andrew@37 | 14 |
andrew@37 | 15 |
andrew@1 | 16 const double hopsize = 512;//check to see it agrees with ofxAubioOnsetDetector |
andrew@1 | 17 |
andrew@0 | 18 LiveAudioInput::LiveAudioInput(){ |
andrew@1 | 19 numberOfEvents = 0; |
andrew@1 | 20 |
andrew@1 | 21 } |
andrew@0 | 22 |
andrew@1 | 23 void LiveAudioInput::addPitchEvent(const double& pitch, const double& time){ |
andrew@1 | 24 |
andrew@1 | 25 AudioEvent e; |
andrew@1 | 26 e.millisTime = time; |
andrew@1 | 27 e.frameTime = millisToFrames(time); |
andrew@1 | 28 e.pitch = pitch; |
andrew@1 | 29 liveEvents.push_back(e); |
andrew@3 | 30 //printf("live input pitch %f time %f ms == %f frames\n", pitch, time, e.frameTime); |
andrew@1 | 31 numberOfEvents++; |
andrew@1 | 32 |
andrew@1 | 33 } |
andrew@1 | 34 |
andrew@1 | 35 |
andrew@1 | 36 double LiveAudioInput::framesToMillis(const double& frameCount){ |
andrew@1 | 37 return ((frameCount*hopsize*1000.0)/44100.0); |
andrew@1 | 38 } |
andrew@1 | 39 |
andrew@1 | 40 |
andrew@1 | 41 double LiveAudioInput::millisToFrames(const double& millis){ |
andrew@1 | 42 return ((millis*44100.0)/(hopsize*1000.0)); |
andrew@37 | 43 } |
andrew@37 | 44 |
andrew@37 | 45 |
andrew@37 | 46 |
andrew@37 | 47 /* |
andrew@37 | 48 //any point in this?? |
andrew@37 | 49 void LiveAudioInput::addChromaEvent(const double& time){ |
andrew@37 | 50 |
andrew@37 | 51 AudioEvent e; |
andrew@37 | 52 e.millisTime = time; |
andrew@37 | 53 e.frameTime = millisToFrames(time); |
andrew@37 | 54 |
andrew@37 | 55 liveEvents.push_back(e); |
andrew@37 | 56 //printf("live input pitch %f time %f ms == %f frames\n", pitch, time, e.frameTime); |
andrew@37 | 57 numberOfEvents++; |
andrew@37 | 58 |
andrew@37 | 59 } |
andrew@37 | 60 */ |