Stepping into the digital world with a DIY guitar DSP effects system

Started by dougman0988, February 26, 2011, 04:25:05 PM

Previous topic - Next topic

dougman0988

My original topic:  http://www.diystompboxes.com/smfforum/index.php?topic=88921.0

=== Introduction ===

I'm like a lot of DIY'ers in that I really want to explore the digital side of
developing guitar effects.  In school, we were spoiled on 8-bit PIC processors,
so I wanted to take the next step and try out Microchip's 16-bit dsPIC chips.

My goal is to develop a simple DSP platform with which I can sample a guitar
signal, try out some filtering/waveshaping/whatever, and spit the samples out
of the on-board audio DAC.

In short, I hope that this thread does the following:

1.  Shows where I'm currently at with the project and provide a place for updates.
2.  Allows other members of the community to ask questions and/or contribute ideas.
3.  Shows other curious DIY'ers how a DSP system can be implemented to get real, audible
    results with relative ease.

Keep in mind that this is, and will probably be for quite some time, a WORK-IN-PROGRESS!
We all know the learning process never ends, but I'm really enjoying this project so far and
I wanted to share it with everyone here.   ;D

I'll try to include a high-level overview of the system and its major parts for now, but
please feel free to ask questions and/or make requests and I'll be happy to respond with
more details.



=== Schematic ===




DSP:  The brain of the system is the 16-bit dsPIC33FJ64GP802 processor from Microchip.  This
      chip was chosen because it has all the required peripherals on-board, including a
      12-bit ADC and a 16-bit stereo DAC specifically designed for audio purposes.  It runs at
      at 80Mhz, or 40 MIPS.  The dsPIC chips are essentially the same as Microchip's regular
      16-bit processors (PIC24) except that they also have a DSP engine.

Port Expander:  This is used for extra general purpose input/output, or GPIO for short.  It
      has two ports, each with 8 additional I/O lines. Right now, I
      am using 4 lines as data to my LCD screen.  I plan on keeping the entire other
      port unused for now, and using a header for easy access to those
      pins later on, just in case the extra I/O is needed. (add-on boards?)

LCD Screen:  The display is a 16x2-line character LCD.  I'd like to keep this in the system
        and eventually use it as a user-interface.  Perhaps program a few different
        effects and use buttons with the display to act as a simple menu to select which
        algorithm the user wants to use.

Dual Op-Amp:  The special feature of the MCP6022 chip is that its outputs are rail-to-rail
         capable and it runs on 5 volts.  The DAC output only swings about 1Vrms peak
         so there is plenty of headroom.  The DAC outputs are also differential, so
         the op-amps convert the signals to single-ended.


=== Programming the dsPIC ===

Programmer:  Pickit 2
Compiler:  MikroC PRO for dsPIC30/33 and PIC24

You can program the dsPIC (along with MANY other Microchip devices) with the above tools.
MikroC PRO is a trusted, VERY GOOD third-party C compiler with excellent software libraries.
It is free to download here: http://www.mikroe.com/eng/products/view/231/mikroc-pro-for-dspic30-33-and-pic24

The Pickit 2 is a Microchip programmer that can handle basically all of Microchip's
processors except for their latest-and-greatest ones.  It's a great tool for hobbyists
at only $34.99:  http://www.microchipdirect.com/productsearch.aspx?Keywords=PG164120

I have code written already to communicate with the other devices in the system.  Thus, there
is a single location in the main function where you can play around with coding different
effects algorithms.  So, if you don't want to concern yourself with anything else, you can
just jump right to that spot in the code and start programming some effects!


=== My First Digital Effect:  Foldback Distortion ===

With a working ADC-DAC loopback platform, now we can get to the fun part.  One simple
distortion algorithm (which I admittedly found online somewhere) is called a foldback
distortion.  Basically, the algorithm clips the samples at a certain threshold that you
define, then it clips additionally based on the difference between the sample and the threshold.
So, the bigger difference between the signal and the clipping threshold, the more clipping
you will actually get.  The resulting sound isn't super-impressive, but again, this was the
very first thing I tried and honestly I was just excited to be able to hear that my project
was working!


=== Conclusion and Tentative Plans ===

Hopefully this thread will be helpful to others who want to develop their own DSP systems.
Sure, it ain't the best, but it works, and its a great way to take that first big step into
learning more about digital devices and applying it to something cool like guitar!

As a side-note, I thought it might be worth while to have professional PCBs made.  I'll see
what kind of response this post gets and maybe if there is enough interest I can take that
step and do a layout.  I just don't want to pay for several boards when I really only need
one or two for myself.  If other folks are interested in the project maybe I can order some
though and make a little kit out of it.

