Guys, I need some help with this. I'm doing a small project for a friend who needs two different drum sounds per ATmega328. 8-bit is ok, the only problem is the envelope, as I can't do in software as it would sound terrible (and it does, I tested) since the whole thing is 8-bits.
The drum sounds already works, using PWM for the output, I can even get 6 voices per chip if I wanted, but that's no the case. I need just 2 voices, so I can use the flash to store longer samples.
If you want to check some of the code of the 6 voices drum sounds, here's the link of the project I created:
There's some youtube videos, just search on google for BeatVox
Now, here's what I want to do, to create the envelope using another PWM output, and have a Transistor(s) take care of the Envelope/VCA. I have seen circuits for VCAs for modular synths, but I want something dirty cheap and simple, to combine both outputs and have the second determinate the volume output. I know that there will be some DC problems, but maybe I could use a third PWM output to add DC as the Envelope lowers.
I will try to draw some pictures later this weekend to show what I have in mind. And yes, each PWM output will have its own filter to convert to a Voltage output, instead of a PWM output.
Anyway, thank you for any help.
Best Regards, WilliamK
Ahh, to convert PWM to Voltage I'm using this simple solution:
Here's my current list of Transistors, the ones I got in-house.
12 x 2N5087 PNP - 100ma
20 x PN2222 NPN - 600ma
30 x 2N3904 NPN - 200ma
30 x 2N3906 PNP - 200ma
200 x BC547B NPN - 45V - 0.1A
10 x ULN2803A DIP-18 Transistor Array (8 in/outs) 500ma
I remember using the PN2222 as a voltage controller and a potentiometer, but the test with the PWM had tons of noise, but I have to test again, to be sure I did it right. Since I have NO CLUE on what I am doing, any help would be much appreciated.
I'm also thinking on using an ATtiny85 and just have a single voice per chip, plus use it in 8Mhz internal mode. That will simplify things up, and I can get those chips for very little money, and its easier to import. Brazil import laws are stupid, you end up paying up to 200% the price just on transportation - customs and other fees... =( It sucks BIG time...
A question. Can't I combine two 8-bit PWM outputs to form a single 16-bit output? This way I could do the envelope in software, and have it applied to the output. I just have to figure out how it would work.
Check out some of the videos here
This guy organfairy seems to have all kinds of boxes, one being an envelope generator.
He shows the schematics too with explanations of what the part do.
I think I'd be inclined to run your sound thru a 12-bit DAC, input it as the reference voltage, and use SPI to send in the 12-bit gain.
That works well with analog signals if you have a dual supply DAC so the output can swing around 0V and not have to mess with DC offsets and capacitive coupling to mess with your sound.
Thanks bud, I will check this one out. 8)
Here's something interesting:
Resistor/PWM hybrid DAC
This is a good explanation on how to combine two PWM outputs in order to double the bit resolution. So combining two 8-bit arduino PWM outputs you can get a 16-bit PWM output! Remember Arduino's limits if you plan on going down this road. I mean, the Atmega chip is just 8-bit...
I will test this one out soon. The idea is simple, to have the 8-bit sound, and the envelope just multiples from 0 to 255. Just need to test how fast the processor can cope with the math, for at least 1 voice. I will also test with the ATtiny85, since there are enough PWM ports for the same test.