Go Down

Topic: Use of SDWaveFile.cue() in the ArduinoSound library (Read 88 times) previous topic - next topic

dwc


Hi

I'm trying to use the SDWaveFile.cue() function in the ArduinoSound library

Here's a code fragment from a system that plays music forward and backwards, controlled by an encoder:

Code: [Select]

     
      // Start playback backward
      Serial.print("Starting backward playback: ");
      current_time = waveFileF.currentTime();
      Serial.println(current_time);
      AudioOutI2S.loop(waveFileB);
      waveFileB.cue(duration - current_time);


The current_time is read correctly, but file playing does not jump to the requested cue time, it always starts at the beginning, as if the cue is being ignored. I assume I'm using it incorrectly, but unsure how.

Anyone have example code of how to use cue?

Thanks

DVDdoug

I've never used that library, but have you tried hard-coding a cue point instead of calculating it?

You can also try "printing" the duration to make sure it's correct.

Quote
it always starts at the beginning,
If it's starting at the beginning it's obviously not playing backwards. ;)   

P.S.
Quote
(duration - current_time);
That's the time remaining...   Don't you want to start at the current time?  Or at the end?

dwc

Yup, tried hard coding a time, still doesn't work, and I do print the time out, which is the  'Serial.println(current_time);' line.

The time calculated is backward, as it's playing a reverse wave, so, to start from the same point when swapping direction, you need the time remaining.

Go Up