Proofread an Analog Audio Design? - Page 1
Forum section: electronics / projects

author: AaronD
author_rank: Frequent Contributor
timestamp: November 23, 2021, 12:28:10 am
content: This is a slightly modified version ofFigure 6 here. (wonderful site, by the way) There's no through-hole PCB offered to buy for that project, so I'm making an SMT one.Any glaring errors? Better ways to do things? I thought about programming a DSP for this, and Iwouldjust add it to the code if a DSP project really needed this function, but seeing as most of the gear that I have at the moment is analog, and the digital sound board that I might use it on only has analog I/O available (that's annoying), I figured I'd keep this analog too.The primary modification is to make it adjustable between ~1Hz and ~10Hz instead of the fixed ~5Hz of the source project, and add the option to shift down in frequency as well as up. The adjustability really needs a 3-gang pot - 2 for the oscillator and 1 for the 90deg shift that follows it - but the difficulty in finding one got me a dual (RV3) and a single (RV4) that the user is supposed to keep equal to each other, plus the "analog inequality compensator" (RV1). If someone knows where to get a 1Meg 3-gang panel-mount pot with decent tracking, I'd appreciate that too!Schematic:4-Layer Layout:The slightly odd placement of the power input is to line up with a single-layer off-board power supply:I'm thinking for that to be a general-purpose analog processing supply, and not necessarily tied to this project.

author: moffy
author_rank: Super Contributor
timestamp: November 23, 2021, 05:42:28 am
content: So basically it is an audio SSB shifter, splitting the audio into quadrature outputs and providing a quadrature low frequency oscillator that is multiplied by the quadrature audio. I would be tempted to create the LF oscillator digitally and use a couple of 16 bit DACs, you could maintain better level matching.What is the purpose for this?

author: AaronD
author_rank: Frequent Contributor
timestamp: November 23, 2021, 07:51:20 pm
content: Quote from: moffy on November 23, 2021, 05:42:28 amPretty much, yes. If I were doinganythingdigitally though, I'd be sorely tempted to doeverythingdigitally. Perfect tracking for everything, for free! Only one single-gang knob required, which feeds DC into an on-chip ADC channel, and no tuning. ADC the raw input, DAC the final output, and do all the work in a midsize MCU if that's all it's doing. Maybe hack a 50% squarewave output and a SPI peripheral together to do I2S to some external converters, because a chip that small probably doesn't have a dedicated I2S mode?As a sanity check, a 2-channel or stereo digital version (the analog design above is 1-channel or mono) running on a 20MHz AVR (probably want something a little bit faster, but just as a data point), using 24-bit converters at 48kHz, would have about 69-70 instructions per byte of processing. Some of that will be taken by some data shuffling as there isn't a DMA in that series, and a lot will be taken by doing multi-byte math on a single-byte architecture. So I'd really want something more than an 8-bit AVR to actually do this, but even that seems almost plausible at first glance.Quote from: moffy on November 23, 2021, 05:42:28 amThe purpose is to give a little bit of extra gain before feedback in a live PA. Speakers and mics can't be moved, otherwise I'd do that first.I'm well aware of the wildly popular approach of adding notch filters until it's okay, and the practice of making those notches automatic in a DSP. But I've never had a DSP feedback detector actually work (according to support, the one that I was the most intimately familiar with had a minimum signal level to work at all, which is understandable, but my conclusion after several support calls was that the minimum level was above clipping???), and the ultimate failure mode when it does work is to apply enough notches to make an audible difference and still allow the same runaway squeal because it ran out of them. My experience in adding notches manually on a full-parametric channel EQ (nowhere near as narrow as a purpose-designed feedback notch), says that the returns diminishveryquickly anyway, in that a handful of dB above the threshold requires enough cuts that it's practically just turning the gain down.The theory with the SSB shifter is that it fundamentally messes with the feedback mechanism itself, but not in a way that is immediately audible. (If you listen for it, you might notice, but how many people know to listen for it?) Each trip through the feedback loop is supposed to be offset by half of the (rough) period in frequency of a room's response, so that most loops only last for one cycle instead of an infinite number of cycles. The ultimate failure mode is kind of a "high-voltage Jacob's Ladder" effect, but in frequency instead of height, where a signal gets shifted each time through the loop and eventually dies. So you get a weird warbly sound instead of a runaway screech. Still undesirable, but the SPL is much better controlled.I tried it once with a digital pitch shifter, because the digital board already had that as a pre-programmed internal FX unit. About 17 cents seemed about right for that particular room, and it did allow a significant gain increase before it misbehaved as above, but the main sound guy thought it was too intrusive on a speaking mic and didn't like it. But that's a frequency multiplier/scaler while this project is a frequency adder/offset. So I thought I'd try this too. And since no one seems to make one, I'm doing it myself.

author: Kleinstein
author_rank: Super Contributor
timestamp: November 23, 2021, 09:40:17 pm
content: The amplitude regulation of the LF oscillator may not be very good. There are usually better ones, though this is not so easy at the low frequency. So a DDS generator (even if only 8 bit DAC and 8 bit µC) may be a real option, especially if one wants a variable frequency. The oscillator looks a little like those versions that directly produce a sine and cosine at the 2 OPs. So one may get away without the extra phase shifter.I would at least keep the option to feed in external LF signal(s), just in case.For the phase shifter, there is no need for film capacitors. At 10 nF and 1 nF there is no problem using C0G capacitors. There is not need for extra low loss capacitors - just don't use nonlinear ones like X7R. C0G MLCCs are much easier to solder and film caps a mainly a thing for large capacitance, like >= 100 nF. So it would be at the LF oscillator where film caps (mylar would be OK) could make some sense.edit:C12 looks a bit small from the form factor. X7R may give some distortion, though not clear if really relevant.

author: BrianHG
author_rank: Super Contributor
timestamp: November 23, 2021, 09:47:54 pm
content: For your PSP, placing either 10nf or 100nf ceramic caps in parallel with each 1N5400 diode helps remove the harsh switching noise in the diode which in some designs may introduce a slight 50/60hz EMI buzz as the diodes conduct during the peaks of the AC waveform. (only D1...D4)

author: AaronD
author_rank: Frequent Contributor
timestamp: November 23, 2021, 10:46:29 pm
content: Quote from: Kleinstein on November 23, 2021, 09:40:17 pmYes, it is a quadrature oscillator, using two 90deg shifters (U6B, U7B) and a controlled gain stage (U7A), so it's technically possible to take the sine and cosine directly from that. But the project description that I'm basing this on, which itself is based on a different project that is essentially the same oscillator on its own, offers a way to reduce the distortion from the diode-clipper gain control, provided that you're okay with a single output (U6A). Then it runs that single clean signal through another 90deg shifter (U8A) to get the quadrature back.Quote from: Kleinstein on November 23, 2021, 09:40:17 pmThe reasoning in the reference project is not stability (you're right about C0G being plenty for that), but tolerance. That said, I looked again at Mouser, and found 1% NP0/C0G MLCC's for the standard pennies that I would expect in a 0603 package. So the through-hole film caps were a result of not thinking it through well enough in translation. Good catch!Quote from: Kleinstein on November 23, 2021, 09:40:17 pmYeah, you're probably right. I was thinking of a series cap for blocking DC, which hardly has any voltage change across it and a rather loose tolerance for the actual capacitance, but that's not what this is! Shopping again, I didn't find any ceramics that big in C0G, but I did find some leaded bipolar electrolytics. I'm not entirely sure that that's any better. How is this sort of thing normally done? Smaller C, bigger R, so that a C0G capisavailable?Quote from: BrianHG on November 23, 2021, 09:47:54 pmAnother good idea, and an easy add. Thanks!As a side note, I remember trying to troubleshoot a small PA that had an intermittent AC buzz. I never figured out where it came from, but an oscilloscope on the AC power line showed lots of distortion when it was happening and clean when it wasn't, and another 'scope channel on the power amp's output showed a very short spike just before the AC peak when it was happening and not when it wasn't. So my guess was that something was doing exactly as you describe. Maybe those caps didn't exist where they should have, and that device, whatever it was, was cycling on and off?

