Mercurial > hg > multitrack-audio-matcher
annotate src/LiveAudioInput.cpp @ 3:5e188c0035b6
checking the offsets of the arrays
| author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
|---|---|
| date | Wed, 01 Feb 2012 16:05:26 +0000 |
| parents | 852173ca8365 |
| children | 4be22a1a0e24 |
| 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@1 | 12 const double hopsize = 512;//check to see it agrees with ofxAubioOnsetDetector |
| andrew@1 | 13 |
| andrew@0 | 14 LiveAudioInput::LiveAudioInput(){ |
| andrew@1 | 15 numberOfEvents = 0; |
| andrew@1 | 16 |
| andrew@1 | 17 } |
| andrew@0 | 18 |
| andrew@1 | 19 |
| andrew@1 | 20 |
| andrew@1 | 21 |
| andrew@1 | 22 void LiveAudioInput::addPitchEvent(const double& pitch, const double& time){ |
| andrew@1 | 23 |
| andrew@1 | 24 AudioEvent e; |
| andrew@1 | 25 e.millisTime = time; |
| andrew@1 | 26 e.frameTime = millisToFrames(time); |
| andrew@1 | 27 e.pitch = pitch; |
| andrew@1 | 28 liveEvents.push_back(e); |
| andrew@3 | 29 //printf("live input pitch %f time %f ms == %f frames\n", pitch, time, e.frameTime); |
| andrew@1 | 30 numberOfEvents++; |
| andrew@1 | 31 |
| 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@0 | 43 } |
