bitcrusher / ringmod build log

Started by cloudscapes, January 09, 2017, 01:28:28 PM

Previous topic - Next topic

cloudscapes

So I've been wanting to design a new bitcrusher/ringmod for a while now. The last time I built a bitcrusher that was more advanced than "crush" and "sameplerate" was back in 2009. And the last time I built a dedicated ringmod that wasn't just a side-feature was also around that time. Now I want to build something that's more like a multieffect, dozen knobs, and who's sound can range from subtle to totally unrecognizable on the other end. A couple of my sources of inspiration could be the WMD Geiger Counter, and especially the Alesis Bitrman:



Behind that cheaply made plastic enclosure is a noisemakers wet dream! I love this box, but at the same time feel it's too limited by only four knobs. So I aim to fix that by making my own reinterpretation of it. Here's a tentative block-diagram of what I have in mind, which I have no doubt will change as I work on it. The orange labels can sort of be seen as controls, which gives you an idea of how large this box might be.



Noise - Blendable noise. First in the effects chain so you can alter it in the most ways possible.

Bitcrusher - Your standard bitdepth and samplerate controls. I may add bit wrapping/masking toggles if I'm inspired!

Envelope - Think of it as irregular amplitude modulation. Not a stutter effect, but a kind of volume "pinging". I've already started working on a pseudo-random pattern generator, at the moment only blinking an led. At the moment, four counters each with a different "loop limit", so when you listen to it the pulse becomes progressively out-of-phase. There is a repeating pattern but it evolves over time, and isn't totally predictable. I'll add complexity to it to occasionally inject random variation, add one or two more counters, etc. These generated pulses then trigger an envelope generator which will use wavetables instead of your traditional ADSR. Then it simply modulates your audio signal.

Error generator - This one is still a bit nebulous. It might end up being a stutter/glitch effect, or something else. I don't know yet. I may or may not have it seeded by the pattern generator used by the envelope section.

Comb filter - Isn't exactly a filter but more an extremely short delay. Ever take a digital delay, det the time real low (<10ms) and feedback really high? I want to tweak this so it's a kind of metallic resonating. Especially after the wavetable envelopes, it could create really cool sounds I think! It's pretty easy to implement, just an extremely short digital delay line with variable time and feedback.

Ring modulator - Self-explanatory. I may have a wavetable here too for some interesting sounds beyond your traditional triangle/sine oscillator.

Low pass filter - The only part of this effect that will be analog! Possibly based off of a classic LM13600 filter or something.

So what's missing? Pitch shifting and frequency shifting are both very cool effects. And I sort of understand the basics on how to achieve them, but they both share a requirement that at present am unable to code. Digital FIR/IIR filters are needed for both digital filtering and phase shifting, which are needed. It's something I've been looking at for years, and still fail to properly understand. Concepts like filter cooeficients, and processing samples together in arrays rather than one at a time aren't things that are intuitive to me. There may be workarounds/hacks I can do for pitch shifting (an analog phase shifter, and sampling the unphased and phased audio together and doing the rest of the processing digitally), but I don't expect good results. I will try, though.

The easy solution of course would be to plug an FV-1 before or after my internal effects chain, but that seems dirty and inelegant to me.

The platform

I have two choices. The hardware I designed for my 14-second delay is more than adequate for the job (schematic)! It could of course be improved on, but it's a great starting point. Plus it's already entirely breadboarded, since I was working on this just a couple weeks ago. It's based around an 80MHz PIC32 microcontroller, which can be pin-for-pin swapped out for a 120MHz variant with better peripherals.

Or, I can move over to ARM, which I've never used for a project yet. I've gotten the basics down (timers, internal ADC sampling, basic SPI), but I'm not yet comfortable with them. I've been thinking of switching from PIC to ARM for a couple years. Undecided.

So I'll use this thread to log my progress. It may take days between updates, or weeks, or hours! I've started on what I believe to be the biggest challenge, the pattern generator used by the envelope effect. I've got an interesting pulse generator going, but at the moment I'm having a bit of difficulty using it to trigger wavetable envelopes, in the condition when a pattern pulse is re-triggered before the envelope has time to "finish". If this were a traditional ADSR, done mathematically, I wouldn't really have a problem. But I'm set on using tables.

I'll probably post a video of the pattern generator in a day or two! No real sound, maybe an audible pulse and a view of the oscilloscope, but it's something!
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

key-bored

Don't know whatcher gonna end up with, but i'll definitely be watching and waiting. 
Good project!


KB
Ray Charles said it, I believe it, That Settles it.

ElectricDruid

As far as the platform goes, I think you can definitely do everything you want to with the PIC32 you've already got. Not having to design new hardware saves you a massive amount of time. I doubt you'd even need to upgrade to the faster chip - there's nothing there which is particularly heavy computationally.

