Author Topic: Getting started with DSP for audio effects  (Read 5477 times)

0 Members and 1 Guest are viewing this topic.

Offline Jon86Topic starter

  • Frequent Contributor
  • **
  • Posts: 526
  • Country: gb
Getting started with DSP for audio effects
« on: November 14, 2018, 01:15:48 pm »
Hi all, first post after a long time away, it's good to be back :)

So I'm starting my electronic engineering degree (finally) and I'd like to expand my skillset with some DSP experience. My end goal is to be able to design digital guitar effects processors, obviously nothing insane just some simple distortion/reverb/delay kind of stuff that you see on virtually every piece of Chinese guitar gear these days.

I'm trying to find a good platform that will make development as cheap and simple as possible, if there's an Arduino equivalent in the DSP world then this is where I'd love to start. I'm quite familiar with the MSP430 platform, and I know TI do a lot of DSP products, but I'm not sure if this is the most practical place to start.

I've seen graphical DSP programming tools before, are they still a thing? Seems like this would be a great place to start. I'm familiar with C and some of it's cousins but obviously I've got zero experience with the world of DSP and DSP algorithms.

Any help gratefully received!
Death, taxes and diode losses.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5408
  • Country: gb
Re: Getting started with DSP for audio effects
« Reply #1 on: November 14, 2018, 02:24:18 pm »
There are two distinct areas to deal with.

o Firstly, learning DSP.

o Secondly, learning the target hardware and tools.

If you try to tackle both of these at the same time, it will be a lot more challenging. Try not to run before you can walk!

To deal with the learning DSP, I very strongly recommend developing the algorithms on a PC (usually in C) first, and then porting it to you target platform. You can use your soundcard interface, but be aware that typically there's tons of latency which will be useless for a real effects pedal, but it's an excellent way to test out your algorithms without the extra complication of cross-compiling and debugging.

For the target hardware, become comfortable with it in its simplest terms first and then port your algorithms. Inevitably, apart form the the most trivial of tasks, you'll find you need to optimise you algorithms on the target hardware, but I tend to keep the same source code on PC and target, with #ifdef...#else...#endif around the platform specific optimisations.

The hello world of the DSP world is generating a 1kHz sine wave.

I learned the hardware side with the help of the Digital Signal Processing series originally authored by the late Ralph Chassaing. Donald S Reay has taken up the mantel and has a version based on a few ARM Cortex M4 boards. Be aware that one or two hardware options mentioned in the book are difficult to find, but the author has a new board that's readily available identified on the book's website.

Note that the Cortex M4 isn't really a DSP, it just has a few extra instructions, but that may well be enough for your purposes: I've done some pretty nifty DSP stuff myself on the M4 in the past, for example this AM radio receiver which takes the RF into an on chip ADC, does a quadrature downconversion and filtering, demodulates the signal, and sends the audio to a PCM output.



 
The following users thanked this post: Jon86

Offline MRMILSTAR

  • Contributor
  • Posts: 17
  • Country: us
Re: Getting started with DSP for audio effects
« Reply #2 on: November 14, 2018, 03:31:43 pm »
As a previous poster said, walk before you run. Before you can do anything meaningful, start with basic DSP theory. Understand the basics such as:

* ADCs and DACs (quantization noise, dynamic range, analog anti-aliasing filters, analog reconstruction filters)
* Nyquist sampling
* Aliasing
* Digital filters
* FFTs (start with the DFT)
* Fixed-point arithmetic (even if your target processor has floating-point hardware)

Until you understand these basic concepts, trying to write code that functions properly will be extremely difficult and you will be trying to decide if your code is buggy or your theoretical knowledge is wrong. There are many textbooks and on-line sources that will give you this information. With an understanding of these basics you can then start to write working DSP software. For eventual real-time implementation on your target hardware, write in C or possibly even assembly language for specific operations. Before implementation in C on your target hardware, you could use a higher level simulation tool such as Matlab or Simulink hosted on your PC to gain a quicker understanding of your algorithm without worrying about the fine details of C programming.