author: BrianHG
author_rank: Super Contributor
timestamp: November 23, 2021, 11:00:21 pm
content: Quote from: AaronD on November 23, 2021, 10:46:29 pmYour were looking at the current spikes during the switch-on to off / visa-verse points where that switched surge of current makes sometimes 2 pairs of 2 spikes around the peaks of the AC source which usually ends up firing throughout the analog system GND. The low impedance of a ceramic cap placed just under the diode is a near short at these tiny spike frequencies generating a short path right at the diode's terminals usually eliminating the problem. The worst diodes generating this buzz typically are the lower power but faster ones like the 1N400x 1 amp diode series in many old fashioned wall-warts and the primary diodes in switching supplies where their switching interacts and transmits right through the usual class Y1 cap the the low-voltage side's GND.

author: moffy
author_rank: Super Contributor
timestamp: November 24, 2021, 01:30:14 am
content: Suddenly I am very interested in your project, the church I go to has quite a bad time with feedback and this might offer some gain boost.Still think the digital approach is the better for the LF oscillator as Kleinstein suggested using a DDS chip or module, you can get versions with quadrature out, but then the linear option is direct and simple, and small mismatches shouldn't be noticeable as long as you don't get a significant beat frequency.Cyril Bateman:https://linearaudio.nl/sites/linearaudio.net/files/Bateman%20EW%2001%202003%20mar2003%2010%20to%20100uF%20caps%20and%20100%20Hz%20measurements_0.pdfHas some nice articles about distortion of some Aluminium caps, they are much better than I expected, but one result was that Bipolar Electrolytics are always lower distortion than Polar Electrolytics of the same value.If using a processor, you would need a 32bit core, probably ARM. I feel like an NXP evangelist(I really have no relation with them), but the iMXRT1021 would be a good starter. The development board(not expensive) even comes with an onboard stereo codec, but I have no idea how processor intensive the Allpass filter network would be to implement.Keep us up to date on your progress and results.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: November 24, 2021, 02:27:55 am
content: Probably a bit of an outrageous idea, but if you want linear potentiometers with excellent tracking then you could use WDD35 and combine them with pulleys and a timing belt.These potentiometers go up to 0.1% linearity (or was it 0.01%)These cost around EUR 20, but I still find them quite cheap for their quality. They are "conductive plastic" and they are individually calibrated for linearity by milling part of the track away.They are also rated for a gazillion rotations. Have ball bearings and the wiper is made out of 20 or so wires.