As far as the algorithm goes..well, it's a matter of personal taste, I recognise...but why *add* noise first up? I mean, won't you get enough downstream? If not, come round and use my amp - it hisses like a bag of angry snakes.

I dig the pseudo-random generator and the envelope - that's unusual and an interesting twist. The comb filter I would be a little bit worried about, since a static comb filter with high resonance provides a big boost at one particular frequency. I know what you mean about the metallic sound you get with short delays (which is good), but be careful you don't get something that goes "note, note, note, NNNNOOOOTTTEEEE!!!!, note, note", which is a bit my experience if I turn it up too much.

RingMod in the digital domain is a great idea. The usual problem with ring-mod is carrier bleed through, and if you can make sure that you've got zeros when you've got zero input, you shouldn't have any problems with that. I do recommend that DC blocking filter I sent you - works a treat, and is simple. Ask me if you're not sure - I've got dsPIC code for it which would convert to PIC32 without too much pain.

I also dig following all this digital craziness with a good old-fashioned OTA filter. For a start, the soft distortion will warm it all up and convince all the naysayers that it's not a "cold, sterile digital effect", and secondly a 2-pole SVF done with the 13700 just sounds wicked so is good to include, any which way. Again, if you want notes for this, ask me.

It sounds great. Good luck with it and keep us posted.

Tom

cloudscapes

So I'm starting with the irregular / pseudo-random pattern/pulse generator, and the envelope generator. Here's something quick I made, for now using the foundation of my delay project since it already has a working micro, ADCs, DAC, LEDs and a ton of pots all ready to go on a breadboard.

Here's the theory behind the pattern generator so far:



It's almost too simple! Four counters. Each one counts to a limit I define before it loops over. But when it loops over, a trigger is sent. And because there are four of them each with different limits, the "sum" of the triggers is a neat geiger-counter crackle that has a hint of repetition but is irregular enough to be interesting. Eventually, I can add complexity to it, like a chance for a trigger to repeat itself, or counters 1-2 trigger a certain envelope shape but 3-4 trigger a slightly different one. And of course I'm not limited to just 4 counters. Another bonus is this sort of thing is extremely easy to process by the micro.

At the moment, each trigger activates a simple ramp-up / ramp-down table. A current issue is often there will be a re-trigger before the wavetable has time to "finish", so its interrupted and starts over. It creates a hard edge I don't want. I think I'll do some quick interpolation to fix that. Each time there is a trigger, it should interpolate between the last "known" table value and some fresh ones over a dozen samples or so. It'll turn the hard edge into a ramp.

Because I'm using wavetables, I'll be able to draw up so many kinds of interesting envelopes, including some that don't necessarily peak once! Last year I wrote a program that imported a 256x256 image of a drawn out wave, and turns it into an array I can use.

Here's a short video I just made that shows what I wrote about. Including the part where re-triggers interrupt an envelope before it has time to finish. The frequency of pulses is sped up a bit so I can work more easily. But for the effect I have in mind, I think it'll be more effective if it's much slower. It'll be adjustable of course.

~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

EBK

I've never wanted anything even remotely resembling a bit crusher or ring modulator...

I've always scoffed at the notion of using "unpleasant" digital artifacts as a source of musical inspiration...

I've always felt that the people who embraced chaos as something that could make a guitar sound good were insane....

... Until now.  I find myself strangely compelled by this, like a hapless insect flying gleefully toward a bug zapper.  :icon_eek:

I can't wait to see where this project goes.  :icon_biggrin:
  • SUPPORTER
Technical difficulties.  Please stand by.

dbp512

I'm looking forward to seeing you develop this sweet idea. Also hoping you end up with an extra pcb/programmed chips I could get my hands on.
Dave's not here, man

On some nights I still believe that a car with the gas needle on empty can run about fifty more miles if you have the right music very loud on the radio
- Hunter S. Thompson

stringsthings

Quote from: dbp512 on January 09, 2017, 10:12:48 PM
I'm looking forward to seeing you develop this sweet idea. Also hoping you end up with an extra pcb/programmed chips I could get my hands on.

+1

ElectricDruid

Quote from: cloudscapes on January 09, 2017, 08:13:03 PM
Here's the theory behind the pattern generator so far:



It's almost too simple! Four counters. Each one counts to a limit I define before it loops over. But when it loops over, a trigger is sent. And because there are four of them each with different limits, the "sum" of the triggers is a neat geiger-counter crackle that has a hint of repetition but is irregular enough to be interesting. Eventually, I can add complexity to it, like a chance for a trigger to repeat itself, or counters 1-2 trigger a certain envelope shape but 3-4 trigger a slightly different one. And of course I'm not limited to just 4 counters. Another bonus is this sort of thing is extremely easy to process by the micro.

