Call out to Musicians or 'wanna be' Musicians

You can #define features out at compile time to trim it down and you can use just the OSC module (which gives you 3 square waves with programmable duty cycle and one noise channel (but no tracker like interface) for ~700 bytes if I recall correctly.

I think it depends on the lens you look at things from.
I tend to look at things from the “big picture” perspective.

Library + Music == overall smaller package.

With Evade 1, we used Tones and the first song used 1,331 bytes and only used two channels. with ATMLib(2) we brought it down to 357 bytes and had room for SFX with percussion without sacrificing an audio track from the music.

All of this depends on what your priority is =). For me, Music & SFX have a higher priority than graphics as audio (no matter how tiny the speaker is on the device) makes the game a much fuller experience.

To me: Arduboy games without music is like going back to the Atari 2600 days of gaming where as with music it’s like going to the NES days almost.

2 Likes

Audio, sure, but soundtracks? After listening to the same background music over and over in a game, I like to have the ability to turn it off but still keep the “beeps”, etc. that provide audio feedback during game play.

I suppose it depends on your preference. =)

I grew up in the 80s with the NES and fancy the music that was created for those games. Just like with movies, music can provide themes such as adventure or anxiety (bosses). Without music, the games can be hollow and less enjoyable.

Ah … that makes sense. Thanks

I checked again and the OSC module from ATMlib2 takes up 580 bytes of progmem. I think it can be made ~100 bytes smaller with a small decrease in performance. I’ll look into it in the next few days.

2 Likes

That’s nice and small. I don’t know what features I will need but I assuming relatively basic!

1 Like

Exactly 100 bytes smaller actually :rofl: (564 → 464 bytes using a demo song + SFX) see Reduce ISR size avoid skip computation for unused voices by dxxb · Pull Request #26 · moduscreate/ATMlib2 · GitHub

1 Like

Did you pad out some of the savings to hit that 100 exactly? A few no-ops??

No, I swear :stuck_out_tongue: the first try was 16 bytes less but behaved incorrectly. I may be able to get those 16 bytes back by adding just a tiny bit to inline asm.

1 Like

When do you think the library will be released? It holds a lot of promise!

I need to talk to @JayGarcia about that. As far as I am concerned people could start using right now to get feedback with the proviso that released application based on ATMlib2 use git submodules to point to a specific version or include their own copy so we are free to make changes to the API if necessary.

i promise that this is on my “To do” list. =)

@filmote

I’ve tried to stuff in ATMLib2 to allow music but the base sketch is already 98% full. :frowning:
IDK what to do here. If i add ATMLib2, we go over 100%.

I shot you a PM, if you remove ArduboyTones you get back a more respectable:

Sketch uses 27518 bytes (95%) of program storage space. Maximum is 28672 bytes.

That should give you a bit of space!

@filmote I don’t know if you’re already aware of this, but you can free up about 2kb just by changing:

class Arduboy2Ext : public Arduboy2

into

class Arduboy2Ext : public Arduboy2Base
1 Like

OMG … no I didn’t. Thanks!! Now I can put back a scene I dropped and the credit page (to the original author).

2 Likes

Oh yeah. You made my day. Thanks for this hint. I also regained so much flash space due to this… :star_struck:
A thousand thanks!

2 Likes

The Ways to make more code space available to sketches section, Remove the text functions subsection of the Arduboy2 library documentation describes this. I always find it helpful to review the documentation for something I’m using, to be aware of this sort of thing.

1 Like

You are right. Should have read the manual. I am not really the C++ expert and I was not sure what to do with the friend class thing in Arduboy2Base. Seeing that creating a friend of class named Arduboy2Ex with base class Arduboy2Base reduced the code size so much kind of hit me. After thinking about it, it makes sense but it took a while to understand.

Not exactly.

The reason using Arduboy2Base as a parent (instead of Arduboy2) saves memory is because Arduboy2 inherits from Arduboy2Base and adds more features, so inheriting from Arduboy2Base excludes those extra features.

Regarding the use of friend and inheritance:

Any class inheriting Arduboy2Base will get access to its protected members.

What friend Arduboy2Ex; means is that if you create a class called Arduboy2Ex it will be able to access the protected members of Arduboy2 (and Arduboy2Base, and Arduboy2Core) without needing inheritance.

For example the following code compiles only because Arduboy2Ex is marked friend.

class Arduboy2Ex
{
public:
  void manipulateArduboy(Arduboy2 & arduboy)
  {
    arduboy.textWrap = !arduboy.textWrap; // textWrap is protected
  }
};

The important distinction is that a class inheriting Arduboy2Base also gains all the variables and functions of Arduboy2Base, whereas a class named Arduboy2Ex (without inheritance) doesn’t inherit those things.
Instead, Arduboy2Ex is just allowed to access the protected parts of another Arduboy2, Arduboy2Base or Arduboy2Core.


Edit:

Also inheriting Arduboy2Ex won’t pass on the friendship.

So the following code wouldn’t work:

class Arduboy2Ex
{
public:
  void manipulateArduboy(Arduboy2 & arduboy)
  {
    arduboy.textWrap = !arduboy.textWrap; // textWrap is protected
  }
};

class Arduboy2ExChild : public Arduboy2Ex
{
public:
  void attemptToManipulateArduboy(Arduboy2 & arduboy)
  {
    arduboy.textWrap = !arduboy.textWrap; // access violation, can't access the protected member
  }
}
2 Likes