Author Topic: Getting started with DSP  (Read 6305 times)

Dan Moos

Getting started with DSP
« on: August 13, 2016, 06:02:35 PM »
I would like to venture into real-time  dsp as a hobbyist. I am pretty experienced in the analog electronics area, and have also been dabbling with digital stuff (arduino and AVR stuff) as of late. In a past life I was fairly decent with C/C++ coding.

I would like to dip my feet into DSP for guitar. What I'm looking for is a good chip family to use. The only one I know specifically of I'd AD's SHARC chips. They definitely sound good, but a development board is over $500, which is too much for me until I know if this is something I really want to get into.

Here is what I hope to find:

A chip with a reasonably priced Dev Board.

Decent C/C++ support with free/inexpensive toolchain.

Doesn't have to be insanely powerful, but at least usefully capable. I'm mostly interested in doing delays and reverbs. My goal is to someday do Strymon type stuff on a hobbyist level. The chip has to at least send me in that direction.

Hopefully good community support.

I realize I can't likely have it all, but I really don't even know what's out there to even start the conversation.

Thanks!

Sent from my E6715 using Tapatalk


Digital Larry

Re: Getting started with DSP
« Reply #1 on: August 13, 2016, 11:37:54 PM »
Check out http://bela.io/ - for a little over $100.  I don't currently know what the limitations are.  It does have a built in IDE for writing C/C++ code as well as support for Pure Data.  I got one and have played around with it a bit.

I got a BlackFin Demo/Eval board for just $75 but haven't started doing anything with that either.  See: http://www.digikey.com/product-detail/en/ADZS-BF706-EZMINI/ADZS-BF706-EZMINI-ND/5408943?WT.mc_id=IQ_7595_G_pla5408943&wt.srch=1&wt.medium=cpc&WT.srch=1&gclid=CjwKEAjwiru9BRDwyKmR08L3iS0SJABN8T4vfSgo220Asj6MQH3BNJTBNhbXRxJsRYECs4LxO20qWxoCEj3w_wcB

