Editing Microcontroller polyphony
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 7: | Line 7: | ||
... ''circuit drawing goes here'' ... | ... ''circuit drawing goes here'' ... | ||
− | == polyphony the "standard" | + | == polyphony the "standard" ADC way == |
... ''circuit drawing goes here'' ... | ... ''circuit drawing goes here'' ... | ||
Line 15: | Line 15: | ||
* (c) If you have 7 sound sources (i.e., you want to simulate playing a chord of 6 notes on a piano, and also a flute), get 7 numbers. | * (c) If you have 7 sound sources (i.e., you want to simulate playing a chord of 6 notes on a piano, and also a flute), get 7 numbers. | ||
* (d) add the numbers together to get a total. | * (d) add the numbers together to get a total. | ||
− | * (e) send the total out to the | + | * (e) send the total out to the ADC |
− | * (f) Use op-amps to buffer the | + | * (f) Use op-amps to buffer the ADC output voltage, do low-pass filtering to eliminate ultrasonics, and send it to the speaker. |
* (g) In the background (perhaps in the main loop, or a lower-priority interrupt), when the time comes to finish the chord, turn off some or all of the sounds. (One of many ways to "turn off" a sound source is to set its delta to zero, and then set its phase accumulator to zero). | * (g) In the background (perhaps in the main loop, or a lower-priority interrupt), when the time comes to finish the chord, turn off some or all of the sounds. (One of many ways to "turn off" a sound source is to set its delta to zero, and then set its phase accumulator to zero). | ||
* (h) When the time comes to start playing another note (perhaps in addition to the notes already playing), set the "delta" number for the corresponding sources to produce the appropriate frequency. | * (h) When the time comes to start playing another note (perhaps in addition to the notes already playing), set the "delta" number for the corresponding sources to produce the appropriate frequency. | ||
− | In practice, to reduce jitter, the interrupt first (at high priority) sends the total out to the | + | In practice, to reduce jitter, the interrupt first (at high priority) sends the total out to the ADC (e), and then (at low priority) calculates a total (b-d) that won't be used until the next sound interrupt. |
You've seen a sound-board mixer, right? | You've seen a sound-board mixer, right? | ||
Line 68: | Line 68: | ||
... ''1-bit circuit drawing goes here'' ... | ... ''1-bit circuit drawing goes here'' ... | ||
− | Serial | + | Serial ADCs were once pretty expensive. |
− | Parallel | + | Parallel ADCs made from an R2R ladder seem to cost less, but they require a bunch of digital input pins, which once required an expensive CPU with lots of pins to handle that *and* all the other stuff you wanted to hook to it. |
− | To avoid that cost, many hobbyists have tried to generate sounds "directly" from one or two digital I/O pins of a CPU, without | + | To avoid that cost, many hobbyists have tried to generate sounds "directly" from one or two digital I/O pins of a CPU, without an ADC. |
They've figured out several relatively clever ways of doing that -- but they all have drawbacks. | They've figured out several relatively clever ways of doing that -- but they all have drawbacks. | ||
Line 79: | Line 79: | ||
In step (f), they generally require much more filtering. | In step (f), they generally require much more filtering. | ||
Pretty much all the other steps stay the same. | Pretty much all the other steps stay the same. | ||
− | Since the cost of high-pin-count CPUs and single-chip serial | + | Since the cost of high-pin-count CPUs and single-chip serial ADCs has plummeted, |
you have to ask if the drawbacks of the "clever" method are worth it. | you have to ask if the drawbacks of the "clever" method are worth it. | ||
Line 95: | Line 95: | ||
== Further reading == | == Further reading == | ||
− | |||
− | |||
− | |||
− | |||
* simple squarewaves are simple. Smooth sinewaves are surprisingly difficult. If you must generate a sine wave, there are several popular approaches: http://www.dattalo.com/technical/theory/sinewave.html | * simple squarewaves are simple. Smooth sinewaves are surprisingly difficult. If you must generate a sine wave, there are several popular approaches: http://www.dattalo.com/technical/theory/sinewave.html | ||
Line 107: | Line 103: | ||
* http://techref.massmind.org/Techref/pots/dtmf.htm | * http://techref.massmind.org/Techref/pots/dtmf.htm | ||
* http://electronics.stackexchange.com/questions/2057/polyphonic-sounds-from-a-microcontroller | * http://electronics.stackexchange.com/questions/2057/polyphonic-sounds-from-a-microcontroller | ||
− |