AVR chiptune project turns this simple code into music

[Mark] had seen a few examples of algorithmic music generation that takes some simple code and produces complex-sounding results. Apparently it’s possible to pipe the output of code like this directly to audio devices on a Linux box, but [Mark] decided to go a different direction. His project lets you play simple algorithms as audio using AVR microcontrollers.

Now the code work for this is very simple, but he hardware implementation is where things get interesting. Ostensibly, [Mark] didn’t have the components available to build a filter to use PWM as an audio signal. Being that he’s a ham operator, he grabbed some radio equipment he had on hand and whipped up an alternative. He’s feeding the PWM from an Arduino into the voltage controlled oscillator on a board meant for high-altitude balloon telemetry. The signal broadcast by this board is then picked up by his radio receiver, and played on some speakers.

Rube-Goldberg contraptions aside, the effect is pretty interesting, as you can hear in the latter half of the video clip which we’ve embedded after the jump.

Comments

  1. Rob Carlson says:

    Nicely done, but transmitting music on 144.300 is technically a Part 97 violation.

  2. Mihail121 says:

    MY EARS, DAMN YOU HAD!

  3. aggaz says:

    I really like the final sound.
    I am wondering what kind of filter could create a similar effect in an audio synthesis enviorment…
    Some hints?

  4. Paul says:

    Last round bracket needs to be a curly bracket :-)

  5. Dax says:

    The first ever thing I did on an AVR was to increment PORTD by one every few thousand cycles. Each pin had a LED and a resistor, so I could watch the binary number increment.

    Then I realized I could put a small speaker between the LEDs and ground, and drive the pins at different rates, and all the waveforms would sum up and play out. So I created a small polyphonic light organ that worked by touching the LED leads to a bare wire.

    I don’t understand why you’d have to go this complicated to do it when you could essentially just wire a speaker to a pin and change the algorithm to produce something that is directly audible.

    • sam says:

      Let’s see why you shouldn’t do this:

      Speaker impedance: around 8 ohms.
      Voltage at the pin: 5v
      Using ohm’s law, the current would be: 625mA

      An AVR pin can put out 40mA max. More than that and you can destroy the pin or the chip.

      The speaker isn’t going to be 8 ohms at all frequencies. Even at 10 times more than the rated impedance, you would still be drawing too much current.

      There’s a good reason why you shouldn’t connect a speaker. You need to limit the current drawn first. Then most likely you’ll need an amplifier.

  6. KevintheCellman says:

    last “)” should be “}”

  7. vic says:

    These algorithms are very interesting. Better than using a microcontroller it seems that implementing them with a CD4040 and a few logic chips or diodes would be easy. A challenge could be to use as few components as possible.

  8. Ulrich says:

    Hi,

    apart from the last bracket,

    isn’t (t&t>>8) equivalent to (t>>8), because the bitwise AND operator has a higher priority than the right shift operator?

    Also, AFAIK, you can only use “void” or “int argc, char *argv[]” as arguments for the C main function.

    How is it supposed to be?

  9. bob says:

    main(){
    for (t=0;;t++)
    putchar(t&t>>8);
    }

    lets add unnecessary parentheses, and lay the code out in some obscure fashion…

  10. t&p says:

    That code is horrible. what is up with you kids and not knowing how code blocks work. THEY DON’T GO IN THE HEADER!!!

  11. gijs says:

    this one by: Rez/Razor1911. http://j.mp/pljQog

  12. tidux says:

    On Linux, the code is “cat foo.wav > /dev/dsp”. Anything else requires an on-the-fly convert to WAV, so it’s not the greatest way to play music.

  13. Aart says:

    There’s a topic on Pouet on this subject: http://pouet.net/topic.php?which=8357&page=1&x=17&y=10

  14. N0LKK says:

    Not exactly data either. How ever Part 97, which I have to observe, really doesn’t define what data is or isn’t. I’m not sure why the RF was used here, because the audio could have been plugged ind the sound card to get the same display Call this testing the micronut with random signals, if anyone asks.[shrug]

    The next step would to see what kind of random text this would generate. Takes one back in time. To when you could here similar music by playing a data cassette in an audio cassette player. Also back to the time of using the telephone handset to send data.

  15. swampy says:

    For some more algos:

    http://www.youtube.com/user/viznut

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 96,615 other followers