Powerful and decent quality audio synthesis project

Depending on if it is a real or a clone the limit might be the voltage rating on the capacitors, but at those sorts of voltages you will have a problem with the heat generated by the board's voltage regulator.

A car is a hostile environment as regards power regulation, it is full of spikes glitches and dropouts. So a lot of smoothing and protection is needed to get a solid supply.

I would go for battery power to begin with.

Thanks, this is not going to be a hi-fi project. Yes, heat is going to be a problem, so the amplifier enclosure needs to be well designed, have a fuse and a relay.
Regarding the amp it's possible to use a b47k pot to control the volume on the TPA3118.
For the power on the arduino maybe something like an LM7805 could be used, but indeed if there are cutouts this will be an issue.

Mike, in terms of the Arduino, what do you recommend to use? Currently I have plenty of UNOs around no other board, however many are available and I can order something . Thank you again for all your support!

I’ve ordered today the TPA3118 and a PAM8610. The latter is a stereo amp with a pot. For the TPA i ordered a 10k pot as the 47 was not in stock. They should arrive tomorrow and I will post back my findings. Thank you all for the support so far.

Alright, hardware received today. I’ve connected the TDA3118 from Pin3 of the Uno via a 10k pot directly, without a capacitor. Arduino and the amp are powered from the same DC12V mains adapter. All grounds: UNO, pot, amplifier board have a common ground. Everything is properly soldered, short cables, thick wires. The 10k pot is not much of a volume controller but it works. There is little hiss, barely noticeable with it closed and almost no hiss with just the amp powered, pot open half way with the input open ended(arduino not powered and the input wire open).

However, with everything connected and the UNO playing the PWM, the output is very chirpy/low quality, yet perfectly understandable. I am outputting 8bit 16kHz samples from the UNO.

I’m not happy, quality wise, it was predictable as many of you anticipated. Again, I am not looking for HiFi quality, I just need better.

What should be the best next step?

  1. Keep UNO and try to output 12-14bit?
  2. Try a different board first? I like the Arduino as it could be difficult to run a 3.3V in the car environment, but which board?
  3. Both the above.

Maybe my conclusion is not the right one yet now I would say the amp part is ok.

I’ve used a full range guitar amp speaker, 4ohm, kept the volume down as it is a 5” driver and not the very best quality one. It comes from a Roland Micro Cube amp. It will not be the speaker to be used in the end project. I will use a marine grade midbass or a coaxial one, depends what I will find available. I need something that can play the low frequencies, probably all below 3k. I do not need a coaxial but this is what I can find easily in 6.5”.

Can you post a sound clip of what you have at the moment?

The rp2040 based boards can produce very good audio quality (subjective opinion) without external chips and the picos are super cheap (4 pounds)

See reply #6

Here is a sample: Simulated exhaust sound - YouTube

Hey Mike, were you able to see the clip?

Not yet, I am away from home at the moment and yesterday my laptop broke. The track pad won't generate a click anymore. So I am going to have to buy a mouse. This is especially annoying as I have lots of these at home. It is currently 4:47 in the morning here, I should be able to get one when the shops open.

I am able to send this on my iPad, but what I want to do is to load the sound sample into a program called Audacity so I can look at the waveform.

No problem Mike. Since the sample I’ve sent is recorded with a phone and then uploaded on youtube, there is a ton of processing going on. I’ve also used audacity to resample to 8bit 16khz and then generate the progmem array. You just gave me an idea! I will make another recording and check it also in audacity compared to the first wave I am using in the arduino.

OK.
If you could just feed the output of the Arduino into Audacity and zoom into the waveform and post the image, I would like to check that there is no clipping going on with the waveform.

Thanks! I could do that, just a bit later. The wave I’ve processed in audacity definitely had no clipping. It is a waveform from audio jungle, I’ve trimmed it to around 0.3s, starting and ending on a 0 crossing sample. The output format when exporting is unsigned 8bit wav.

I did not use effects at all, no amplify/compressor.

Ok, I've made a recording and looked at the traces in Audacity. Top trace is the original, middle is the exported 8bit format, bottom is the arduino output recorded via a microphone 3.5jack in a PC.

There seems to not be any clipping, however the recording of the Arduino is the loudest. This could be due to the input level on the PC. It seems I have recorded the Arduino at 44kHz, but that should not matter I guess.



Here are also the wav files and the exported progmem array.
RAMsnippet zip The hosting site is in Romanian, there is a download link in the middle.

Actually listening with the headphones is not that bad, of course not hifi but nonetheless. There is hiss and noise but there’s also in the 8bit source. However, the Arduino output through the amplifier and the speaker is definitely not as good. Hmm, maybe the culprit is the guitar speaker …

Thanks, that doesn't sound too bad to me.
Possible suffering from the fact that it is 8 bits.
The thing about using 8 bits is to sound at its best you have to have the waveform cover as much of those dynamic range as possible without clipping.
Those traces look like your sample is not doing that. Try the amplify function in Audacity to get the maximum amplitude and only then cut it down to an 8 bit sample range.

Thanks Mike. I appreciate the advice and I will try that. I thought of trying a higher sample rate as well. Yes the 8bit decreases the quality significantly but that’s that :frowning: .

Would a Due produce better audio quality? It does have a DAC and 16bit if I understood it well. I’ve only used UNOs so far and this is my first audio project.

No, it has two DACs but they are both only 12 bits. Which is of course better that 8 bits.

The other thing out of them is you don't get the full voltage range (0 to 3V3), or at least not at a linear range. Can't remember the actual numbers off hand.

The other thing is that these two outputs are extremely limited as to output current. The two pins can only source 3mA and sink 6mA and are very easy to damage. In fact it seems that DAC0 is a lot more fragile that that. I have damaged one of my Dues DAC0 pins myself.

I couldn't get that link to load. You can post it directly on this forum by just dragging the file into the reply window.

Thanks Mike! There are the files from the above analysis. Meanwhile I am playing with different sounds, yet in terms of PWM they are not that different.
RAMsnippet.zip (816.7 KB)

Thanks for that. Yes that sound file did not cover the full range available for an 8 bit sound. Try replacing your RAM8Bit.h file with this one and see how you get on.
normilised.h.zip (23.8 KB)

Thanks Mike, how did you normalize it? If I do too much of an amplification, without any clipping in audacity then the extraction to .h leads to overflows on unsigned char. Meanwhile I am using different samples, so I would like to know the procedure you have used. I am away from my computer, I will try it first thing in the morning.

Mike, the reason I ask this is not to waste your time with probably the many samples I will be using in the future. OTOH, I respect experience and the fact one needs to learn and not steal knowledge. I am not a proficient audacity user especially not on 8bit, however I can use the software. Amplify is not a good option, maybe normalize and compress the hell out of it is the way to go. I looked at the .h on the phone, it seems very saturated. Maybe my wavec needs some more options and debugging. At a glance, your .h is in hexadecimal, mine was in uints, not that that would make a difference but I am intrigued by the no overshoot in your file. I will check my options when I am back.