summaryrefslogtreecommitdiff
path: root/src/sms/sms.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/sms.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/sms.c')
-rw-r--r--src/sms/sms.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/sms/sms.c b/src/sms/sms.c
index 8501d4d..59e9fa9 100644
--- a/src/sms/sms.c
+++ b/src/sms/sms.c
@@ -112,6 +112,7 @@ void sms_initAnalParams(SMS_AnalParams *pAnalParams)
pAnalParams->fPeakContToGuide = .4;
pAnalParams->fFundContToGuide = .5;
pAnalParams->fFreqDeviation = .45;
+ pAnalParams->realtime = 0;
pAnalParams->iSamplingRate = 44100; /* should be set to the real samplingrate with sms_initAnalysis */
pAnalParams->iDefaultSizeWindow = 1001;
pAnalParams->windowSize = 0;
@@ -839,7 +840,6 @@ int sms_initFrame(int iCurrentFrame, SMS_AnalParams *pAnalParams, int sizeWindow
pAnalParams->ppFrames[iCurrentFrame]->iFrameNum =
pAnalParams->ppFrames[iCurrentFrame - 1]->iFrameNum + 1;
- pAnalParams->ppFrames[iCurrentFrame]->iFrameSize = sizeWindow;
/* if first frame set center of data around 0 */
if(pAnalParams->ppFrames[iCurrentFrame]->iFrameNum == 1)
@@ -849,19 +849,30 @@ int sms_initFrame(int iCurrentFrame, SMS_AnalParams *pAnalParams, int sizeWindow
pAnalParams->ppFrames[iCurrentFrame]->iFrameSample =
pAnalParams->ppFrames[iCurrentFrame-1]->iFrameSample + pAnalParams->sizeHop;
- /* check for end of sound */
- if((pAnalParams->ppFrames[iCurrentFrame]->iFrameSample + (sizeWindow+1)/2) >= pAnalParams->iSizeSound
- && pAnalParams->iSizeSound > 0)
+ if(pAnalParams->realtime == 0)
{
- pAnalParams->ppFrames[iCurrentFrame]->iFrameNum = -1;
- pAnalParams->ppFrames[iCurrentFrame]->iFrameSize = 0;
- pAnalParams->ppFrames[iCurrentFrame]->iStatus = SMS_FRAME_END;
+ pAnalParams->ppFrames[iCurrentFrame]->iFrameSize = sizeWindow;
+
+ /* check for end of sound */
+ if((pAnalParams->ppFrames[iCurrentFrame]->iFrameSample + (sizeWindow+1)/2) >= pAnalParams->iSizeSound
+ && pAnalParams->iSizeSound > 0)
+ {
+ pAnalParams->ppFrames[iCurrentFrame]->iFrameNum = -1;
+ pAnalParams->ppFrames[iCurrentFrame]->iFrameSize = 0;
+ pAnalParams->ppFrames[iCurrentFrame]->iStatus = SMS_FRAME_END;
+ }
+ else
+ {
+ /* good status, ready to start computing */
+ pAnalParams->ppFrames[iCurrentFrame]->iStatus = SMS_FRAME_READY;
+ }
}
else
{
- /* good status, ready to start computing */
+ pAnalParams->ppFrames[iCurrentFrame]->iFrameSize = pAnalParams->iSamplingRate / pAnalParams->iFrameRate;
pAnalParams->ppFrames[iCurrentFrame]->iStatus = SMS_FRAME_READY;
}
+
return SMS_OK;
}