Fixed silence detection

CQTexperiment
Chris Moeller 2013-10-24 04:35:16 -07:00
parent af3a40bdc2
commit d99477f49f
1 changed files with 2 additions and 2 deletions

View File

@ -74,7 +74,7 @@ public:
mask = ~mask; mask = ~mask;
if ( used ) if ( used )
{ {
p = begin = &buffer[ 0 ] + readptr - 1; p = ( begin = &buffer[ 0 ] + readptr ) - 1;
end = &buffer[ 0 ] + ( writeptr > readptr ? writeptr : size ); end = &buffer[ 0 ] + ( writeptr > readptr ? writeptr : size );
while ( ++p < end && ( ( unsigned long ) ( *p + silence_threshold ) <= ( unsigned long ) silence_threshold * 2 ) ); while ( ++p < end && ( ( unsigned long ) ( *p + silence_threshold ) <= ( unsigned long ) silence_threshold * 2 ) );
unsigned long skipped = ( p - begin ) & mask; unsigned long skipped = ( p - begin ) & mask;
@ -83,7 +83,7 @@ public:
readptr = ( readptr + skipped ) % size; readptr = ( readptr + skipped ) % size;
if ( readptr == 0 && readptr != writeptr ) if ( readptr == 0 && readptr != writeptr )
{ {
p = begin = &buffer[ 0 ]; p = ( begin = &buffer[ 0 ] ) - 1;
end = &buffer[ 0 ] + writeptr; end = &buffer[ 0 ] + writeptr;
while ( ++p < end && ( ( unsigned long ) ( *p + silence_threshold ) <= ( unsigned long ) silence_threshold * 2 ) ); while ( ++p < end && ( ( unsigned long ) ( *p + silence_threshold ) <= ( unsigned long ) silence_threshold * 2 ) );
skipped = ( p - begin ) & mask; skipped = ( p - begin ) & mask;