At the moment, each trigger activates a simple ramp-up / ramp-down table. A current issue is often there will be a re-trigger before the wavetable has time to "finish", so its interrupted and starts over. It creates a hard edge I don't want. I think I'll do some quick interpolation to fix that. Each time there is a trigger, it should interpolate between the last "known" table value and some fresh ones over a dozen samples or so. It'll turn the hard edge into a ramp.

Another way to approach this might be to swap from using 8-bit counters that count to a limit (so 118 for your counter 3) to using a 16-bit counter that wraps round using a larger frequency increment. So for counter 3, you'd add 555 to the 16-bit count each time, and it'd wrap around every 118 samples (Ok, 65536/555=118.08, but it's close enough). The advantage of this is that then the top byte of the counter can be used as a direct address into whatever lookup table you're using for the envelopes.
Although the addition gets slightly more complicated (double byte add instead of single) you don't have to do any upper-bounds checking, which is a good speed-up.

HTH,
Tom

blackieNYC

I would think when you slow down the speeds to where the effect comes thru, you'd find that the repetitions are imperceiveable. Even three selected waveforms (which I've rounded off with caps, not programming). Don't know what you project requires, but I say this if you are going to great lengths to achieve "random". And I do love me some random LFOs.   
Also, if you take this into high frequency modulation, will an elaborately constructed waveform survive ring modulation? I feel like I can put any extreme dirt into my (simpler than yours) ring mods and it comes out the same, sounding like a ring modulator. I think it would do the same thing to your not-as-low freq mod waveform.
  • SUPPORTER
http://29hourmusicpeople.bandcamp.com/
Tapflo filter, Gator, Magnus Modulus +,Meathead, 4049er,Great Destroyer,Scrambler+, para EQ, Azabache, two-loop mix/blend, Slow Gear, Phase Royal, Escobedo PWM, Uglyface, Jawari,Corruptor,Tri-Vibe,Battery Warmers

cloudscapes

Quote from: ElectricDruid on January 09, 2017, 05:23:30 PM
As far as the platform goes, I think you can definitely do everything you want to with the PIC32 you've already got. Not having to design new hardware saves you a massive amount of time. I doubt you'd even need to upgrade to the faster chip - there's nothing there which is particularly heavy computationally.

I might not upgrade to the faster ARM chip, but I might upgrade to the better pin-compatible PIC32. Not just for speed, but it also has much more ADC pins/channels broken out, and seeing how this thing will probably end up quite knob-heavy, I think it's a good idea. It will require almost no code and hardware modification.

Quote from: ElectricDruid on January 09, 2017, 05:23:30 PM
As far as the algorithm goes..well, it's a matter of personal taste, I recognise...but why *add* noise first up? I mean, won't you get enough downstream? If not, come round and use my amp - it hisses like a bag of angry snakes.

As a way to make the bitcrusher's limited headroom even gnarlier! It might not just be noise, but pops and cracks too. Just something I want to try. A very old samplerate reducer I built almost a decade ago was inherently noisy, but I liked the hiss/crackle/pop it produced in front of the effect, so I want to reproduce that (blendable).

Quote from: ElectricDruid on January 09, 2017, 05:23:30 PM
I dig the pseudo-random generator and the envelope - that's unusual and an interesting twist. The comb filter I would be a little bit worried about, since a static comb filter with high resonance provides a big boost at one particular frequency. I know what you mean about the metallic sound you get with short delays (which is good), but be careful you don't get something that goes "note, note, note, NNNNOOOOTTTEEEE!!!!, note, note", which is a bit my experience if I turn it up too much.

I might build in a limiter in the comb filter. Won't completely solve the possibility of RUNAWAYHOWL but it might help. And I just have to try it and hear anyways.                                                       

Quote from: ElectricDruid on January 09, 2017, 05:23:30 PM
RingMod in the digital domain is a great idea. The usual problem with ring-mod is carrier bleed through, and if you can make sure that you've got zeros when you've got zero input, you shouldn't have any problems with that. I do recommend that DC blocking filter I sent you - works a treat, and is simple. Ask me if you're not sure - I've got dsPIC code for it which would convert to PIC32 without too much pain.

I had (yet another) read on FIR anf IIR filters yesterday, as I do every 6 months for the last few years. I don't think I'll ever get it. My brain completely  shuts down against anything more complicated than straight algebra. Some people have a brain for math, others don't. I really don't.

If carrier bleed is too much of an issue, I might code a simple noise gate post-ringmod. I've had success in past analog ringmods/bitrate reducers and simple noise gates.

Quote from: ElectricDruid on January 09, 2017, 05:23:30 PM
I also dig following all this digital craziness with a good old-fashioned OTA filter. For a start, the soft distortion will warm it all up and convince all the naysayers that it's not a "cold, sterile digital effect", and secondly a 2-pole SVF done with the 13700 just sounds wicked so is good to include, any which way. Again, if you want notes for this, ask me.

