How about real waveforms with PWM (hardware or software) output? You can easily store a sampled (or synthesized) waveform in a table. You then index through the table at various rates to generate different notes. This is the basic idea behind "wavetable" sound cards. The trick is that you maintain a 16 bit value for your current position in the table, but only use the top 8 bits to index. The lower 8 bits are a running 'error value'. Here is the idea in sorta-C unsigned char sound_table[256] = { ... a bunch of numbers for the desired waveform ... }; union { unsigned short as_short; struct { unsigned char ls_bits; unsigned char ms_bits; } as_bytes; } index; /* the following variable determines the frequency of the note to be generated. You think of it as a fixed point binary number with 8 bits on each side of the binary point assume you are sampling at 8,000 samples per second if note_value == 0x200 (ie: 2.00 in fixed point) then it will take 128 samples or 128/8000 of a second to generate one cycle of output. Thus the frequency will be 62.50 Hz. because the time taken to cycle through the table is proportional to note_value so will the frequency be. */ unsigned short note_value; // assume you are sampling at 8,000 samples per second // if note // unsigned short note_value; index.as_short = 0; for (;;) // loop forever { index.as_short += note_value; output(sound_table[index.as_bytes.ms_bits]); } You can use a similar technique to perform envelope generation, but then you will need to multiply the envelope value by the waveform value to compute the output. At 8000 samples per second and a 4MHz clock you will have 125 instructions per sample. This should be enough to do quite a bit. btw: I did this sort of thing over 20 years ago using a Data General minicomputer and it sounded great. Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) ----- Original Message ----- From: Brian Jones To: Sent: Saturday, August 19, 2000 11:39 AM Subject: Music > I run a 'warm iron' evening at my ham radio club every December. > The idea is I design and kit something simple for the members to > build - must take less than a couple of hours and cost less than 10 > dollars. Last years 20 sequenced LED Xmas tree driven by a > 12C509 was a great hit. > > I'd like to add music this year but can't find a cheap source of > Holtek tune chips so was wondering what I'd need to make the > 16F84 (or whatever) sound decent. Obviously a starting point is a > simple square wave with the roughness filtered. But how do I make > a richer tone - what harmonics do I need? Is it a simple job of > adding harmonic square waves suitably attentuated and feeding all > the outputs to the filter/speaker? > > Any ideas ?? > Brian E Jones > Centre for Java Technology > IBM HURSLEY > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics