ATM music delay

I got the exact same result as last time.

In that case I’ll wait for @JayGarcia or @dxb’s next comment.

I know lots about C++ but very little about ATMlib,
and I’m guessing this is an ATMlib problem
(i.e. something wrong with the format or the wrong function being called).


Just to make sure, you know that I’m using ATMlib2, right?

1 Like

Yeah, I was looking at the examples on their github:

I don’t know enough about the sound format to know whether the issue is the wrong function being used, the sound format being in the wrong order, a bug with the file generator etc.

(I meant to post this hours ago but didn’t realise I hadn’t pressed the send button. Oops.)

1 Like

Hi people,

been a while … I know.

@dxb @JayGarcia maybe it’s time we merge ATMlib and ATMlib2 into 1 library ?
But will probably have to discuss the song Format ? We originally made it as dens as possible, but that doesn’t mean we’re not open to improvement !


Hi @JO3RI! Great to have you back.

The new format can be smaller than the original one in some specific cases and in the “full featured” case is only marginally larger but it packs opcodes in a way that makes the decoder a lot smaller (and I believe it can be improved further). We should definitely discuss what to do with ATMLib2 (merge, name change, other options?).


@dxb @JO3RI, we should all get together to talk about the handoff (if applicable) of ATMLib2 =).

1 Like

Welcome back @JO3RI – you’ve been missed :smiley:

@Cyndi4U, is there a Github repo i could clone & test stuff out in?

I’ll admit, I’ve done an absolute horrible job of finishing the work to publish ATMLib2 and would like to help as much as I can. it will be hugely easier for me if there was a Repo I could jump on and make changes with related pull requests.


I was also going to suggest you consider getting a github account, but wasn’t sure when to mention it.

If you’re going to be using the forums a lot and/or asking for help with code, it’s a very useful thing to have.

1 Like

(I already have an unused account)
Here’s a github with all of the files in it.

1 Like

Hi @Cyndi4U, I can see your problem – you’re not including the ATMLib2 sources.

This is a problem generated partially because I failed to finish the publishing activities to make it available to the general public. I’m going to clone your repo, stuff in the ATMLib2 (pre-published) code and will create a PR for you.

Created the PR:

SFX options work with A & B buttons respectively.

Example ATM files can be found here:

Upload them to

1 Like

So being pretty new to C and C++, I have little to no idea what you just did. I’m studying the code, but I can’t seem to understand how or what this is doing. Can I get a quick summary? :sweat_smile: (Sorry for taking so much time)


  • Include the proper source files. I copied the source code to ATMLib2 to the local project. This issue is caused by the library not being fully published in the Arduino library repository.
  • Properly implement initialization (init()) function and play a song

Added: Sound.h & Sound.cpp

  • These files are my homegrown interface to ATMLib2’s function
  • Sound.h Sets up the prototype for the Static class (Sound)
    *Sound.cpp Includes the SFX and Songs
  • Static method Sound::play_sound Takes an integer that is mapped to the local constant array of SFX pointers. Sound::play_sound(SFX_PLAYER_SHOOT); will play the first SFX item in that array. SFX_PLAYER_SHOOT resolves to value of 0 (see Sound.h)
  • Static method Sound::play_song(INTRO_SONG) plays the music mapped in the play_sound's internal constant array of song pointers. INTRO_SONG resolves to value of 0 per Sound.h.
  • Static method Sound::stfu() will stop the music.

Hope this helps =)


If you’re new to C and C++, I highly suggest reading this book:

It was absolutely eye opening to me, a non-traditional programmer.

I bought it second-hand, and didn’t pay full price.

also – There are college lectures online that will help you a ton: For example, these are lectures that are captures from an intro to computer science class at Carnegie Mellon University:

Update: The link above doesn’t seem to represent it’s true contents:

1 Like

A few more references:

And (you’ll need this one day):

And lastly, plenty of useful stuff in the Arduboy magazine:

1 Like

One of the reasons I couldn’t figure out what it was doing what because the download I got was corrupted! Maybe my computer/internet doesn’t like Github :sweat_smile:

Git does checksum/hashing to ensure quality. :shrug:

Well … I decided to fix the delay bug after all.

The new release of ATMlib v1.2.5 will pop up soon enough in the library manager of the Arduino IDE.