LoginLogin
Might make SBS readonly: thread

Improved MICSAVE function

Root / Submissions / [.]

12Me21Created:
If you wanted to save the last 20 audio samples, you might use something like
MICSAVE (MICPOS+MICSIZE-20) MOD MICSIZE, 20, ARRAY
However, this will fail if, say, MICSIZE was 100 and MICPOS was 90. SB records audio into a circular buffer, but for some reason MICSAVE doesn't act like RINGCOPY You need to use MICSAVE twice when MICPOS is near the end of the buffer:
DEF MICSAVE2 START,LENGTH,ARRAY
 START=START MOD MICSIZE
 VAR REMAINING=MICSIZE-START
 IF REMAINING>=LENGTH THEN
  MICSAVE START,LENGTH,ARRAY
 ELSE
  MICSAVE START,REMAINING,ARRAY
  VAR EXTRA=LENGTH-REMAINING
  DIM TEMP[EXTRA]
  MICSAVE 0,EXTRA,TEMP
  COPY ARRAY,REMAINING, TEMP,EXTRA
 ENDIF
END

Could you use RINGCOPY for this

Replying to:snail_
Could you use RINGCOPY for this
I mean you could just copy the entire buffer into an array and then RINGCOPY from *that* but that would be slower and require the DLC for no reason. (there's no way to get an array that references the mic buffer like PCMSTREAM)