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.


21 thoughts on “AVR Chiptune Project Turns This Simple Code Into Music

  1. 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.

    1. 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.

  2. 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.

  3. 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?

  4. 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.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.