Also there's my old favorite the Spin FV-1, but if you're set on C/C++ then forget about that.  Dev board is about $100, and there are modules you can purchase for about $30.  You can learn the Spin ASM or you can use the graphical tool I wrote (which doesn't cover all bases, but quite a few) to generate DSP code by hooking together functional blocks.  See:  http://holycityaudio.com/spincad-designer-2/  I may be overstating the case as you still need to understand the chip to be able to use the tool effectively, but this is about as close to low cost instant gratification as you're going to get.
« Last Edit: August 14, 2016, 10:51:47 AM by Digital Larry »
Digital Larry
DSP tinkerer and former transistor twister

Transmogrifox

Re: Getting started with DSP
« Reply #2 on: August 23, 2016, 01:20:56 PM »
Bela looks really cool.  I want one, but once the kickstarter ended it became vaporware (although they do seem to indicate it will be available to general public soon:  http://bela.io/)

For the short-term the Raspberry Pi is not a bad platform.  I just got a chorus/flange/delay effect (currently text-file configured) working on a Pi3 with a Behringer UCA-202.  With the OS stripped down to the minimum I'm getting 1.3 ms latency + maybe 1ms latency added from the AD/DA conversions on the USB audio interface for a total 2.5ms latency.

That is equivalent to standing 2 feet further from your amp, so it's a more-than-adequate development platform.  But if you're a latency snob, or mixing the output of this with dry signal then Bela can get you down to about 2 or 3 samples latency if you simply use Bela SAR ADC & DAC (the CODEC still adds ~1ms because of the digital anti-aliasing and reconstruction filters).

The advantage of having a Linux OS underneath (as with Bela) is that all the work is done in the realm of drivers and ready-to-play access to USB-midi devices so your control surface isn't required to be a DIY project if you don't want to go that route.

At the same time, there are libraries in the PI for talking to I2C devices, so you could put an 8-channel ADC on a pair of I/O pins to scan pots or expression pedals similar to what the Bela platform does.  It's just that the Bela project has already done this boring work.

Whether you go with the Pi or Bela (or something else) I suggest writing your code in a manner that is not platform-specific so you can move it around.  You can also develop it on a PC and experiment even before you have decided on a specific DSP development platform.  If you are leaning toward a DSP chip like a SHARC or even trying things on a microcontroller then you are safest sticking to plain no-frills C so you can easily build it into its final hardware target platform.  By "no-frills" I mean don't use operating-specific functions in the DSP core functions (for example don't insert code for reading/writing an audio interface into the main DSP loop). 

For example, the way my code is written it is easy to do either of these development/testing methods:
#1  I have in my files a rudimentary tool to read and write a wav file.  I call my "process" function from my wav reading function and process the files.  Output from processing is stored back to a wav file so I can listen to it.

#2 I use Linux and Jack Audio Connection Kit.  I have a basic Jack client from which I can call the same "process" function and start it as a real-time effect.  This model applies directly to the raspberry pi platform after I have evaluated it on the PC.  Just copy source code over to the Pi using SCP on the Ethernet cable, compile and run.  Gives me fun and joy until such time Bela becomes available for purchase.

My particular "first" effect on the Pi is a further evolution of this:
http://cackleberrypines.net/transmogrifox/src/cgi_chorus/csource/
Which in the application you see is run as a cgi program allowing you to experiment with envelope control on parameters:
http://cackleberrypines.net/transmogrifox/src/cgi_chorus/chorus.html
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.

Digital Larry

Re: Getting started with DSP
« Reply #3 on: August 25, 2016, 01:41:27 PM »
Are you using a specific framework to develop your DSP code for the Pi?  I just started using the Synth Toolkit (stk) on desktop Ubuntu for developing/prototyping effects in C++.

https://ccrma.stanford.edu/software/stk/

I also bought Julius Smith's incredible reference from Amazon, but it's available online here https://ccrma.stanford.edu/~jos/pasp/

Some of the examples use Stk, which is a nice bonus.  I also worked with one of the main authors of Stk about 25 years ago, so there's a small personal reason for wanting to try this set of classes.  However, as you hinted, this is C++ and is perhaps not optimized for a small footprint CPU.  We shall see.
Digital Larry
DSP tinkerer and former transistor twister

Transmogrifox

Re: Getting started with DSP
« Reply #4 on: August 25, 2016, 11:57:21 PM »
I'm not using anything really very advanced for a framework.  Here's my first-pass experiment:
http://cackleberrypines.net/transmogrifox/src/rpi/delay_line_fx/

For a number of years I contributed a fair amount of code to the rakarrack project (the main developer has disappeared without a trace and I have not had time to keep supporting it).
https://sourceforge.net/projects/rakarrack/

A lot of that code came from ZynAddSubFX synth, but I kinda learned DSP using that set of code as my "framework".  I haven't made any effort toward running Rakarrack on Rpi but based on reported success with Guitarix it likely runs fine.

I'm keeping things pretty low-key and just rob from either code I have written in the past or code my own functions that have been done over and over again (and possibly better), but just for the educational aspect.

Probably my most favorite effect which I will most certainly port to the Pi or Bela is my Infinity filter.  It's something like 8 band state variable filter (parallel) routed in up to 12 - stage phaser and stereo amplitude modulation (panning).  Phasers and SFV's all modulated linearly to create the continuous rising or falling effect.
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.

Digital Larry

Re: Getting started with DSP
« Reply #5 on: August 26, 2016, 12:40:01 AM »
Cool man!  Being involved in DSP is a little strange for me, because it was my favorite subject at university, but I managed to spend the next 30 years of my career almost completely not working with it.  And with the FV-1 I stumbled back in a few years ago.  So my theoretical grounding is pretty good, but I am going slower than molasses actually writing some of my own code.  I haven't written any C++ in a really long time, so that takes a bit of getting used to.

And, if I didn't have a real job and a family I could probably go till 2 AM every night like I used to. (cough)...(wheeze)....

 :icon_lol:
Digital Larry
DSP tinkerer and former transistor twister

Transmogrifox

Re: Getting started with DSP
« Reply #6 on: August 26, 2016, 02:05:10 PM »
And, if I didn't have a real job and a family I could probably go till 2 AM every night like I used to. (cough)...(wheeze)....

 :icon_lol:
Same fate put a lot of my coding and stompbox building on hold -- or at least at a much slower pace. 

I love analog circuits but some things with DSP are out of reach of the analog world.  For some things that can be implemented in analog then the DSP world offers a nice simulation environment for getting the theory worked out and "ear-tested". 

Anyway, I have referenced JOS and generally CCRMA white papers over the years for learning new things.  Probably one of the best resources out there for music-specific DSP theory and practical example out there.

The CCRMA STK is a good platform for both brushing up on your C++ and for getting quite a lot of goodies for less time investment.  I learned a lot just by looking at code and then doing the research to understand methods and syntax that weren't familiar to me.  I also found code that used a lot of fancy C++isms that I found unnecessary and honestly made the underlying algorithm difficult to understand.  Probably computer science gurus learning to do DSP and writing the code in the same way they would do GUI or business database programming where some of these "isms" are useful for multi-threaded asynchronous processing.

For synchronous sequential processing it makes more sense to use a sequential flow in the organization of the source files and minimize the use of external libraries so it's easy to port the application to any type of platform.

Trying to keep on-topic here, I would suggest to the OP that a good development platform is a plain PC with a sound card.  As long as you keep your code portable and stick with standard C (or C++) libraries it should be easy to port it to DSP platform X, Y or Z when you have decided on something.
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.

ElectricDruid

Re: Getting started with DSP
« Reply #7 on: September 01, 2016, 01:24:47 PM »
You could have a look at the Axoloti platform too:

http://www.axoloti.com/product/axoloti-core/

This is a pretty powerful board for the money, and would certainly do guitar FX. They provide a lot of modular software to plug-n-play, so you could start by playing with that, and then write your own modules for it, without having to delve too deeply initially.

Full disclosure: I have one on my shelf since I supported it on kickstarter or wherever because it seemed like a good project that deserved some support, but I've never actually had time to sit down and play with it and it is still languishing there in its box.

Tom

potul

Re: Getting started with DSP
« Reply #8 on: September 02, 2016, 09:23:13 AM »
Wow... this axoloti looks great!
That looks like what I'm looking for...
How does it compare to FV1 power-wise?

Digital Larry

Re: Getting started with DSP
« Reply #9 on: September 02, 2016, 11:15:36 AM »
Spec sheet on the CPU for the ARM chips says "225 DMIPS".  FV-1 claims "6 MIPS" or flops or whatever.  This ARM chip probably wipes the floor with the FV-1.  The only thing to remember is that the FV-1 architecture is highly optimized for its purpose, so you get a fair number of things "for free", e.g. the SIN/RAMP LFOs, pitch shifting instructions, 2 instruction 1 pole filters and all passes, interpolating delay lines for chorus/flange which I don't believe are accounted for in the FV-1 stated MIPS.  So to get those things, which you are probably going to want for audio effects, you will have to add some effort to program those things and it will chew a bit of the resources.  But it looks like there's quite a bit of wiggle room there. 

I love the FV-1 and I have pushed it to its limits many times.  It's only because I want to go beyond those limits that I'm now looking into a more general purpose approach.

If by "power" you meant power-supply power, sorry!  I don't know.  But practically speaking even an FV-1 is going to want an AC adapter.
« Last Edit: September 02, 2016, 11:47:03 AM by Digital Larry »
Digital Larry
DSP tinkerer and former transistor twister

ElectricDruid

Re: Getting started with DSP
« Reply #10 on: September 03, 2016, 12:20:23 PM »
Yep, as Larry says, the Axoloti will wipe the floor with the FV-1. The Axoloti is based on a 32-bit chip running way faster, so it's a whole different league.

But as he says - the FV-1 gives you some stuff already done (quite a bit, really), which is certainly handy and allows you to get more out of the FV-1 than might first appear possible.

But no, there's no competition, power-wise.

Tom