Music composition help

Hi everyone. Hoping to get some help here. My first post, so go easy on me!

I’m a young South African music composer, and similar to the post by a user named dualweilder (topic “I’d like to compose music for your applications”), I too have an interest in composing stuff for the Arduboy. I’m doing my masters degree next year (exploring musical representations of culture in video gaming), and composing for the Arduboy could play a huge role in my research. More than anything, I just really want to be a video game composer, and this could be a fantastic opportunity to start doing so.

Here’s the problem: I have no idea how to do so.

I spoke a bit to JO3RI about it, and he recommended I look at Milky- and FamiTracker. Now being a composer, I’ve used many programs - Sibelius, Pro Tools, Logic, etc. - but never a tracker. After months of trying my best to understand it, I honestly can say I’m not cut out for using a tracker haha.

So. The question is this.

Would it be possible to compose for the Arduboy using a somewhat standardised music making application? JO3RI explained to me that the music has to be converted into code or something like that - it was a bit beyond me - and so only a certain program could be used. But is there anything I can do??? A midi file with four voices perhaps? Four seperate tracks bounced from Logic made using sine waves? I understand that our Arduboy’s have a piezo speaker, but as you might have guessed, I have absolutely no clue about the limitations I’m working with, and no experience coding.

Anyone want to suggest anything? Perhaps an extremely simple composition application exists that I can use? Thanks in advance!

1 Like

Yeah, it shouldn’t be too much of a problem. You are probably familiar with a sequencer. A tracker is a sequencer. It is possible to record midi input and export it to a flat file. At this point you would want to consult the documentation for the tracker you wish to use, but the next step is to map midi values to values the tracker understands to be used in controlling steps in the sequencer. I would imagine there would be some tools for each tracker to do such. Each tracker will most likely have a flat file backend for saving sequenced tracks. One could even hand edit these files if they are xml, yaml, etc.

I might start by googling ‘importing midi to tracker x’ and see what happens. If you do attempt a few things, and get stuck, post back in this thread and let’s see if we can’t develop a solution.

Thanks for the reply ekem. I did exactly that, and had what seems like a little bit of success!

So I wrote a little piece (very shoddy, just random notes really) in a music software called Sibelius. I wrote for four voices, using a square wave as my sound in the program. I then exported that to a MIDI file. I then found a tracker that can open MIDI, namely BeRoTracker. I imported it, and got what I wanted, more or less.

What BeRoTracker isn’t allowing me to do, is save the file as anything other than a BRT file. Regardless, I exported the song and each channel as WAV files (see ‘untitled test 2.wav’). Would that be usable? It’s saving in 8 bit, at 33075 Hz. Would that work?

Am I on the right track here guys? I’ve made a little Dropbox folder that you can checkout if you want, I’ll put updates and stuff there.

1 Like

Great! Glad you got something going.

I always try to promote Github over dropbox for open source projects, even if it is for a tiny script. I always try to be FOSS friendly around here : ) You are much more likely to get people viewing your source through Github, it’s just so much simpler for others to click the link than use a dropbox.

I will say that you have the composition part down, but I would take a look at the Arduboy libs to see how sound is actually generated/stored to be played for a user.

Generate procedurally
It’s actually going to be very similar to the way you make sound with any Arduino, using the tone() function.

Its a class wrapping built in tone functionality.

Store composition
Here is another option that has been included in the library, which is to use a sequence of bytes to store sound generation information.

I actually have no idea where this example came from : D I would snoop around Github and see what documentation is there or what can be gleaned from the source.

In the case above, the actual execution of that score is done with a line like the one below.;

@JO3RI Do you know what toolset was used to generate that byte sequence?

So @Josh_Hartdegen, you are now able to use midi information in a tracker, the tracker generates some native file format, its probably a sequence of bytes. The Arduboy library uses a sequence of bytes to run Arduino’s tone() function when it plays a composition. It’s probably a matter of just opening the file generated by the tracker in a hex editor, copying out the bytes and jamming them in to an .ino (c source file) and setting it as a byte array like in the example above.

The current chiptune library is just Arduino Playtune by Len Shustek (we should mention him in the copyright).

