NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Generating Polyphony with Square Waves
February 05, 2011 by Slash_Fury |
First off: I'm really enjoying my Nerd Kit! I've gone through each of the projects when I received it for Christmas and I'm having a blast playing around with it. On to my project. After going through the "Making Music" tutorial, I wanted to learn how to do so utilizing PWM and interrupts. As of now, I'm able to generate a square wave, change its duty cycle, length, and pitch. Using PROGMEM, I can store the notes, but ultimately, I want to use a controller (in this case, I've experimented with getting inputs from an SNES controller) to play various notes. I've even set up a simple low-pass filter. I know it's strange, but my audio samples at 78125Hz (uC is at 20Mhz). For the most part, this all works just fine. The trouble I'm having is that I would like to be able to play two (or more) notes at once. I've been scouring the internet for information, but I'm finding little about actually implementing such a system (and the math required). I understand it has to do with adding the waves together, which affects the amplitude, but beyond that, I don't have a very good idea of what I can do to make that happen. If anyone had general advice, I would be quite grateful! |
---|---|
February 05, 2011 by mongo |
A long time ago, I did a program for an Apple IIc that simulated multiple notes like chords. What it did, was play each note of a chord in succession and rapidly repeat for the length of the note. |
Please log in to post a reply.
Did you know that there are Power MOSFETs for switching big loads on and off? Learn more...
|