"Cruncher" bit-rate and resolution reducer

Started by ElectricDruid, November 27, 2019, 04:19:23 PM

Previous topic - Next topic

ElectricDruid

Ok, so this is what I've been working on the last couple of weeks. It's now in a stable and workable condition!

I had problems getting the CMOS switching quiet initially, but that was fixed by running the chip with a virtual ground so it thinks it's got a +/-4.5V supply. Seems happy like that, and switches very very quietly. I can't say "silent" because if you turn everything up really loud with no input signal you can hear it, but then you burst your eardrums and your speaker cones, so it's not a great idea.

The crunching itself is done by the PIC which samples at 10-bit resolution and a variable rate, and then outputs data at a variable resolution too. The sample rate can be reduced from 24KHz (reasonably good but noticeably "not hifi") down to 400Hz. That's low enough to totally mangle even bass notes, and cause aliasing reflections to scramble the notes in a scale so that you can hardly tell what order you played them in. The resolution goes from 10-bit down to 3-bit. That reduces your expensive guitar's beloved tone down to a meagre eight levels. It's like Minecraft for your sound.

The PIC controls the switching too, so I was able to implement long press/short press on the foot switch. Short press toggles the effect on and off like a typical pedal. A long press only puts the effect on while the footswitch is held down, so you can add a bit of crunch to just a couple of phrases.

Here's the schematic:


Here's what it sounds like reducing the sample rate (twiddling the knob, dropping it down in stages, then turning it back up at the end):
https://electricdruid.net/sounds/cruncher/CruncherSampleRate.mp3

..and this is reducing the sample resolution/bit depth (gradually turning it down all the way):
https://electricdruid.net/sounds/cruncher/CruncherResolution.mp3

Doing the two together is enough to reduce famous riffs to mush! (It has something of the chip-tunes 8-bit era sound to it. I can imagine that coming out of a Commodore64 and my younger self being really impressed!)
https://electricdruid.net/sounds/cruncher/CruncherSandman.mp3

Enjoy!

I've got a few other plans for this hardware. Basically anything that can be done with extremely under-powered DSP is possible! The mind boggles with the vast range of hideous crunchy lo-fi opportunities that await!

Tom


Scruffie

Very cool! Nice to have an easy step out of the Sample & Hold variant (I tried the old school variant with the ADC/DAC chips too and this sounds much better!) so is the 4053 just being used for the alternate switching modes or does the effect rely on it?

How did you solve the V.Ref issue in the end? Was it just the TL072 unhappy in the job or a breadboard issue.

I can think of so many ways to use this...

anotherjim

Fast work!

Was the ADC noise trouble due to it toggling between b10000000 and b01111111 then? Odd, written like that it looks a lot, but it's only a "1" apart and LSB toggling is always going to happen -  something internal getting upset by the multiple bit switches at 127/128? Oh, but it's a 10bit ADC so the low byte bits are all toggling at mid-scale...




ElectricDruid

Quote from: Scruffie on November 27, 2019, 07:22:08 PM
Very cool! Nice to have an easy step out of the Sample & Hold variant (I tried the old school variant with the ADC/DAC chips too and this sounds much better!) so is the 4053 just being used for the alternate switching modes or does the effect rely on it?

The 4053 is just for switching. You could build it true bypass, but you'd lose the "momentary" mode. It'd make for a very simple circuit though.

Quote
How did you solve the V.Ref issue in the end? Was it just the TL072 unhappy in the job or a breadboard issue.
I rebuilt the circuit separating the supplies (not tying Vee and Gnd together) and on the second prototype I haven't got the problem. I eventually traced the problem on the original stripboard.The rail splitter op-amp was oscillating for some reason, at about 300-400KHz. That oscillation fed into the ADC caused wideband noise, since it would have been reflected a dozen times by aliasing.

Quote
I can think of so many ways to use this...

Do go on...I'm all ears!

ElectricDruid

Quote from: anotherjim on November 28, 2019, 05:12:09 AM
Fast work!