As far as target hardware goes, that all depends on the complexity of your DSP software and the bandwidth of the signals you are dealing with. For simple low bandwidth applications like an audio signal generator, you might get by with an Arduino. For higher bandwidth and/or higher complexity applications, you could use a target board with a DSP on it (e.g. TMS320 series) and suitable ADC and DAC. You would then need development system software (compiler, assembler, linker, JTAG interface) to go with the DSP. Some of the single board computers may also be suitable. To really know what target hardware that you need, you have to determine the number of multiply-accumulate operations per second (MACS) that your application needs since MACS are the heart of DSP. Then find a processor that can deliver that performance.
« Last Edit: November 15, 2018, 04:04:16 pm by MRMILSTAR »
 
The following users thanked this post: Jon86

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15360
  • Country: fr
Re: Getting started with DSP for audio effects
« Reply #3 on: November 14, 2018, 04:51:01 pm »
First you'll have to define your exact goal. Do you want to learn DSP or do you just want to get familiar with processors labeled as DSPs?

For the first one, I think your best bet would be to start with a good book on DSP - there are plenty of them. As a platform for exercising, I suggest starting with Matlab or something similar (such as Scilab). You don't need any DSP board/dedicated hardware to get started with DSP.

For the second, you can take a look at one of Analog Devices ADSP eval boards for instance. Note that they are not cheap and the software tools aren't either.
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 6966
  • Country: nl
Re: Getting started with DSP for audio effects
« Reply #4 on: November 14, 2018, 06:05:50 pm »
Teensy is the arduino equivalent for audio DSP. Has a Cortex M4F.

Forget about graphical DSP programming though unless you want to shell out huge amounts of money for platforms using hugely expensive Sharc DSPs ... or alternatively if you want to tweak the knobs on the overpriced SigmaDSP toy chips. Please don't do the latter, it makes me sad.
« Last Edit: November 14, 2018, 06:12:33 pm by Marco »
 
The following users thanked this post: Jon86

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1685
  • Country: gb
Re: Getting started with DSP for audio effects
« Reply #5 on: November 15, 2018, 01:02:56 am »
DSP is a huge subject, and can get really quite gnarly in terms of maths.   However, many guitar effects are quite basic in their function.  Tremolo for example simply modulates the input signal with an oscillating signal (sine, triangle wave etc..).  That just requires a table for the modulating wave, and multiplying the input with it.  "Distortion" is a subject in itself, but essentially is just clipping the signal peaks which introduces higher harmonics.  Delay is just how it sounds, the signal is passed through a delay line (= RAM, lots of RAM..) and fed back into the input after attenuation.  Phasers, literally mixes the input signal with a variable phased version of that signal, and chorus uses slight delay and pitch changes.

There was a chip specifically for easing one into DSP effects, the FV-1 by Spin semiconductor.  I have one, but never got around to playing with it.  It was rather basic but had everything one needs to get started on chip, ADC, DAC, RAM buffers etc..   It didn't have the best support, but there were libraries one could use as templates.

Filters are a subject in themselves but are essentially achieved with a series of multiply and accumulate (which is why DSP specific devices have dedicated hardware for this function, and can do many in parallel, and why the teensy with an M4F was mentioned).  The trouble with a lot of educational sources is that they tell you what is done in DSP, but not necessarily why or even how.  I'll have to search for an excellent introduction to DSP filters I have bookmarked somewhere.  It starts off with your standard window averaging, and eventually gets to IIR vs FIR and how to implement them, and it quickly becomes clear why DSP chips are the way they are.  Can't find it right now..

 
The following users thanked this post: Jon86

Offline coppice

  • Super Contributor
  • ***
  • Posts: 9489
  • Country: gb
Re: Getting started with DSP for audio effects
« Reply #6 on: November 15, 2018, 04:25:26 am »
So I'm starting my electronic engineering degree (finally) and I'd like to expand my skillset with some DSP experience. My end goal is to be able to design digital guitar effects processors, obviously nothing insane just some simple distortion/reverb/delay kind of stuff that you see on virtually every piece of Chinese guitar gear these days.
"Just simple" and "distortion" are really incompatible. As soon as you introduce almost any form of distortion you expand the bandwidth of the signal. Managing that, so you don't run into aliasing problems, is not simple.
 

