News for hackers. Stuff that matters.
Re:Digital Audio 101: Playing Audio from a Microcontroller by Nihilartikel on Thursday April 15, 2021 @10:55AM (#26821224)
With microcontrollers being as fast as they are, and most having some hardware PWM capability even the very tiny ones, like the ATTiny85 can be startlingly capable synths, if you're satisfied with ~15khz 8bit audio fidelity.

At 8/16 mhz there are plenty of cycles for multi-channel audio synthesis. Not much room for samples, but a lot can be done with envelopes, saw, square, and noise waveforms.

https://github.com/blakelivingston/DuinoTune

https://www.youtube.com/watch?v=G3baH5iTcFM

Re:Digital Audio 101: Playing Audio from a Microcontroller by salehenrahman on Thursday April 15, 2021 @12:21PM (#26822481)
I could almost swear that you can even create a class-D amplifier with the ATTiny85, with a clock rate of ~15kHz.

Obviously it's not going to be ideal for an audiophile, but the quality is not too shabby. A fun project for those curious.

Still, stick to off-the-shelf class-D amplifiers, such as the PAM8403.

https://www.youtube.com/watch?v=O8of40tFsD8

Re:Digital Audio 101: Playing Audio from a Microcontroller by squarefoot on Thursday April 15, 2021 @12:37PM (#26822757)
> I could almost swear that you can even create a class-D amplifier with the ATTiny85, with a clock rate of ~15kHz.

Pretty sure you can do that. A Class D amplifier is to a class A/B traditional one what a switching power supply is to a linear one, so I would expect to be able to make a class D amplifier using for example a PWM driven H bridge usually employed to drive electric motors, or a chip used to make switching power supplies. If they can work at high frequencies (say 50KHz or more) then they should work; all it's needed is modulating their input or feedback pins the right way. Probably not HiFi for the sensitive ear, still good enough.

Re:Digital Audio 101: Playing Audio from a Microcontroller by Nihilartikel on Thursday April 15, 2021 @12:32PM (#26822670)
That would be really cool. Never got around to trying it, but I'm really curious about the subjective quality on the 12bit A/D conversion looping back to PWM D/A.

LoFi effects pedals could be fun.

Re:Digital Audio 101: Playing Audio from a Microcontroller by lb1lf on Thursday April 15, 2021 @01:18PM (#26823399)
-The 12 bit A/D provides a (theoretical) 72dB of S/N, so if you can do that at a decent sample rate to get sufficient bandwidth, the digitizing should be good.

As long as the PWM D/A has a good clock to keep the PWM ratio accurate, I think it should be eminently listenable, given a proper reconstruction filter and a decent power supply.

It would be fun to try this.

Re:Digital Audio 101: Playing Audio from a Microcontroller by GeorgeTirebiter on Thursday April 15, 2021 @08:14PM (#26827772)
Check this out -- really good discussion of bits and SNR: https://www.xiph.org/video/vid2.shtml jump to the 11:00 mark to find out just how many 'equivalent bits' those old cassette 'mix tapes' of yours had...
Re:Digital Audio 101: Playing Audio from a Microcontroller by squarefoot on Thursday April 15, 2021 @12:28PM (#26822611)
Interesting, thanks for sharing. I'd be interested in experimenting a hybrid approach in which the microcontroller takes MIDI in then generates basic waves (saw, square, sine etc) to keep resource consumption as low as possible while maximizing poliphony (layering with detune, etc), then leaving to analog circuitry noise generation, filtering, enevelopes etc. It would make things more complicated hardware-wise but I'm sure the sound would improve significantly, at least for us old beards who still love analog synths from the 70s.
Re:Digital Audio 101: Playing Audio from a Microcontroller by nitrogen on Thursday April 15, 2021 @03:41PM (#26825244)
I have an Ensoniq SQ-80 synthesizer that did something like that. A microcontroller generates 8 channels of sounds from a PCM wavetable, and those are fed into 8 analog filters before mixing down to stereo. But all of the waveforms and envelopes were digital.