Go Down

Topic: NES inspired multichannel sounds generator library (Read 2020 times) previous topic - next topic

biji13

Hi everybody,

It's my first post on this forum and English is not my native language, so please help me out if I'm missing anything or if there is any typo.

I've always found generating sounds on the Arduino to be cumbersome. One tone at the time and everything freeze until it is done. It's nowhere near the charm of chiptunes songs!

So I decided to fix just that. I took inspiration from the NES Audio Processing Unit and I programmed a better way to generate chiptune like sounds.

https://github.com/superbiji/ArduinoProgrammableSoundGenerator

My library handle 6 channels: 2 squares, 1 triangle, 1 sawtooth, 1 noise and 1 sample, all asynchronous, using the Timer 2. Just plug a speaker on pin 3 and you are in business.

From the moment of this post, this is a work in progress. I feel as the project is mature enough to be shown to you, but bear in mind there are things to improve and to add. I'm pretty sure that my code may have some strange word or wording, due to my native language, but there are working examples in the file "SoundInterfaceDevice.ino", you should manage  :smiley-wink: . Eventually, the structure will be better: with more comments and more example.

I just want you to generate awesome chiptune from your Arduino, and to spread this code! If you have any idea how I could publicize this, feel free to suggest (for example: a tutorial on instructable).

I await for your feedback!

biji13

Robin2

Do you know how much of the Uno's cpu time is used by your library? Will it be fully occupied making sounds or will it be able to do other stuff at the same time?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

biji13

I don't know exactly how much cpu time is used, but personnaly, I made a walking robot and it sang music will walking, so there is a reasonnable margin. The sounds generation is in an interrupt, so it is asynchronous.

tl;dr; You can do other stuff at the same time.

Hope it help,

biji13

Robin2

but personnaly, I made a walking robot and it sang music will walking,
That sounds very convincing (forgive the pun).

I must investigate further

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Robin2

I have downloaded the ZIP and had a quick look through it.

How would one create the data for a sound - for example from a .WAV file?

I am interested in making sounds for model trains.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

biji13

Unfortunately, the same way the NES Audio Processing Unit worked, you cannot read or translate standard music file directly with this. You have to compose your music manually (there are examples in the file "melody.h"). You could translate MIDI or similar files, but I did not make tools to do so. You have to see this library as a tool to generate music instead of reading it.

You can load this code without any change in an Arduino, there is a working example. You can start from here.

If you have any other questions, don't hesitate  :)

biji13

biji13

After rereading your post, I thought of something. In my library, there is a channel where you can load a sample; an array that represents a wave. You could make a tool yourself to translate short WAV to the sample array. I may be able to help you with that.

biji13

Robin2

I am now thinking that your program is intended for something different from what I want. If the sound is in a .WAV file it will already be multi-channel.

Sorry for wasting your time.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

biji13

Indeed, .WAV is already multi-channel. My library is more for the chiptune mentality. It is a sort of Programmable Sound Generator. You have to compose your music specifically for my library implementation.

I wish you luck in your project!  :D

biji13

Go Up