On Sat, Jun 28, 2003 at 11:32:07AM -0400, Ishaan Dalal wrote: > > This is essentially a "port" of a project that was done using > LSI/MSI/analog. It's a 24 (extendable to 36) digital-analog synthesizer, > that supports 8/12 note polyphony (extendable to 24/whatever, depending on > how many subcircuits are there). An analog multiplier with a > capacitor/monostable circuit handles the ADSR (Attack, Decay, Sustain, > Release) of each note. A POT/opamp handle amplitude for each channel, while > a system of 16:1 muxes allows varying each note slightly around the center > frequency. [... snip ...] If you wand analog output, you don't need the add's and the multiply's, it can be done using PWM, each sample is sustained on DAC output for a controlable amount of time: /* Parameters: freq[i] : frequency of wave "i", as phase increments. speed[i] : speed of adsr, as increments each supercycle. phase[i] : keeps the current phase of wave "i". adsrpos[i] : keeps the ADSR position of wave "i". */ * For each source "i": * Read sine-wave value from LUT: y = sintable[ phase[i] ]; * Adjust phase: phase[i] += freq[i]; * Read Amplitude wave from LUT: a = adsrtable[ adsrpos[i] ]; * Output y -> 8bitDAC: PORTB = y; * Wait "a" cycles: delay(a); * Output 0 -> 8bitDAC: PORTB = 0; * Wait "16-a" cycles: delay(16-a); * If adsr's need adjust: * For each source "i": * Adjust adsr time: adsrpos[i] += speed[i]; * If detect note off: if( adsrpos[i] > adsrduration ) * Clean note: adsrpos[i] = speed[i] = 0; At the output, you'll have a PWM output with the different wave-phases. A simple low-pass filter is sufficient to convert to a continuous analog wave, that will follow output = SUM_i( sintable[ phase[i] ] * adsrtable[ adsrpos[i] ] ); If you allow 16 cycles for the PWM of each wave, and add about 14 cycles extra for the housekeeping, its 30 cycles per chanel. At 40MHz and 32kHz output freq. you could have 10 channels. Note also that you don't need to keep only sinewaves in the LUT's, you could have any waveform you need to output. Daniel. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu