News:

SMF for DIYStompboxes.com!

Main Menu

Getting started

Started by iampoor, December 06, 2015, 04:13:43 PM

Previous topic - Next topic

iampoor

Hi

I have played with the Spin Fv-1 and arduino quite abit, but I really want to start learning more about microcontrollers and dsp. I am interested in modulation effects and delays (like most of us  :icon_biggrin:). I have read most of the resources in the stickys too. Where is a good place to start programming Pic's for audio effects? I have been really inspired by some of the projects on this forum. Where did yall start? I am not a very good programmer, man a tutorial or two on this would be great, but now Im probably asking too much.  :icon_biggrin:

anotherjim

I hate to see a Q unanswered.
I think I'd only do any digital/programming when that seems a good or intriguing way to get what I want.
So that's where you begin, with motivation, the rest is just work.

Code size for most projects is going to be small, so it's practical I think to use assembler rather than C. That way you build confidence in your understanding of how it works, without also having to learn to write to please the C compiler as well.
I've had an advantage with using AVR chips as the AVR Studio program includes a simulator. Even though it fails to correctly simulate some of the chips peripherals, I can run through the code execution and check it before programming a chip.

I don't know how it is with other MCU's like the PIC, but they do have a better selection of on-board features in easy to use DIP packages.

Actually, I think these Harvard architecture MCU's are quite hard to learn because there's a lot of cases of "you can't get there from here". I learned coding a very long time ago with 68xx processors, where everything is in the same memory map and you can do the same things with anything with the same instructions - you can go anywhere from anywhere. I've been looking at the ST range of MCU's with interest, since they seem to be developed from the 68xx families.


Digital Larry

I've never programmed an 8-bit MCU for audio stuff.  I've used 8031s in the past for MIDI projects.  In spite of being Harvard arch. I got used to it.  As far as "getting started" I took a firmware class at university like 30 years ago now.  I don't think I did very well. But then I got a job where I was able to look at an existing product (a keyboard for a video editing system).  I wasn't under pressure and I just looked through the code and thought "oh so THAT's how you do it"!  You probably need to practice a bit until you start to think logically that way.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

iampoor

Quote from: anotherjim on December 10, 2015, 12:00:01 PM
I hate to see a Q unanswered.
I think I'd only do any digital/programming when that seems a good or intriguing way to get what I want.
So that's where you begin, with motivation, the rest is just work.

Code size for most projects is going to be small, so it's practical I think to use assembler rather than C. That way you build confidence in your understanding of how it works, without also having to learn to write to please the C compiler as well.
I've had an advantage with using AVR chips as the AVR Studio program includes a simulator. Even though it fails to correctly simulate some of the chips peripherals, I can run through the code execution and check it before programming a chip.

I don't know how it is with other MCU's like the PIC, but they do have a better selection of on-board features in easy to use DIP packages.

Actually, I think these Harvard architecture MCU's are quite hard to learn because there's a lot of cases of "you can't get there from here". I learned coding a very long time ago with 68xx processors, where everything is in the same memory map and you can do the same things with anything with the same instructions - you can go anywhere from anywhere. I've been looking at the ST range of MCU's with interest, since they seem to be developed from the 68xx families.

Hi Jim.
Thankfully I have the motivation! I have atleast 10 different ideas (ranging from simple to complex) that all need MCU's. Things like tap tempo, envelope generator etc. It doesnt really make sense to do them in analog. The problem is, I tend to get ahead of myself (Gotta start walking before you can enter a marathon.  :icon_mrgreen:) I have also really been inspired by cloudscapes work!

Interesting, I have always been under the impression that assembler is harder to learn?
I will look into AVR studio :)
There are so many good microcontrollers I just want to learn the basics so I can port it to ther micros. I just used PIC's as an example because they have alot of ultra cheap 8 bit MCU's that can replace alot of analog circuitry.

I thought most of ST's newer parts are ARM based now?
Quote from: Digital Larry on December 11, 2015, 12:30:30 AM
I've never programmed an 8-bit MCU for audio stuff.  I've used 8031s in the past for MIDI projects.  In spite of being Harvard arch. I got used to it.  As far as "getting started" I took a firmware class at university like 30 years ago now.  I don't think I did very well. But then I got a job where I was able to look at an existing product (a keyboard for a video editing system).  I wasn't under pressure and I just looked through the code and thought "oh so THAT's how you do it"!  You probably need to practice a bit until you start to think logically that way.

I would like to use smaller MCU's mostly for control logic...an 8 pin micro can replace alot of analog circuitry! Probably will use DSPics or ARM based parts for some audio stuff...

How long did it take for it to "click"? I havent had that moment yet in any of my programming attempts!

anotherjim

I guess assembler seems easy to me because my first coding was in machine code -  that's the most basic long hand method there could be. All you had was a card with the instruction codes printed on it and you entered the code in hex (if you were lucky) or in binary using toggle switches! You had to calculate branch/jump address offsets yourself - longhand if you didn't have a calculator. An Assembler makes coding stupid easy compared to that! But the hard part for me is have the confidence that the instructions you write will do what you hope/expect, so being able to simulate the code running and watch the register contents change is a real boon.
Of course, you can mix C and Assembler. C gives you access to standard routines for things like LCD display and save time re-inventing the wheel. I happen to really like assembler as it gives full control and (hopefully) deeper insight.

My current project needs a Trigger to MIDI converter. I'm sure there are plenty of ready to go solutions out there, but I've never actually written for MIDI before and I think it's high time I did! Because I'm doing it in assembler and not using any library code, it should be good experience if nothing else.


SISKO

Note: the next section is for someon with cero (or minimun) programming skills:
-----------------------------------------------------------------------------------------------------------------
Leaving aside the idea of getting into a course from some university or a deegree of some kind, what you can do is learn how to do a plugin. There are some tutorials on the web.

In this way, you can write your own code in C, try some of your ideas, etc. Theres a learning curve about how to make the plug in functional. But once you have that done, you can copy paste it and the you can start writing your effects.

Another way is to learn MATLAB. The difference in learning how to make a pluging or how to use MATLAB is very similar, being MATLAB a little longer to learn, but is a powerfull tool with endless possibilities and not only dedicated to dps but aplicable in many many many areas of eleectronics.

Other thing you can try, but i didnt, is try to learn thing like PureData, etc.

-------------------------------------------------------------------------------------------------------------------------------------------------

Now, what i think that you should do if you want to experiment with dsp is to read about dsp and try to implment it on your arduino and (why not) your fv-1. Those micros would be used in place of MATLAB or a Plugin stated before.

Things i recommend to read is:
www.dspguide.com <- plenty of dsp in general (not only related to audio, in fact, very little of audio)
Julius o smith pages, <- lots of information related to audio and dsp in general. A very good resource
DAFx <- This is what you want.
The audio programming book
Designing audio effect plugins in C++

--Is there any body out there??--

iampoor

Quote from: SISKO on December 11, 2015, 10:43:08 AM
Note: the next section is for someon with cero (or minimun) programming skills:
-----------------------------------------------------------------------------------------------------------------
Leaving aside the idea of getting into a course from some university or a deegree of some kind, what you can do is learn how to do a plugin. There are some tutorials on the web.

In this way, you can write your own code in C, try some of your ideas, etc. Theres a learning curve about how to make the plug in functional. But once you have that done, you can copy paste it and the you can start writing your effects.

Another way is to learn MATLAB. The difference in learning how to make a pluging or how to use MATLAB is very similar, being MATLAB a little longer to learn, but is a powerfull tool with endless possibilities and not only dedicated to dps but aplicable in many many many areas of eleectronics.

Other thing you can try, but i didnt, is try to learn thing like PureData, etc.

-------------------------------------------------------------------------------------------------------------------------------------------------

Now, what i think that you should do if you want to experiment with dsp is to read about dsp and try to implment it on your arduino and (why not) your fv-1. Those micros would be used in place of MATLAB or a Plugin stated before.

Things i recommend to read is:
www.dspguide.com <- plenty of dsp in general (not only related to audio, in fact, very little of audio)
Julius o smith pages, <- lots of information related to audio and dsp in general. A very good resource
DAFx <- This is what you want.
The audio programming book
Designing audio effect plugins in C++

This post has been great :D Thank you!
I fund some courses I am going to take on using microcontrollers, so that should be a good starting point! I have basically zero programming skills as of this point (Though I do understand the basics, I cannot apply them practically).

Is it possible to run Matlab programs on a microcontroller? I thought Matlab was generally used for PC's but could be totally wrong here...
I know one way or another alot of programming will be done in C so I should start learning that right away!

The Fv-1 actually is a dsp, just very limited. It cant be programmed in C which is why I havent put too much effort into learning assembler for it. Thats a good idea with the arduino, I could probably build a basic tremelo or chorus relatively easy, wonder if the arduino will be able to handle it in real time? We will see....