I planned on adding support for EEPROM and SRAM chips just in case extra memory
is required.  Also, analog pots will be added so the user can change parameters in real-time.

Aside from that stuff, I'm going to continue to experiment with different algorithms and just see
what kind of sounds I can get.  Again, any suggestions in this area would be fantastic!   :P


=== Attachments ===

Code, sound samples, pictures, etc are available upon request.
www.pickuptheguitar.com
Guitar lessons, music theory, audio projects

potul

Hi

looks like a lot of fun!

It seems some of us in this forum have been putting our eyes on dsPICs, you are the 3rd one in a couple of weeks who starts playing with them.
I found dspic33 to be a perfect starting point for digital experimentation, as they have almost everything needed already in the PIC (although I wish they would have more RAM).

I saw the foldback distortion algorithm some time ago (I think in musicdsp), but didn't try it my self. How does it sound?
So far I've only experimented with modulation based effects (tremolo, flanger, chorus), and a little delay (limited by the amount of memory). I want to try next some compression algorithm, and I'm also experimenting with pitch shift.

Good luck, we will follow closely your progress.

Mat

JKowalski

Quote from: potul on February 26, 2011, 05:37:54 PM
Hi

looks like a lot of fun!

It seems some of us in this forum have been putting our eyes on dsPICs, you are the 3rd one in a couple of weeks who starts playing with them.
I found dspic33 to be a perfect starting point for digital experimentation, as they have almost everything needed already in the PIC (although I wish they would have more RAM).

I saw the foldback distortion algorithm some time ago (I think in musicdsp), but didn't try it my self. How does it sound?
So far I've only experimented with modulation based effects (tremolo, flanger, chorus), and a little delay (limited by the amount of memory). I want to try next some compression algorithm, and I'm also experimenting with pitch shift.

Good luck, we will follow closely your progress.

Mat

Yeah, it's pretty interesting how many people suddenly took the leap to dsPICs. I've been wanting to do this for a long time and buying a Pickit3 finally let me.

It's pretty great though, nice to have a group of people making the foray at the same time, good support!



Just a note - I believe that if you are reading the busy flag on the LCD display you are going to have a 5V signal going into your port expander chip.


dougman0988

Thanks for the feedback guys!  It's cool to see other people are going this route as well.  Do you guys have any suggestions for trying out the modulation based effects you mentioned?  I have yet to give those a shot.

I'll work on getting some sound samples up from the foldback distortion.  I also wanna take some pictures once I get the project onto some protoboard.  I'm just starting a big job and have a baby coming soon so I'm a little tight on time right now  :icon_wink:
www.pickuptheguitar.com
Guitar lessons, music theory, audio projects

potul

Take a look at this document:

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.110.4688&rep=rep1&type=pdf

It contains a good explanation of most of the modulation based effects and more. You will not be able to use the code, because it's not for dspic, but you can get the concept.
You need a couple of building blocks:

Delay line
LFO

Once you have these 2 working, you can create some of the basic modulation stuff (flanger/chorus, tremolo, etc...)

Here you have an example of Delay line, although it will require some tweaking:

http://www.dsprelated.com/showcode/58.php

And for information around using DDS to create an LFO, you can check here:
http://www.electricdruid.net/index.php?page=info.dds

Have fun,

Mat

potul

Hi,

I recorded a first crappy video demoing some of the algorithms I'm playing with. I love the sequenced tremolo

http://www.youtube.com/watch?v=Yj0t6TNvrgM

Enjoy.

jasperoosthoek

Great stuff, count me in! I would be interested in a professionally fabbed PCB if you decide to design it.
[DIYStompbox user name]@hotmail.com

dougman0988

Apologies for taking so long...here's some preliminary pics of the system on a breadboard (not all parts are on the breadboard right now) and the PCB.

I also purchased a drill press today, just waiting for the drill bits to come in, then I can continue.   ;D

Took the pics with my iPhone so the image quality is meh, hehe.

Thanks for the resources potul, and your effects are very cool, I'm hoping I can try out stuff like that as well!

Breadboard:


Top side:


Bottom side:
www.pickuptheguitar.com
Guitar lessons, music theory, audio projects

potul

Nice PCB

By the way, how's the noise in the breadboard? I've been playing myself with a similar setup, and I've got a lot of noise or crosstalk or similar. i.e I get a noise whenever a LED is on.

Mat

dougman0988