Offline Sparker

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ru
Re: Getting started with DSP for audio effects
« Reply #7 on: November 15, 2018, 05:10:03 am »
I agree with what MRMILSTAR said. Maybe not exactly study FFT though at first, but DFT in general. I think that checking how DFT works really helps you understand the problems of proper sample rate, aliasing, etc..

I'd recommend these books/resources personally:
1. Books and articles by Rick Lyons are great and very easy to read. Very good for introduction.  :-+
2. Discrete-time Signal Processing by A. Oppenheim and W. Schafer if you need very deep study of the topic. There are also Oppenheim's DSP lectures on Youtube.
Also coursera has a good DSP course. There are lectures from these course uploaded to YouTube.

These resources helped me a lot, I hope it helps you as well!
 

Offline TimNJ

  • Super Contributor
  • ***
  • Posts: 1712
  • Country: us
Re: Getting started with DSP for audio effects
« Reply #8 on: November 15, 2018, 04:40:01 pm »
You can use whatever programming language/environment you want, but I'd suggest using whatever is easiest to get up and running, without much fuss.

I've used MATLAB in the past. GNU Octave is a pretty close open source equivalent. Python with some additional libraries can work well too. You can use these tools as a "proving ground" for your future embedded development.

You don't necessarily need a DSP-specific chip to do embedded DSP. A "normal" microcontroller might be powerful enough, but it really depends on what  you want to do. Anything with a Cortex M4 is probably powerful enough though. I've been toying around with some Silicon Labs parts.

 

Offline Apollyon25_

  • Regular Contributor
  • *
  • Posts: 66
  • Country: nz
Re: Getting started with DSP for audio effects
« Reply #9 on: November 15, 2018, 11:16:12 pm »
If you are starting your engineering degree anyway, find out what software they use for the DSP sections (my uni used Matlab) and then use that.
 

Offline janekm

  • Supporter
  • ****
  • Posts: 515
  • Country: gb
Re: Getting started with DSP for audio effects
« Reply #10 on: November 16, 2018, 07:45:25 am »
Have a look at the CMSIS DSP libraries which can be used with ARM-based microcontrollers from all the major vendors. Plenty of dev boards around and the library is quite easy to use (by DSP standards).
On most chips it'll be grunty enough for simple guitar effects.
 

Offline diyaudio

  • Frequent Contributor
  • **
  • !
  • Posts: 683
  • Country: za
Re: Getting started with DSP for audio effects
« Reply #11 on: November 16, 2018, 09:44:59 am »
Most of your DSP effort, when working either with a Processor or MCU  is not even DSP related, 70% of the work is actually digital audio timing and configuration, i.e getting the platform to efficiently take audio samples and move it (fast) from some audio source to some destination, Example: An I2S (source) to an audio codec (destination), this is where all the effort lies, its takes some domain knowledge (familiarity) to setup a system just to perform what is known as a "talk through" sample, the DSP is just code that can be ported from Matlab to some target (or a library like cmsis dsp).
Lucky for you, you dealing with a single channel audio effect, significant effort applies.

One of the best learning eval boards for this and cheap is a STM32F4 discovery it has everything you need, and the sample code actually works, plus there are lots of resources on the internet.   

« Last Edit: November 16, 2018, 10:28:54 am by diyaudio »
 

Offline ehughes

  • Frequent Contributor
  • **
  • Posts: 410
  • Country: us
Re: Getting started with DSP for audio effects
« Reply #12 on: November 16, 2018, 03:29:33 pm »
This will help getting started:   (the dev board use for this is no longer in production but it is just a cortex M4)

https://community.nxp.com/docs/DOC-100149

https://circuitmaker.com/Projects/Details/Eli-Hughes/MonkeyJam

As diyaudio stated,  most of the work is house keeping.     Getting your samples in and out efficiently, etc.       Most actual code for effects use per-sample techniques.     i.e.   bring in a sample, do something with it and send it out.      There are a small number of "block" based algorithms (gather 256 samples, processing them and then queue for output) but for real time this is generally avoided as the latency stacks up through your signal chain.

The Analog devices Sigma DSP's will do most of what you want:

https://www.analog.com/en/design-center/processors-and-dsp/evaluation-and-development-software/ss_sigst_02.html

 https://www.analog.com/en/products/processors-dsp/dsp/sigmadsp-audio-processors.html