author: AaronD
author_rank: Frequent Contributor
timestamp: November 24, 2021, 05:21:47 am
content: Quote from: moffy on November 24, 2021, 01:30:14 amAccording to the reference project, RV1,2 are meant to minimize any residual amplitude modulation at the output from the oscillator. If the quadrature isn't quite 90deg, or the multipliers aren't summed exactly equal, then the overall gain can be modulated slightly at twice the oscillator frequency. Those two pots are essentially to account for analog not beingexactlyequal in their respective parts of the circuit. Neither would be needed for digital because thatisexact. (well, exactly equal toitselfanyway, which is what matters here)Quote from: moffy on November 24, 2021, 01:30:14 amWell, seeing as all of them had their highest harmonic below -90dB, I don't think I'm going to hear any of them.Just stay away from tantalum, which I was anyway. (too many horror stories...)Quote from: moffy on November 24, 2021, 01:30:14 amI'm more torn than before now, between keeping it analog and solving those problems, or making a DSP to do it. I do have some more ambitious projects on the shelf that will definitely require an audio DSP. In order that I was planning to do them:Stereo USB sound card with a signal path of: highpass -> gain -> limiter -> crossover -> individual gain -> corrective EQ -> anti-clipping limiters -> TDM -> class-D chip amps to a custom 2.1 set of speakers. Everything before the crossover is user-adjustable; everything after and including the crossover is tuned for the installation and left alone. (and of course some blinkenlights to show what's going on, like HPF bypassed, limiter active, etc.)8-in/8-out USB sound card plus 6 analog channels each direction (3 stereo in, 3 stereo out), with mic and speaker correction, mixing, and hearing/clipping protection. This one is going to be especially interesting in that the mics and speakers are going to be physically close to each other with foam, resin, or some other kind of barrier in between, and their primary purpose is to fill in what the unavoidable acoustic lowpass cuts out. So there may or may not be some feedback prevention in there as well, and I really want to keep the analog-to-analog latency to an absolute minimum to avoid a comb filter, which probably means writing my own DSP code for one sample at a time instead of the 64 or so that most pre-fab DSP's do that I've seen. (Analog Devices has awonderfulDSP chip and matching free IDE, if it weren't for that one specific problem for this particular application that I want to build up to.) The USB connection in this case is just to monitor what's going on at various points for debugging and possibly recording on a PC, and to read/write coefficients and possibly reprogram it altogether.It would definitely fit to insert this SSB shifter as #0 in that list of DSP projects, but I can still see some reasons to keep it analog too...Quote from: moffy on November 24, 2021, 01:30:14 amWell, there's these that I already have bookmarked:https://en.wikipedia.org/wiki/Digital_biquad_filterhttps://www.musicdsp.org/en/latest/Filters/197-rbj-audio-eq-cookbook.htmlhttps://www.musicdsp.org/en/latest/Filters/64-biquad-c-code.htmlhttps://www.musicdsp.org/en/latest/Analysis/186-frequency-response-from-biquad-coefficients.htmlhttps://www.musicdsp.org/en/latest/Analysis/108-magnitude-and-phase-plot-of-arbitrary-iir-function-up-to-5th-order.html#commentshttps://www.musicdsp.org/en/latest/Effects/204-simple-compressor-class-c.htmlhttps://webaudio.github.io/Audio-EQ-Cookbook/audio-eq-cookbook.htmlBasically, a lot about biquad filters, how to write one, and how to calculate their coefficients from the desired behavior and back again, plus one example of a compressor. (A compressor with infinite Ratio, instant Attack, and finite Release, becomes a limiter, which is what I'll need for the other two projects.) The equations for biquad coefficients are not intuitive, just like every other DSP filter, but they're conveniently given on those pages for each of the filter types that might be useful. One of those given types is an allpass.So, each analog APF (U2..U5) that isn't involved with the quad oscillator, represents one biquad with presumably constant execution time regardless of its coefficients (I'll need 8 of those, exactly as if it were a stereo 4-band full-parametric EQ, fed in mono; only the coefficients are different, and they're not equal between channels like they would be for a stereo EQ), the multipliers and the summer become trivial (one instruction each), and the oscillator is pretty straightforward too. If I'm using a 32-bit chip just for this, then I'll probably have enough overhead left over to actually do the trig functions instead of a lookup table.All that's left then, is to connect the ADC and DAC to a world where full-scale is +/-15V peak. Pretty much every datasheet for those chips has an example circuit to do that, with some being more complex than others.

author: moffy
author_rank: Super Contributor
timestamp: November 24, 2021, 06:23:48 am
content: Wow, that is really ambitious. Thanks for the links I'll look at the code.

author: AaronD
author_rank: Frequent Contributor
timestamp: November 25, 2021, 11:02:22 pm
content: I haven't completely given up on a pure-analog version, but I did add an external oscillator input, along with the other changes suggested here. It's slightly smaller too, with the massive film caps replaced with 0603's and some rearranging.Did I miss anything?Schematic:PCB:Power:

author: Kleinstein
author_rank: Super Contributor
timestamp: November 26, 2021, 08:43:17 am
content: For the LF osciallator it may help to have a trimmer to adjust the loop gain and this way the amplitude / distortion.I see no real need to have the PCB so cramped together. For a prototype / testing it helps to have a bit more space to help soldering and in some places maybe have to option to an extra cap / resistor in parallel to trimming.For manual soldering it is OK and sometimes even a bit easier to have larger pads, like the versions for manual soldering.It helps to have space for the iron and tweezers.It may help to have test points, including ground.

author: moffy
author_rank: Super Contributor
timestamp: November 29, 2021, 12:42:12 am
content: After thinking a bit about your project, I thought that maybe "pitch shifting" might be a way to accomplish the same thing without the metallic sound artifact of large fixed frequency shifts. It would of course have to be implemented digitally, but I have a few SEEED Arch Mix iMXRT1052 boards and I found some code:https://www.surina.net/soundtouch/sourcecode.htmlwhich compiled easily under Visual Studio 2017, and looking at the library, should port fairly easily to the RT1052. I might just give it a try to see if the processor can do real time pitch shifting. The windows program worked very well on a music wave file I had, I tried 2 and 0.2 semitones shft.

author: AaronD
author_rank: Frequent Contributor
timestamp: November 29, 2021, 03:39:40 am
content: Quote from: moffy on November 29, 2021, 12:42:12 am2 semitones is HUGE, compared to what my room needed! That's 200 cents, compared to the 17 cents that I ended up with. Roughly ~100-seat auditorium, maybe twice as wide as it is long? Just guessing here; I haven't actually measured it.The idea here is that the SSB shifter isn't really shifting by all that much. Just ~5Hz or so across the board. A 17-cent pitch shifter would shift by 5Hz at an input of 506.7Hz. More for higher input frequencies, less for lower. The top end of the intelligible range (~3kHz) is shifted by almost 30Hz, and the bottom end (~300Hz) by only 3Hz.---If you're going to do this "right", then the required shift is determined by the room's acoustic response. Specifically, an input of x Hz needs to come out at y Hz, where [y-x] is the distance from a peak to its adjacent null. That, in turn, is determined by the size of a wavelength that fits exactly in the room. Convert that to a frequency, and the peak/null period has that spacing in frequency. So a frequency shifter is better suited to line up with that across the entire spectrum, whereas a pitch shifter can only match at one point.That said though, the pitch shifter that I tried did give me a significant improvement in GBF. If you can get one easily and you're okay with how it sounds, then go for it!

author: moffy
author_rank: Super Contributor
timestamp: November 29, 2021, 04:07:07 am
content: Quote from: AaronD on November 29, 2021, 03:39:40 amActually, the amount of shift needed is proportional to frequency, not an absolute amount. A fixed Q BP filter has a BW proportional to its center frequency, so its not hard to imagine the rooms resonances as a series of BP filters of some Q added to a somewhat flat response(this is a big over simplification, but illustrative), so the shift required is proportional to the center frequency. Of course an EQ is a series of Band Reject/Band Pass filters at different center frequencies and BW again is proportional to center frequency of each filter.I'll let you know if I manage to get it working.

author: AaronD
author_rank: Frequent Contributor
timestamp: November 29, 2021, 04:30:33 pm
content: Quote from: moffy on November 29, 2021, 04:07:07 amEhh...not really. I think you made an assumption thateverythingworks in terms of bandpasses and other "single action" filters if I can create a term. But not everything does. Harmonics, for example, are spaced equally in frequency, so that the musical interval between them decreases with increasing pitch. Room responses are more similar to that than to a bunch of EQ bands. (a peak every 10Hz or so for example, regardless of absolute frequency, so shifting by 5Hz drops a peak into its neighboring null)You can see this by creating a wave in a rope. The longest possible wavelength is 2x the length of the rope, with a null at each end and a single peak in between. Another is 1x the length (2x the fundamental frequency), with a null at each end and one in the middle, and opposite-polarity peaks on either side of the center null. Another (3x the fundamental) has 2 nulls in the middle, with 2 peaks of one polarity and 1 of the other in the middle. Etc. Every time you do this, you have a whole number of peaks and nulls, and the number of peaks is exactly that multiplier in frequency. Adding a peak adds the fundamental frequency again. This is frequencyaddition, not multiplication.That's how a room response works. The walls are forced nulls in movement (peaks in pressure), and the peaks in frequency response correspond to the wavelengths that fit exactly in 1/2-wave increments between them. Then put some "single action" filters on top of that foundation, like drapes, bass traps, etc.Of course, you really don't want to mess up the direct sound any more than you absolutely have to, to fix a room's problems. Sometimes you have to, but because it's really a time problem - the speed of sound over the size of the room - our ears and brains are very good at separating the direct and reverberant sound into "what" and "where" information. If you mess up the "what" to fix the "where", then the wrong "what" can easily become more audible than a technically misbehaving "where".This is also why you don't want to blindly trust a measurement mic or anything based on one; it can't tell the difference between direct and reverb, and we can'tavoidtelling that difference. Use it to start with and to get somewhat close, but allow your ears to override the final result and produce something that's actuallygood. Don't just let it do its magic and leave it at that, or even put a "magic" fixed compensation curve on it. Anything that does not have your ears as the final authority, is just polishing a turd. It takes some real skill and a bit of time to do it that way (ears fatigue quickly so thatanythingsounds "right", so you have to take frequent breaks to let them reset), so contractors are reluctant to do it (thus, very few people have actually heard it to compare to), but thatisthe way to make itgood.A good shortcut, if you have the means, is to move the entire rig OUTSIDE (big parking lot or an open field, not an alley between buildings), use the measurement mic there, then re-install it inside. This is as close as you're going to get to an anechoic environment, and the mic does work there, simply because there is no room response to confuse it. Save that setting, make your final tweak by ear while wandering the room, and then double-blind test between the outdoor mic setting and your tweaks by ear, to see which one you go with. (double-blind means that the person operating the test rig doesn't know either, which is which or even if it changed, so as not to give any subliminal clues)

author: moffy
author_rank: Super Contributor
timestamp: November 29, 2021, 04:59:44 pm
content: Sorry, I must disagree, a 5Hz shift at 5kHz(0.1%) does not have the same effect as a 5Hz shift at 50Hz(10%), the Q is not infinite but finite and therefore BW is proportional to center frequency.

author: AaronD
author_rank: Frequent Contributor
timestamp: November 29, 2021, 05:12:10 pm
content: Quote from: moffy on November 29, 2021, 04:59:44 pmYour facts are right as far as they go, the percentage does change like that...but the percentage does indeed change. A lot of things work as you describe, including a single lobe of a room response in isolation. But the spacing between lobes is linear, and that dominates the equation.

author: AaronD
author_rank: Frequent Contributor
timestamp: November 29, 2021, 05:45:56 pm
content: Quote from: Kleinstein on November 26, 2021, 08:43:17 amI've made a few boards with this spacing, mostly to save on protoPCB costs (it's already 4 layers, so I don't pull my hair out trying to route power and signals around each other), and I've gotten used to it. I can still put a 'scope probe anywhere - the pads are still big enough for that - and I can tack a wire on too, for more permanent monitoring. Initial assembly is with paste and a toaster oven that I made my own controller for.I haven't needed to recently, but I've also made a tower of SMD capacitors when I was convinced that the value was way off. (that problem turned out to be something else)For someone not used to fine work, or that needs to hand-solder the whole thing; then yes, it would help to spread things out a bit. I also like the visuals of having modules physically packed together and then treated as a block. Not so much trying to cram a bunch of silkscreen into a tight space after I like the layout...oh well.There's also this thing in the back of my mind about long traces being antennas, so don't give them any more opportunity than absolutely necessary. Low-impedance traces, like the outputs of opamps, can be longer, but don't be ridiculous just because I can. That rule is broken in spades with the high-value panel pots in this design, but it's still habit. And we also have external cabling that is WAAAY longer than any trace could ever be, and isn't always shielded. (I've made some out of unzipped ribbon cable, for example)

author: AaronD
author_rank: Frequent Contributor
timestamp: November 29, 2021, 10:35:12 pm
content: Quote from: AaronD on November 25, 2021, 11:02:22 pm...but it's getting more discouraging. Fully specifying parts came out to $26 shipped for 5 copies of both boards from JLC, and $178 shipped for the parts from Mouser to populate 2 of them. (one for each of 2 different rigs) $204 total, compared to $143 shipped for 2 MIMXRT1020-EVK dev boards from Mouser, with an onboard CODEC and ARM7.I'm not sure if that's the right board for this project, just because of the specific CODEC that they chose and how it's probably hooked up - only 2 ADC channels total, and there's an onboard mic - but it does demonstrate the point of digital being cheaper, in addition to not having analog's famous non-idealities. (it just has a different set of non-idealities)So I guess I need to starta new threadasking for a decent DSP audio dev board to start playing with. I may eventually get back to making an analog version of this just for the "cool factor", but probably not now.