gb.sound.playTrack(track, channel)

Can someone please explain to me how to use gb.sound.playTrack(track, channel) properly?
All I know is that a track contains an array of patterns, and a few commands but I don’t know how to make a track array to use correctly with the command above. Currently my code is as follows:

const unsigned int track01[] PROGMEM = {p01,p01,p02,p03};

I also have a patternSet sorted, but how do I use that with the track too?
When I run it, it plays random sounds…

Any help would be greatly appreciated!

This is an automatic translation of the document I wrote in Japanese, will it be helpful?

https://translate.google.co.jp/translate?sl=ja&tl=en&js=y&prev=_t&hl=ja&ie=UTF-8&u=https%3A%2F%2Fsites.google.com%2Fsite%2Fsugarflowerrn%2Farchives%2Farduino%2Fetc%2Fgamebuino%2Ftute%2Fsound&edit-text=&act=url

1 Like

Ok, so to my understanding, when creating a track, don’t direct it to the patterns themselves, as they’re given an ID when making pattern sets…

PatternSet p01, p02, p03…
The command automatically gives them pattern IDs in order: p01 is ID 0, p02 is ID 1, p03 is 2…

So to play patterns p01, p02 then p03, put them in a track array: track[]{0,1,2,0xFFFF}
The last entry is a command to terminate the song when the track reaches the end.

the command is playTrack(track,0)

I think I got it right, I’ll give it a go. My next question is: is there a way to loop the track with a command?

As far as I know, there is no track loop command. (I think so)
Instead, use isPlaying () in the main loop and create a program to play when not playing.

Cool explains. I’ll try this when i will be back at home. I have search this for some time.
Thanks for this tuto