You can use the following software on Windows in the command line to transform a MIDI file into a score array:


Does this need to be ported to linux and mac? Sorry I don’t have a chance to snoop around quite yet.

No… :smile:

1 Like

Thanks, just wanted to make sure Josh won’t run into a roadblack. I should have said ‘can it be run from a unix like environment?’ :bathtub:

Yes, miditones is only some standard C code.

1 Like

What’s up everyone. I’m back. The South African heat has made productivity slow to a crawl.

Goodness. I don’t know WHAT I’ve been doing really, but I finally managed to get Miditones to do something or other. I’ve generated a file with the extension ‘.c’, which is apparently the byte stream you’re asking for. I think? I don’t think you guys realise just how clueless I am haha. :stuck_out_tongue: Anyway, here’s the file:

Sorry about the Dropbox thing, I’m still learning this damn website. Anyway, is this what you guys wanted? Furthermore, is there a way I can ‘play’ this little file or something? A web-based Arduino sound emulator or such? Again, pardon my ignorance. I just like music. If it does work, and someone is feeling particularly kind, could they post a little recording of the piece in action?

Thanks in advance.

1 Like

I don’t know about any emulators, but I got it playing on my arduboy by adding it to the example Tunes.ino file mentioned a few posts above.



Uh… that composition sounds awesome when ran through the piezo :clap:

1 Like

@ekem Thanks man! Just a silly mess-around but could be used for something or other!

@noel_abercrombie THANKS! How cool is that! It’s working!

Thanks for the help everyone. This is exciting! Onto the next few things.

  1. I’m assuming that short loops of music are preferred, so as to not use much of the 32kb of available space.

  2. Should I do music in four channels, and then sound effects will just override one of the channels when needed, similar to how the Gameboy did it? Or should I write for three channels, leaving the fourth open exclusively for sound effects? Probably not a big deal either way?

  3. I assume that I’ll need to write sound effects as well yes? Just one or two note patterns for whatever thing?

  4. Any other tips you all can give me? Still very new to this of course.

  5. How can I test my .c files? Is there any way, or do I need the hardware?

  6. Most importantly, who needs music?? Get in contact with me! Either here, Twitter, Facebook, or email me at

1 Like

More songs for you guys to play with.

‘Dramatic’ uses three channels, ‘French’, four.

Hi @Josh_Hartdegen :smile:

Nice job. We’ll try to get the ATMlib finished, but for now there is no progress, so what you did with TUNE is a good alternative.

PS: scores of about 512 bytes would be cool :wink:

PS2: You should be able to buy an arduino Leonardo in South Africa too. All you need extra is a buzzer or a piezo

@JO3RI, good to hear from you again!

Right, I gave it a shot!

What an awesome compositional struggle hey! The first two are a bit bigger than you wanted, and the second two, a bit smaller than you wanted. Again, see what you think and send comments my way!

@Josh_Hartdegen I tested them and they are cool :slight_smile: you can make them a bit longer though. I say you should just make scores and post them for people to use ! They will.

I’ve taken your advice @JO3RI. In the following folder, one will find a small pile of compositions they can use for their apps/games.

In this folder, you will find both the .c file and a .midi file of each composition, if you want to hear it before you try it out. I’ll constantly be adding to the collection, so if you’re looking for music, just check the folder and go for it I guess. If you are going to use one, let me know! I’d love to see my work at work. :stuck_out_tongue: Also, just chuck my name into the credits or whatever.

One last thing, I can still stick to four voices right?


This makes my brain hurt. Any good tips for a complete noob? I’d like to make a wedding march song for a project that will be a gift. Any tips on where I start?

You can use the tunes code built into the Arduboy library, as has been discussed above. It’s only capable of playing two part harmony using square waves, though (and only one part on a DevKit). The Arduboy tunes functions are derived from the Arduino Playtune library, where you can find information on the format of the data that is read to play tunes.

An example of playing a tune on the Arduboy can be found as the Tunes sketch in the Arduboy library. With the Arduboy library installed in the Arduino IDE, open it using:
File > Examples > Arduboy > Tunes

1 Like