Thanks potul (or Mat if you prefer!)

I started this project using external ADCs and DACs...I had noise issues with the DAC output, it wouldn't stay steady.  Since I've switched to the dsPIC's peripherals I can't say I've had much trouble with noise. *knock on wood*
www.pickuptheguitar.com
Guitar lessons, music theory, audio projects

dougman0988

Alright!

It took me a while, but the PCB is fully assembled and everything seems to be working great.

Now the experimenting can officially begin!  Anyone have good suggestions for maybe some interesting distortions or short-delay modulation types of algorithms?  In the meantime, I'll be playing with this thing to see what kind of sounds I can create.   :icon_biggrin:



www.pickuptheguitar.com
Guitar lessons, music theory, audio projects

potul

Looks great! Let the fun start!

I would start by coding a simple delay line and an LFO. With this you can get much of the modulation/delay effects. Probably the easier one is a Flanger.

Mat

Bigorno

Hello dougman0988,

I'm planning to do something similar but with the Texas Instrument Launchpad.
I'm new to the DIY realtime audio Processing and your project is a big source of motivation.

Do you want to share with me the code that read the stuff from the ADC and send it back to the DAC please?  :icon_redface:
First I don't want to do any guitar processing.  :icon_cry:

I want to understand what you did with this chip and then I will implement it on the TI msp430 chip.  :icon_mrgreen:

Thank you very much for your help.

Thierry

Max OLydian

Hey dougman- are you still working on this? I've been thinking about starting a project like this myself, and if you're still active, it'd be great to collaborate.

dougman0988

Quote from: Max OLydian on May 06, 2012, 08:55:14 PM
Hey dougman- are you still working on this? I've been thinking about starting a project like this myself, and if you're still active, it'd be great to collaborate.

I will admit I haven't touched the project in quite a while, beyond the point of passing audio and trying to code some *extremely* basic sounds.
Too many things going on lately...but I definitely want to get back to it and try some more effects.
Have you gotten started with something?
www.pickuptheguitar.com
Guitar lessons, music theory, audio projects

Max OLydian

Hi dougman, back again- I hear you about being busy, same with me.  No, I haven't actually started anything yet, was still in the parts spec stage.  How do you like the dsPIC?

brownt


brownt

Thanks for the code doug. I will take a look at it. Looks similar to the example from Microchip. CE154_ADC_DAC_LOOPBACK. I am using MPLABX. I used a I2C LCD and just a single DAC channel as output. Works OK. I found a good delay algorithm. Used foldback distortion which sound pretty average, and tremolo which I think was OK. Also tried a few FFT applications from CE005 - Using FIR Filters from dsPIC Filter Design and DSP library. Worked OK, but I stopped short of purchasing microchips digital filter design program.

DSP is very complicated stuff and a bit beyond me actually. So, I have taken another path, but am still looking back sometimes because aside from the DSP difficulty, it really is the best option for me.

Blackaddr

@brownt

I originally started down the path of doing my own DSP audio on FPGAs because that's what I did at my day job. However, the work involved in coding for FPGA or DSPs is significant. I eventually realized if my goal was to write my own DSP effects, the smarter way was do it with VST plugins (even though I knew FPGA coding but did not know VST).  Since switching to VST, I spend more time on the audio algorithm design and playing my guitar through it, and less time doing raw coding.

If hardware DSP programming won't be worth the time invested, have you considered instead writing your own VST plugins?  It's lets you write the audio processing in regular C or C++ so coding is much faster and less laborious than DSP or FPGA coding.

The key to making this easy is to use a VST/GUI framework that does the hard/boring stuff for you. JUCE is a great framework for quickly building VST plugins so you spend little time building a functional GUI and worrying about the mechanics of getting audio and MIDI in and out of the plugin. JUCE and the VST software frameworks are free.  There are also many free VST hosts.

All that money you save on DSP hardware though should be invested in a good audio interface if you don't already own one. For around $100 USD used, you can easily find entry level interfaces like the Presonus 22VSL or Focusrite Scarlett 2i4.  Just make sure you get one with MIDI ports so you can add a MIDI Foot Controller later if you want. This lets you use your software pedal just like a real one.

I've recently put up an article and blog post on my website.  It's about using VST software for gigging, but it illustrates that software VSTs can be used just like real hardware, even for playing live or jamming.  It's not just for desktops and bedroom studios.

I actually plan to write a tutorial article about JUCE/VST programming in the coming months as well.

Check out www.blackaddr.com
Blackaddr Audio
Digital Modelling Enthusiast
www.blackaddr.com