I am trying to get a music selection menu with it previewing the music selected, right now it all works but 1 thing is not working as it should.
When i am on the selection menu, and it’s on one song, the song isn’t playing but it looks like it’s playing only the first note over and over instead… I do suspect that it’s because my code is always checking if the selected music is X and play music X, but instead of keeping that music X playing until i select something else, it may be restarting the selected song every loops.
Can anybody help me finding what i am doing wrong there? I am pretty sure it’s pretty easy for others, but i am a newbie at all this.
here’s how the music selector is right now
void radioMusic()
{
if (radioStation == 0)
{
ATM.play(music1);
}
if (radioStation == 1)
{
ATM.play(music2);
}
if (radioStation == 2)
{
ATM.stop();
}
}
So i am just calling that function on the music selection screen, on that screen you can use left/right to switch the song, 3 choices there: Music1, Music2 and No Music.
Once selected, the music in-game is the one selected and works nicely, only problem is that on the selection screen, the song isn’t playing, it seems to get stuck on the first note…
Also, is there an easy way to repeat a song infinitely? Not sure but i think there’s nothing on the Team ARG website about that.
Hi! If you are calling radioMusic() repeatedly then you are restarting the song every time ATM.play() is called. The solution is to call the radioMusic() only when the selection changes.
If this is ATMlib v1 then a pattern can carry a set pattern loop command which sets the pattern index to loop back to when the song is over (one pattern index for each of the 4 channels, pattern index 255 disables loop on a channel). This command can be anywhere before the end of the song, once the end of the song is reached it takes effect and the song starts again from the patterns specified in the set loop command.
Thanks for the help, i got it working now. But i didn’t expect ATMLid music to make everything else slow down that much. If there’s no way to make it more efficient we may not even be able to reader the game fast enough to be worth using it… i might need help there.
Yes, for now it’s ATMLib 1 (since i am using the ATM track editor on Team ARG website). Could you be more precise about what i should be doing? you seem to imply that i know the command to use. I am a total newbie at this.
Could you show me how to do it using the test song below? (it’s the one available on team ARG website to test)
Note that I added the command to the last track because I didn’t want to update the pattern offsets listed at the beginning of the listing you quoted. I would work also if it was inserted at the beginning or the middle of a pattern.
Sorry, ATMlib v1 is always mixing 4 channels audio even if you use less than 4 and interrupts the MCU at twice the sample rate. This is not easy to fix on the fly.
FYI all improvements made into ATMlib2 (which does skip processing unused channels and doesn’t trigger interrupt at twice the sample rate).