I have just started on Dafx. Great book! Do you know of any resources for audio effects on embedded systems (Like microcontrollers or dsp's?) I am worried that implementing them on those platforms will be harder than on the computer, but I might be overthinking this!

Thanks!

Quote from: anotherjim on December 11, 2015, 09:11:29 AM
I guess assembler seems easy to me because my first coding was in machine code -  that's the most basic long hand method there could be. All you had was a card with the instruction codes printed on it and you entered the code in hex (if you were lucky) or in binary using toggle switches! You had to calculate branch/jump address offsets yourself - longhand if you didn't have a calculator. An Assembler makes coding stupid easy compared to that! But the hard part for me is have the confidence that the instructions you write will do what you hope/expect, so being able to simulate the code running and watch the register contents change is a real boon.
Of course, you can mix C and Assembler. C gives you access to standard routines for things like LCD display and save time re-inventing the wheel. I happen to really like assembler as it gives full control and (hopefully) deeper insight.

My current project needs a Trigger to MIDI converter. I'm sure there are plenty of ready to go solutions out there, but I've never actually written for MIDI before and I think it's high time I did! Because I'm doing it in assembler and not using any library code, it should be good experience if nothing else.



Ah wow! Sounds like programming old mainframes, or an altair 8800! But yes, I can certainly see how assembler would make that a much easier task! I feel like nowadays my aversion to learning assembler comes down to how flippin complex many microcontrollers are, and also how much shorter many production cycle lifespans seem to be. All these new ARM Based parts seems to come and go very quickly, and they all have crazy feature sets. Didnt the Z80 and 6502 last for what 20 years!?!? But at the same time,with some of the smaller pics that have been around forever I could see how optimizing routines in assembler could save code space, which could be a large deal with 1k of ROM. Writing registers and some arithmetic functions will also be noticeably faster then C Im assuming?

Sounds like a cool project! Are you doing A/D convertin on your inputs then writing the MIDI values out via a UART?

Digital Larry

QuoteIs it possible to run Matlab programs on a microcontroller? I thought Matlab was generally used for PC's but could be totally wrong here...
I know one way or another alot of programming will be done in C so I should start learning that right away!

The Fv-1 actually is a dsp, just very limited. It cant be programmed in C which is why I havent put too much effort into learning assembler for it. Thats a good idea with the arduino, I could probably build a basic tremelo or chorus relatively easy, wonder if the arduino will be able to handle it in real time? We will see....

You get into some tradeoffs with smaller CPUs/microcontrollers, although the horsepower of affordable chips gets better all the time. I think of it this way.  On a typical PC, you have cycles to burn, so the code can be fairly inefficient and you'll never notice it.  You also benefit from a large market resulting in people having (by now, it was a different world in 1988) developed lots of tools to make the up front work easier.  If you want to use a microcontroller, at some point you have to learn something about its architecture (how does it handle interrupts, how do you do I/O, how many registers does it have, what are the memory limitations, how do you set up a timer, etc.)

Then you probably want to separate "what is a good learning platform" from "what's the best way to get to a specific result"?  I've spent way more time than I ever imagined with the FV-1 but it's unique in a certain regard.  It's so specialized that you don't learn much about programming other chips from it.  If you concentrate hard enough, you can learn something about DSP from studying the examples, but the documentation stays away from standard Z-transform theory, which made it pretty hard for me to absorb. 

As far as DSP goes, I separate it into two categories.
1) Things which make intuitive sense without a lot of math, such as delays and perhaps modulation effects like chorus.
2) Things which don't make much sense without a lot of math, including filters and things like the Hilbert-transform frequency offset.

So, you may wish to take two different approaches. One, use an Arduino so you can develop some skills using if-then-else-add-and-or-not logic, because this has universal applicability.  You may just run into a wall with the capabilities of the hardware you're dealing with. The other approach is to use a relatively high powered PC with something like Matlab where you are more concerned about the theoretical "what I want to achieve" rather than the gory details of how that actually takes place.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

anotherjim

Let me de-mystify the basic ATMega based Arduino.
It is the MCU with a 5volt regulator, 16Mhz clock crystal, a reset button and its USART coupled to a serial/usb converter. The only thing that makes it an Arduino is the bootloader. There is nothing to stop anyone with a programmer from disabling the bootloader and ISP programming it from AVR Studio or other development tools with code written in C or Assembler. In other words, its really just an AVR application board.

16Mhz is as fast as most would want anyway, and it's trivial to use the USART to drive a standard MIDI interface or even re-program the USB chip (on versions with an AVR MCU for this rather than a hardwired converter chip), and behave as a class compliant USB midi interface.

The Arduino language is C, but with many functions presented as simple commands ready built to suit the kinds of controller jobs the creators expect users to need most. As the language can talk directly to the ports and registers, you can still take full control of the MCU and do everything any other programming environment can. To handle audio, you will probably want to set the ADC converter to run faster (it will clock at 1Mhz) and set the PWM (analog write) to a faster rate.