[WIP] 4 channel Music


#1

I have been in contact with STG again about Music library brainstorm
The code we have so far is ready for testing against a tracker BUT
We need someone to help build a WEB based tracker (for creating music)

SO who can help us out: HTML5 + Sound
No more brainstorming, we need to create it now !!!

We’ll work on https://github.com/TEAMarg/ATMlib

if you want to help, please be sure you know what this is about.


Recreating Super Mario Land Piezo Speakers
Music maker? Need help with sound
Arduboy2 - The now recommended alternative to the Arduboy Library
Music library brainstorm
#2

Because we are working very quiet on this, I haven’t put any updates on the forum concerning our work on the 4 channel Music Tracker. So how are things going? …

You all do know it’s possible:


My biggest concern has always been the size of the player AND the songs. So STG and I have discussed this long enough to come to a certain point were we decided we have a format that is usable.

The play routine is finished ! hurray ! But it is still impossible to create music for this play routine :frowning:
The hardest part has started with us creating an editor. STG was able to make a browser sound generator, not playing samples, but actually generate the exact same sound the Arduboy will. Once this was finished we need the actual editor and to be honest we didn’t make much progress, until recently a good friend of mine joined our efforts.

So, we are creating an online editor, were you will be able to make/listen/export your music ready for use in your Arduboy (any Arduino) programs.

I’m going to show you a screenshot of the actual program WIP and probably will change a lot.
This is not a mock-up but the actual editor. Not much yet, but it gives a basic idea: channels, tracks and the part you don’t see yet: a piano roll where you can click notes.


#3

It’s been a while and progress has been slow, BUT I managed to get STG’s work into a separate library AND it works … well the player works, but still we need to add in all the effects. For now only the volume effect is working. Other effects could be Arpeggio, Vibrato, Tremolo, …

Well this is what it sounds like :slight_smile:

What you hear is 71 bytes … so a little song shouldn’t be bigger than 200 bytes :smiley:


#4

Just to let you know the first effects are in the player now:

  • set volume
  • slide volume ON
  • slide volume ON ADVANCED
  • slide volume OFF
  • slide frequency ON
  • slide frequency ON ADVANCED
  • slide frequency OFF

started working on Arpeggio en nested loops


#5

I think we have about most FX working in the tracker player:

  • VOLUME
  • FREQUENCY
  • ARPEGGIO
  • NOISE RETRIG
  • TRANSPOSITION
  • TREMOLO
  • VIBRATO
  • GLISSANDO

I’m currently working to get us as much example tunes/songs as possible explaining every FX separately.
Also the description and keywords are on my todo list.

This a small example of Arpeggio made by STG:


#6

Good news !

The tracker player you all can use in your game is finished. I still need to correct some of the example songs (because of some changes I made in how to set Tempo). BUT yes ! The library is ready for use. I’ll make a separate post about the lib soon.

We also created a WEBplayer, that can play the same song format as the Arduboy tracker. You only have to drop your song.h file on the webpage and it will start to play.

SO … how to create music? Yeah well that’s still kind of very hard, because our editor isn’t ready yet.

BUT if you would like to create an editor your self, please do. you can use the webplayer to create something around it.


(Scott) #7

If you really want this to become a standard library that people will use in their sketches, I suggest you:

  1. Organise the repository according to the Arduino Library Specification. This will allow you to submit it for inclusion in the Arduino Library Manager, making it easy for it to be installed in the IDE.
  • move ATMlib.h and ATMlib.c into a directory named src

  • move the mockups directory into a directory named extras

  • either combine all the .md files into README.md or move all but README.md to the extras folder

  • create a library.properties file

  • Add sound mute control that integrates with the audio class functions available in the Arduboy, Arduboy2 and Arglib libraries. Both the ArduboyTones and ArduboyPlaytune sound libraries do this by passing a pointer to the audio.enabled() function in the constructor. Doing this would probably mean eliminating the ATM object that you create automatically in ATMlib.cpp, instead letting the sketch create its own ATMlib object that provides a mute indicator function as a constructor parameter.

  • if you want to make the library PlatformIO IDE friendly, add a PlatformIO Library Manager compatible library.json file.


(Holmes) #8

Are we still going to have a global mute location in EEPROM?


(Scott) #9

Yes, that’s what I was referring to in suggestion 2 above. It’s the EEPROM_AUDIO_ON_OFF location, which is in the same place in the Arduboy, Arduboy2 and Arglib libraries. It’s controlled the same way, using the audio class, in all three libraries.

https://mlxxxp.github.io/documents/Arduino/libraries/Arduboy2/Doxygen/html/classArduboy2Audio.html#details

If you use the Arduboy2 library, controlling mute is available via the SystemButtons() startup feature, so you don’t even need a menu item for it in your sketch if you don’t want to add it.

https://mlxxxp.github.io/documents/Arduino/libraries/Arduboy2/Doxygen/html/classArduboy2Base.html#ad6dc5d0b396938daee143010bba64182

The intention is that all Arduboy compatible sound generation libraries work with the main library’s audio class functions to control mute globally amongst all sketches, and the state is saved across power cycles.


#10

@MLXXXp yep going to make all those changes you suggested. Also, yes ATMlib should take advantage of the audio on off from EEPROM, just need to implement it.

I’ll keep you all posted when I have done those changes.


(Holmes) #11

Awesome! Sorry if ya’ll mentioned it, already. I was only skimming the conversation and didn’t see it.


#12

@MLXXXp https://github.com/arduino/Arduino/issues/5648


#13

Can I use tone() while playing music ?


#14

@boochow yeah, but why would you do that, just talk to the oscillator directly.
We’ve added functions to mute/unmute a channel, so you can make game sound effects using the oscillators.

I have submitted the Library to arduino, once it’s in I’ll post a new topic and I will make a dedicated webpage explaining “the what” and “the how”.


#15

Oh I’m interested in how to talk to the osc. what I want to do is to play some sound effects while music track goes on.


#16

@boochow give me some time to write up a small manual on http://www.team-arg.org/ATMlib-manual.html
Once I got everything documented a bit more, I’ll ping you :wink:


(Scott) #17

@JO3RI, Are you planning to do this? I see that you’ve added mute() and unmute() calls to the ATMlib class but it would be nice if you implemented a global mute that follows the state of the Arduboy, Arduboy2 and Arglib libraries’ audio class by using a callback to the audio.enabled() function, as ArduboyTones and ArduboyPlaytune do.


#18

Great ! I 'm looking for update of the manual. It must be important to use this library for games !


#19

@MLXXXp this mute and unmute is something different. Those function mute 1 of the 4 channels, so that you can use the channel for a sound effect in the game (like shooting). They have nothing to do with the global sound on_off. This is how the Amiga games worked.

Normally global sound on_off should just work, because they set the pins from input to output … (I have to admit, I didn’t have time to test it yet)

@boochow creating those sound effects is up to the game coder, but I’ll provide examples in time.
Oké Oké here is a small example :slight_smile: , only a sound effect, without a timer or muting the channel:

for (int n = 1000; n < 4000; n += 40) {
  osc[CH_ZERO].vol = 63;
  osc[CH_ZERO].freq = n;
  delay(1);
  osc[CH_ZERO].vol = 0;
}

So one would mute the channel, do a sound effect on that channel and unmute the channel again.


#20

@JO3RI Thank you for example code. I just tested this and it works good.