Was the ADC noise trouble due to it toggling between b10000000 and b01111111 then? Odd, written like that it looks a lot, but it's only a "1" apart and LSB toggling is always going to happen -  something internal getting upset by the multiple bit switches at 127/128? Oh, but it's a 10bit ADC so the low byte bits are all toggling at mid-scale...

The problem with the 127/128 boundary (or the 512/511 boundary for 10-bit, same thing really) comes when you reduce the bit resolution right down. There will inevitably be *some* ADC noise (or even just input noise being accurately converted). If we reduce the output to 1-bit and that noise is making the input value jump from 127/128, then we get a huge square wave output. (output goes high for 128, then goes low for 127, etc). Moving the bias down a bit provides a "gating" threshold effect which keeps the noise at bay for those very very low resolution outputs.

anotherjim

Have you tried a bit reduction mode when one 1 (and only 1) bit is masked out to 0 or 1.  This is another kind of bit reduction but a lot different than the usual approach of dropping only the LSB's. Taking out bit 0 or 1 this way makes little difference, but any of the bits in the middle being fixed can cause quite a racket.


bluebunny

  • SUPPORTER
Ohm's Law - much like Coles Law, but with less cabbage...

anotherjim

Who's all ears?


Demos sound good. Does what it says on the tin.

ElectricDruid

Ok, weird things are going on.

As you've heard, I had this working. I'd been experimenting with the power supply splitter, so I'd got that part on the breadboard, and the rest on a strip board prototype. Last night, since it was working, I decided to move the rail splitter to the strip board. Did that, and the noise problem came back.

Thinking about it today, I realised there was only one thing I'd changed. Last night I noticed that I'd never added the connection from pin 8 of the 74HC4053 to ground. It was connected to pin 6 (Inhibit , which is also supposed to be grounded) but the two of them weren't connected to anything else.

So this morning I took that wire out again - lo and behold the noise disappears! I can now switch the noise on and off by shorting pin 8 to ground with a bit of wire! When grounded, there's noise, when not grounded, there isn't.

Any ideas? I shall investigate further, but if the noise is the same as it was in the earlier prototype, it's a ultrasonic oscillation in the rail splitter op-amp. Seeing as I only need DC gain, is there anything can I do to squash the gain at higher frequencies in a unity-gain follower?

Thanks,
Tom


FiveseveN

Sorry if I missed it, but have you tried not using the follower? Or some other option that's been discussed lately, like a 386 or special rail splitting IC?
I've been wanting to build this kind of effect, and actually one of my thoughts was to use a 405x for aliasing, maybe uC-controlled. By the way, any chance we may welcome you to the Arduino cult community in the future?
Quote from: R.G. on July 31, 2018, 10:34:30 PMDoes the circuit sound better when oriented to magnetic north under a pyramid?

ElectricDruid

Quote from: FiveseveN on December 01, 2019, 08:06:53 AM
Sorry if I missed it, but have you tried not using the follower? Or some other option that's been discussed lately, like a 386 or special rail splitting IC?

Yeah, I've got the follower as appears in the schematic at the top of the page.

Quote
I've been wanting to build this kind of effect, and actually one of my thoughts was to use a 405x for aliasing, maybe uC-controlled.
Well, so far uC-controlled 4053 isn't working out that well for me! But I think there's a way - I just haven't found it yet.

Quote
By the way, any chance we may welcome you to the Arduino cult community in the future?
Perhaps. I've been wondering about moving to STM32 or Teensy for some stuff I want to do that needs more power or more pins, but I'm unlikely to bother with the basic AVR Arduino's since I can already do all the stuff they can do in PIC assembly. If I finish up with Teensy, I'd be developing in an Arduino environment for the first time.

anotherjim

You can fit a low-value resistor in series with the output and take the feedback from the load side of that. The resistor needs to be just large enough to move the phase shift caused by the load capacitance - which isn't obvious but it's all of it between ground and Vss/Vdd. Start small, say 10R.

ElectricDruid

Thanks, I'll give it a try and report back.