If you want a quick environment to try things without investing a lot of time,  SigmaStudio is a good fit.

Some open source Sigma studio Hardware:

http://www.freedsp.cc/




 

Offline diyaudio

  • Frequent Contributor
  • **
  • !
  • Posts: 683
  • Country: za
Re: Getting started with DSP for audio effects
« Reply #13 on: November 16, 2018, 04:07:11 pm »
This will help getting started:   (the dev board use for this is no longer in production but it is just a cortex M4)

https://community.nxp.com/docs/DOC-100149

https://circuitmaker.com/Projects/Details/Eli-Hughes/MonkeyJam

As diyaudio stated,  most of the work is house keeping.     Getting your samples in and out efficiently, etc.       Most actual code for effects use per-sample techniques.     i.e.   bring in a sample, do something with it and send it out.      There are a small number of "block" based algorithms (gather 256 samples, processing them and then queue for output) but for real time this is generally avoided as the latency stacks up through your signal chain.

The Analog devices Sigma DSP's will do most of what you want:

https://www.analog.com/en/design-center/processors-and-dsp/evaluation-and-development-software/ss_sigst_02.html

 https://www.analog.com/en/products/processors-dsp/dsp/sigmadsp-audio-processors.html

If you want a quick environment to try things without investing a lot of time,  SigmaStudio is a good fit.

Some open source Sigma studio Hardware:

http://www.freedsp.cc/

Sigma studio is about DSP blocks, no code. I think he/she wants hands on DSP using code without helper blocks.
 

Offline coppice

  • Super Contributor
  • ***
  • Posts: 9489
  • Country: gb
Re: Getting started with DSP for audio effects
« Reply #14 on: November 16, 2018, 04:56:31 pm »
Sigma studio is about DSP blocks, no code. I think he/she wants hands on DSP using code without helper blocks.
Sigma studio is a lot more restrictive than that. The Sigma devices only support a narrow range of DSP functions. They should suit the OP's filtering needs, but won't get very far with the distortion effects they showed interest in.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5408
  • Country: gb
Re: Getting started with DSP for audio effects
« Reply #15 on: November 16, 2018, 09:14:05 pm »
As well as C, I use Octave and particularly Excel when prototyping and designing algorithms. Don’t discount the value of a spreadsheet, but also note that they can get quite big when doing DSP.

I agree with a previous post, anything by Richard Lyons is recommended, he has a knack of minimising unnecessary mathematical gymnastics so loved by academics, concentrating instead on the more practical real world application side.

Just don’t expect to be spoon fed, it’s a topic that takes a while to get into. Like the best engineering tasks, get yourself a basic grounding in the building blocks, and work from there, building up Lego style.
 
The following users thanked this post: Jon86

Offline ehughes

  • Frequent Contributor
  • **
  • Posts: 410
  • Country: us
Re: Getting started with DSP for audio effects
« Reply #16 on: November 16, 2018, 10:30:50 pm »
Quote
Sigma studio is a lot more restrictive than that. The Sigma devices only support a narrow range of DSP functions. They should suit the OP's filtering needs, but won't get very far with the distortion effects they showed interest in.

I have gotten tube emulation with an arctan modeling function working well in sigma studio.   It is no better or worse than a C / text based environment.     (other than it will be about 10x quicker to get to something that works.).

Anything that is per sample based can be done easily in Sigma Studio.

The only limitation would be the delay pool for looper type effects.     Everything else (reverb, chorus, flange,  pitch shift) is pretty simple in Sigma studio.    A 1 second delay line covers 95% of delay based effects.



If you are trying to get your you feet wet, it is a good place to start.





« Last Edit: November 16, 2018, 10:33:49 pm by ehughes »
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: Getting started with DSP for audio effects
« Reply #17 on: November 21, 2018, 10:14:57 am »
You may find this book quite useful if you are going to use ARM: Digital Signal Processing and Applications Using the ARM Cortex-M4; 1st Edition; Donald Reay; 250 pages; 2014; ISBN 978-1118859049. The book presents example code for typical DSP algorithms written in the C so that the compiler will generate code for ARM Cortex M4 and the on-chip DSP features.
 
The following users thanked this post: Jon86


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf