robertsonics / Tsunami-Arduino-Serial-Library

Arduino Serial Control Library for Arduino
11 stars 9 forks source link

seemless jump to another track and current time elapsed #5

Open alexrjohnston opened 4 years ago

alexrjohnston commented 4 years ago

Hello! this looks great, I have two questions/requests. I see you have seemless looping. would it be possible to have a feature where for example tracks 1-8 are played and then seamlessly linked so that tracks 8 - 16 play straight after. also would it be possible to call the length of any of the currently loaded tracks? many thanks, Al.

edit: the reason i ask about the gapless playback is it would then be possible to trigger clips in an ableton like fashion and build up complex tracks on the fly :D

robertsonics commented 4 years ago

Regarding seamlessly linking to sequential tracks, not easily and not likely something I can add in the near future. Sorry.

For the track length, what do you mean by "currently loaded"? It would be simpler just to provide a command that would return the length of any numbered track on the SD card, but perhaps that's what you meant. This could be added pretty easily, but how would you use it?

alexrjohnston commented 4 years ago

Thanks for the quick response! No problem re the sequential playing. If I trigger a new set of wavs will there just be the 8ms (ish) gap before the new ones start playing? does the buffer of the already playing tracks soak up any of this time.

if it would be possible to have a tsunami.isTrackLength(int trk) then I could set a timer or count through millis (or ideally micros) untill 8ms before the end of the current set of wavs and then launch the new ones.

I also feel this feature would really complete the functionality as at the moment apart from tsunami.isTrackPlaying(int trk) there isn't any more info that can be obtained to find out where the track is at as far as I can see?

edit: it would mean if you know the bpm of the clip you can calculate how many beats there will be and therefore how many bars/phrases there will be in that clip of audio. Then i can make a countdown in beats and bars until the next clip.

robertsonics commented 4 years ago

If you trigger a new set of sounds before the end of the ones already playing, there will be no gap at all, since you'll be using 8 more voices to overlap the end of the previous with the beginning of the new. You will need to take into account the starting latency of the second second set (time between the start command or trigger and when sound gets into the audio buffer, around 7 ms)

I can probably implement a command to return the length of a track in the Tsunami firmware pretty quickly. Are you capable of implementing the Arduino Library end of things?

Keep in mind that Tsunami only knows the sample rate, number of channels and the length in samples of a track. It does not know anything about the musical content such as tempo or time signature.

alexrjohnston commented 4 years ago

This would be a real game changer for a project I am stuck on!

I can have a go at adding the functionality to the arduino lib but it would probably take me a while to get it working. it looks as if I would need something like "bool Tsunami::isTrackPlaying(int trk)" but that returns the number that the Tsunami sends rather than true or false.

Once I have the track length in ms or ideally uS its is easy to calculate the info I need from that. ms might be easier to implement depending on uS rollover.

Thanks! - Al.