From f82385459b7dd3915bebebf3e6daff87df811069 Mon Sep 17 00:00:00 2001 From: Chris Kiefer Date: Wed, 14 Mar 2012 11:36:50 +0000 Subject: Fixed sample looping --- ofxMaxim/ofxMaxim/libs/maximilian.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ofxMaxim/ofxMaxim/libs/maximilian.cpp b/ofxMaxim/ofxMaxim/libs/maximilian.cpp index a6420b2..c0e08f1 100644 --- a/ofxMaxim/ofxMaxim/libs/maximilian.cpp +++ b/ofxMaxim/ofxMaxim/libs/maximilian.cpp @@ -433,15 +433,11 @@ bool maxiSample::read() double maxiSample::play() { - // long length=myDataSize*(1./myChannels); - double remainder; short* buffer = (short *)myData; - position=(position+1); - remainder = position - (long) position; - if ((long) position>length) position=0; - output = - (double) ((1-remainder) * buffer[1+ (long) position] + remainder * buffer[2+(long) position])/32767;//linear interpolation - return(output); + position++; + if ((long) position == length) position=0; + output = (double) buffer[(long)position]/32767.0; + return output; } double maxiSample::playOnce() { -- cgit v1.3