summaryrefslogtreecommitdiff
path: root/src/sms/analysis.c
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2012-07-09 23:39:35 +0200
committerJohn Glover <j@johnglover.net>2012-07-09 23:39:35 +0200
commit86183d8a17c7561706d76afe678f49bee56e0000 (patch)
tree223155f2157b78ed0a7cdc025b4e5e417719559f /src/sms/analysis.c
parentdeadc91509c507168fbd47999fed0d7c9ea693b9 (diff)
downloadsimpl-86183d8a17c7561706d76afe678f49bee56e0000.tar.gz
simpl-86183d8a17c7561706d76afe678f49bee56e0000.tar.bz2
simpl-86183d8a17c7561706d76afe678f49bee56e0000.zip
[sms, peak_detection] Add realtime analysis parameter, avoid performing non-real-time specific checks when running in realtime mode.
Diffstat (limited to 'src/sms/analysis.c')
-rw-r--r--src/sms/analysis.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/sms/analysis.c b/src/sms/analysis.c
index 89d4b4a..c7aae0b 100644
--- a/src/sms/analysis.c
+++ b/src/sms/analysis.c
@@ -174,19 +174,36 @@ int sms_findPeaks(int sizeWaveform, sfloat *pWaveform, SMS_AnalParams *pAnalPara
sms_analyzeFrame(iCurrentFrame, pAnalParams, fRefFundamental);
/* set the size of the next analysis window */
- if(pAnalParams->ppFrames[iCurrentFrame]->fFundamental > 0 &&
- pAnalParams->iSoundType != SMS_SOUND_TYPE_NOTE)
- pAnalParams->windowSize = sms_sizeNextWindow(iCurrentFrame, pAnalParams);
+ /* if(pAnalParams->ppFrames[iCurrentFrame]->fFundamental > 0 && */
+ /* pAnalParams->iSoundType != SMS_SOUND_TYPE_NOTE) */
+ /* { */
+ /* pAnalParams->windowSize = sms_sizeNextWindow(iCurrentFrame, pAnalParams); */
+ /* } */
- /* figure out how much needs to be read next time
- * how many processed - sample no. of end of next frame
- * = no. samples that we haven't processed yet from whenever, if sizeNextRead was 0
- */
- iExtraSamples = (pAnalParams->soundBuffer.iMarker + pAnalParams->soundBuffer.sizeBuffer) -
- (pAnalParams->ppFrames[iCurrentFrame]->iFrameSample + pAnalParams->sizeHop);
+ if(pAnalParams->realtime == 0)
+ {
+ /* set the size of the next analysis window */
+ if(pAnalParams->ppFrames[iCurrentFrame]->fFundamental > 0 &&
+ pAnalParams->iSoundType != SMS_SOUND_TYPE_NOTE)
+ {
+ pAnalParams->windowSize = sms_sizeNextWindow(iCurrentFrame, pAnalParams);
+ }
- pAnalParams->sizeNextRead = MAX(0, (pAnalParams->windowSize+1)/2 - iExtraSamples);
- ReAnalyzeFrame(iCurrentFrame, pAnalParams);
+ /* figure out how much needs to be read next time
+ * how many processed - sample no. of end of next frame
+ * = no. samples that we haven't processed yet from whenever, if sizeNextRead was 0
+ */
+ iExtraSamples = (pAnalParams->soundBuffer.iMarker + pAnalParams->soundBuffer.sizeBuffer) -
+ (pAnalParams->ppFrames[iCurrentFrame]->iFrameSample + pAnalParams->sizeHop);
+
+ pAnalParams->sizeNextRead = MAX(0, (pAnalParams->windowSize+1)/2 - iExtraSamples);
+ ReAnalyzeFrame(iCurrentFrame, pAnalParams);
+ }
+ else
+ {
+ pAnalParams->windowSize = sizeWaveform;
+ pAnalParams->sizeNextRead = sizeWaveform;
+ }
/* save peaks */
pSpectralPeaks->nPeaksFound = pAnalParams->ppFrames[iCurrentFrame]->nPeaks;