It sounds great. Good luck with it and keep us posted.

Nothing wrong with "cold/sterile"!  8)

But it's nice to be able to dial in roughly how warm or cold it is.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

cloudscapes

Quote from: EBK on January 09, 2017, 09:38:35 PM
I've never wanted anything even remotely resembling a bit crusher or ring modulator...

I've always scoffed at the notion of using "unpleasant" digital artifacts as a source of musical inspiration...

I've always felt that the people who embraced chaos as something that could make a guitar sound good were insane....

... Until now.  I find myself strangely compelled by this, like a hapless insect flying gleefully toward a bug zapper.  :icon_eek:

I can't wait to see where this project goes.  :icon_biggrin:

"unpleasant" is always subjective as far as I'm concerned. when it comes to effects. That may be more because I have an experimental background when it comes to music.  ;D
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

cloudscapes

Quote from: ElectricDruid on January 10, 2017, 10:08:09 AM
Another way to approach this might be to swap from using 8-bit counters that count to a limit (so 118 for your counter 3) to using a 16-bit counter that wraps round using a larger frequency increment. So for counter 3, you'd add 555 to the 16-bit count each time, and it'd wrap around every 118 samples (Ok, 65536/555=118.08, but it's close enough). The advantage of this is that then the top byte of the counter can be used as a direct address into whatever lookup table you're using for the envelopes.
Although the addition gets slightly more complicated (double byte add instead of single) you don't have to do any upper-bounds checking, which is a good speed-up.

HTH,
Tom

Oh I never had any intention of limiting these counters to 8bit. They're already integers. I just start low because I have a pot that multiplies the count limits for a slower rate. I might change the way the rate changes later, this was quick.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

ElectricDruid

Quote from: cloudscapes on January 10, 2017, 04:56:29 PM
Oh I never had any intention of limiting these counters to 8bit. They're already integers. I just start low because I have a pot that multiplies the count limits for a slower rate. I might change the way the rate changes later, this was quick.

Ok, sorry. That's me thinking like an assembly language programmer. You're doing this in C, so it's a different story.

T.

digi2t

As a Bitrman, Geiger Counter, Mold spore, and String Ringer owner....

I'm really interested to see where this goes.

Oh... popcorn's done.
  • SUPPORTER
Dead End FX
http://www.deadendfx.com/

Asian Icemen rise again...
http://www.soundclick.com/bands/default.cfm?bandID=903467

"My ears don't distinguish good from great.  It's a blessing, really." EBK

Trackhappy

Hi Guys,
I am fairly new to Pic programming and very new to DsPic's. One member kindly sent me his code to look over, but it is WAY over my head (as he suggested it would be). I am trying to use a DsPic33 to make a ring modulator (Dalek Voice Modulator). I have some code that loops the ADC straight through to the DAC, which helped me immensely to understand the process and prove my physical setup (op-amps etc). http://soerenbnoergaard.dk/project_adcdac.html But I am not sure where to start. I was going to just do a straight multiplication of a sine table and the incoming audio, but that is not really using the capabilities of the DsPic33. Can anybody point me at DSP for Ring mod 101? A basic explanation of how DSP is used to do this, and what sort of C code would be great. Most of what I have found so far is WAY over my current understanding. The eventual objective is a Ring Modulator with a variable Sine wave input from about 20Hz to 80Hz.

Thanks in advance,
Glenn.

balkanizeyou

I have never programmed any DSPs, but a common sense idea would be probably something like that:
do the FFT, add and substract the frequency of your modulating sine to the frequencies you got from the FFT, and then do the reverse FFT to go back to the time domain.

ElectricDruid

Quote from: balkanizeyou on April 05, 2017, 03:18:01 PM
I have never programmed any DSPs, but a common sense idea would be probably something like that:
do the FFT, add and substract the frequency of your modulating sine to the frequencies you got from the FFT, and then do the reverse FFT to go back to the time domain.

No! Don't do that! Much too complicated for something as simple as Ring Mod!

Ring Mod is multiplication in the Time Domain, and that means just take the sine wave modulator sample and multiply it with the incoming audio sample. It really *is* that easy.
Only twist is the signals are both bipolar, so it needs to be signed arithmetic. That's not a big ask on most platforms.

Tom

balkanizeyou

Quote from: ElectricDruid on April 05, 2017, 04:21:55 PM
No! Don't do that! Much too complicated for something as simple as Ring Mod!

haha, oh well, never listen to any of my "advice" on DSP then. It's just a habit I got into at the university: "if you want to process a signal - go to frequency domain, manipulate it all you want and then go back".

A few seconds after typing that I realized how stupid would that be in case of, let's say, a delay pedal  :icon_lol: never mind the ringmod

Agung Kurniawan

Multiple gain stage followed by some active EQ is delicious.