DSP & general advice for guitar effects unit (with a twist) - Page 1
Forum section: electronics / projects

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 19, 2016, 04:48:55 pm
content: Hi guys. My first post!I am looking at building a multi-guitar preamp and effects unit. There are a lot of paths to go down, and even browsing the forums I'm left with many options. I was hoping I could get a bit of direction, given I know my constraints.What I'm trying to do:Sniff the frequencies of my guitars' strings, play some silly buggers with the audio, output line level or another guitar pedal.The key thing that makes my problem unique:This one unit processes multiple guitars. I require at least 5-6 inputs (yep you read it). And as many outputs.Imagine a guitar effects pedal which every member plugs into. I have some evil mixing techniques I am automating.INPUTS:Primarily what I am doing is figuring out the fundamental frequency of each guitar. This is actually a very constrained range - 80hz to around 1200hz.This may potentially mean I could sniff frequencies with cheap ADCs or DSPs or even arduino maybe?OUTPUT:My output will actually just be a mix of the guitar inputs. For example: 20% this guitar, 50% that guitar, etc. The talky end of my project will have guitar effects pedals listening to it. So I'm outputting AC instrument level I think.I need to sniff directly off the guitar, so if I used an arduino I would have to do funky dance moves to bring the signal to 3.3v non-signed. Guitars are usually AC and microvolts. I'm OK with that as long as the Arduino was capable, but I am unsure. Theres cheap ADC chips out there surely.The capabilities of the DSP I choose really affect the rest of this project. So I can't continue without some help.In summary what I need:* 5-6 inputs.* FFT/DCT to figure the fundamental frequency on each channel (very limited on electric guitar)* Selectively output to about 5-6 channels at levels OK for guitar effects units.* I appreciate generating high-fidelity audio may be difficult and may just want to mix my inputs onto a bus anlogue-styles.Things that terrify me:* Impedance* Capabilities of DSP chips. Can some sniff AC? Some have on-board FFT which sounds neat. I'm OK with 6 cheap ADCs & arduino for example.* Latency.Food for thought:Because my output is just a variable mix of my inputs, I thought about not outputting sound from the DSP. I thought about discrete components with potentiometers and my box can control a mixer.I'm not using the transformed signal to regenerate an audio wave. Im only using this information to adjust the gain of the output channels.I would appreciate anyones thoughts on this. I'm a big fan of EEVBlog and stuff. So yeah winner winner chicken dinner, and thanks a lot in advance. I appreciate any spare thoughts anyone has.

author: coppice
author_rank: Super Contributor
timestamp: September 20, 2016, 09:10:09 pm
content: Quote from: pepelevamp on September 19, 2016, 04:48:55 pmIf you are doing this to learn, then go ahead and see what you get. If you are eager to have robust fundamental analysis working quickly you might like to review your idea of using FFT/DCT analysis.

author: alexanderbrevig
author_rank: Frequent Contributor
timestamp: September 20, 2016, 11:17:20 pm
content: I'm curious... what are you using the fundamentals for? Indeed; what is this project for?

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 21, 2016, 02:14:12 am
content: Hi guys thanks for replying.Okay yup - I am trying to get the fundamental frequency because I want to know what note is being played, but I need it as a frequency.I am mixing instruments based on musical relationships. The relationships are best dealt with in terms of frequency this time believe it or not.At present the only way I know to do this is use a FFT/DCT. I have seen other methods but I'm not entirely sure. Such as counting the times the signal crosses the 0 volts boundary.I'm not doing it for the learning experience this time. I have a mission to accomplish!but I am fully invested in learning everything and I'm doing it in software (going good) as well as this hardware implementation.I know that guitars play complex chords, but that wont be done while using this device. Single notes only per guitar. FFT can capture this pretty well.So what do you guys think ? The fundamental frequency of the instruments will be 80-1200hz. Would this mean I can perform a crappy enough FFT for an arduino to process it x6?

author: BurningTantalum
author_rank: Frequent Contributor
timestamp: September 21, 2016, 03:21:18 am
content: Guitar outputs are not microvolts.

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 21, 2016, 04:04:41 am
content: I was under the impression they were. Millivolts perhaps? I know that they can vary widely. I'm not entirely sure on the best way to measure the output of a guitar. my meter doesnt go down that low on AC mode. I have been relying on literature online. i could possibly grab out a few diodes to rectify it but dont they have a voltage drop themselves? I'll give it a shot. I haven't got a scope you see. Just a multimeter.There's plenty of circuits online to amplify guitars up to line level, but I'm not certain about what DSP/chip is appropriate for this job. Thats my biggest unknown at this point - and it kinda dictates the way the rest of the project falls together.

author: Greg Robinson
author_rank: Regular Contributor
timestamp: September 21, 2016, 04:09:35 am
content: Arduino? Nope, not with the built-in 10bit ADC's anyway. If you're wanting to do ADC-DAC (you could also just be doing ADC for sampling and output a control signal via PWM), then latency would be stupid long with an Arduino too, especially if you use a library for an external ADC/DAC, so that completely writes it off.As BurningTantalum mentions, guitar signals are NOT microvolts. Typical single coils will output a very short transient attack around 1v peak, with the decay being more like 100mV peak. Humbuckers or active pickups will put out 2V peak transients or higher.Also, 80Hz-1200Hz discounts alternate tunings, down-tunings, extended range instruments, 7/8/9/10/12 string guitars, etc. etc. Might want to increase your bandwidth.What you should look into is the Spin Semi FV-1. It's a DSP chip designed specifically for guitar effects. There's also a dev board available (around $100USD from memory).It sounds like you're biting off WAY more than you can chew given your level of experience. I'd recommend you start with either DSP on a computer, or some simple analogue effects before you jump into this project. You're going to need to mix both of those skills together in order to achieve your goals for this project.

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 21, 2016, 08:23:15 am
content: thanks greg thats some great information.youre right im biting off quit a bit. the job needs to be done though, so im jumping in the deep end. its a hardware implementation of what im doing in software. im used to torturing myself with this kinda thing.thanks for showing me that DSP i will have a look. this is putting me on the right path. man i had no idea pickups could generate that much voltage though. that is staggering.the guitars are all identical and passive humbuckers. which makes my life easier.

author: alexanderbrevig
author_rank: Frequent Contributor
timestamp: September 21, 2016, 06:14:42 pm
content: Sounds like a handy device when tutoring (and performing) with young aspiring guitarists. I've only had a similar idea once and that was when I agreed to serve as a guitar tutor for a cultural school (where 50% actually want to learn, and the others are there because parents wants a break :p). It's either that or some art installation?Still am curious why you want this!How will you control which frequencies are considered musical (or rather, which notes?)? Minor/Major and then setting the root note?

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 21, 2016, 06:40:34 pm
content: Thanks very much alexanderbrevig.The actual mixing algorithms and music side of it (the whole point of it) is something I'm gonna keep under my hat for now. I've just finished watching Dave's video on opamps and I'm a little concerned about the noise floor. The most ideal thing ever for me would be an arduino that can identify the root notes without corrupting the data stream.re greg, FV-1 DSP:Thanks for finding that for me and that info. You're correct about the guitar frequency ranges. I just gave like a rough approximation so we all knew what kinda frequencies I'm looking at.The DSP looks like it has stereo inputs and looks quite appropriate. It looks just like the kind of thing one would make for guitar effects pedals.My issue is that its not multichannel, so I would have to link 3 of them together. And I can't quite see any way to talk to it digitally in realtime from another controller (i2c etc). I am concerned that there might be simpler alternatives. For example is there a simpler or cheaper DSP chip that is older, lower spec, just mono?I am more than happy to be rolling at 16-bit or 11khz kinda thing.Perhaps I could ask a better question - what would you recommend I search for, or where is a good place to explore, so I can evaluate a bunch of options? Cos it wouldn't be fair to ask you guys to go window shopping for me while I yay/nay everything.

author: Greg Robinson
author_rank: Regular Contributor
timestamp: September 21, 2016, 07:02:52 pm
content: Check outDigikeyDSP section. You'll need to whittle down with the parametric search, but that should get you started.

author: hamster_nz
author_rank: Super Contributor
timestamp: September 21, 2016, 07:10:50 pm
content: One thing you may have trouble working with is latency. 10ms doesn't give you much data to separate 100Hz from 105Hz when other frequencies are present,.... not so much of a problem at higher frequencies though.

author: alexanderbrevig
author_rank: Frequent Contributor
timestamp: September 21, 2016, 10:22:26 pm
content: If I were to make this I would keep the digital out of the analog path. Just have a digitally controlled pot for attenuation.Now, take a buffered signal through an ADC (I would try withattiny85and it's 10 bit ADC) and sample at say 8Khz which should be well above double the max frequency (nyquist) you're trying to find. Now, you can have one central device, lets say an atmega328 that talks to those other six attiny chips and ask them for the fundamental freq.After you know that, do your under-the-hat secret sauce and attenuate each digital pot so the sum is what you want it to beNotice, all these chips can be programmed with Arduino so it probably lowers the immediate 'getting up and running' hazzle.Thoughts?

author: magetoo
author_rank: Frequent Contributor
timestamp: September 22, 2016, 01:33:33 pm
content: There might be some useful information if you look through the archives of the "music-dsp" mailing list, I remember this sort of thing being talked about now and then and the consensus seemed to be that it's not easy to do well, especially with low latency.If I were doing this, I'd look into copying a sustain circuit, there has to be hundreds of DIY schematics around, low pass filter and boost the output, maybe even square it, and count zero crossings. Do more pre-processing in analog to simplify any DSP work.It won't be perfect, but it might get a prototype off the ground so you can get a feel for things.

author: Marco
author_rank: Super Contributor
timestamp: September 22, 2016, 02:17:30 pm
content: Unless you want to start selling systems a PC is the way to go. You're not going to solve this cheaper or easier with DSPs.My suggestion would be a PC with Xenomai (real time Linux) and a Lynx 16 audio I/O card, less than a k$/k€ worth of hardware.

author: _Wim_
author_rank: Super Contributor
timestamp: September 23, 2016, 08:45:20 pm
content: You could you an of these or similar:http://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/EVAL-ADAU1452.html#eb-overviewOnly 4 inputs, but a quite powerful DSP and a user friendly audio specific programming environment. I am not sure if it will do completely what you have in mind, but using a board like this will get you started quickly.

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 24, 2016, 06:54:55 am
content: Quote from: magetoo on September 22, 2016, 01:33:33 pmThanks very much for that info mate. I have been investigating zero-crossing algorithms because they are fast, unfortunately its not possible to sniff low-frequencies without a large delay with that technique. For example a 100hz signal needs 10ms to complete. And you need two of them for nyquist, so 20ms.About the sustain - guitar notes when struck have the fundamental + transients, and the transients fade away to leave the fundamental. Does a sustain pedal/effect keep the transients rolling or just the fundamental? If it keeps the transients/harmonics going too, then I might be able to take advantage of the faster zero-crossings of the harmonics.Afterall, the same note higher up merely has higher-up harmonics too. Hrmm

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 24, 2016, 07:04:17 am
content: Quote from: alexanderbrevig on September 21, 2016, 10:22:26 pmYeah man you're thinking along the same lines I am. All output that I make is just going to be a mix of the original inputs. Do you know the best way to construct the equivalent of a digital pot? I know we can amplify with a transistor - is there a way to say pull a signal down to nothing using a transistor? Perhaps by sending in the input signal into the high voltage side of the transistor, and controlling it with a DC voltage which I can bring down to 0v when I need to quiet the signal?My issue is that the arduinos are powerful enough to sample data at 4khz (my target) but nowhere near powerful enough to do the FFT required. I need to use a fourier transform because I need to calculate low frequencies which have not yet completed their full cycle. eg 100hz takes 10ms to fully complete.The raspi is capable of processing an FFT in realtime, but it has trouble bit-sniff GPIO due to the OS interrupting the CPU. While I was making my toast I came up with the same thing you did - using arduinos which can simply send their sniffed voltages (er samples) to a raspi for FFT work.The FFT can even output crappy audio. Electric guitars only output up to ~10khz anyway believe it or not. Mine stops at 5khz but its a very masculine pickup with a low range.

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 24, 2016, 07:06:28 am
content: Quote from: Marco on September 22, 2016, 02:17:30 pmYeah I'm doing it live with a PC and audio interface right now. Cant take them on stage though. I might look at Xenomai as a replacement for that rasperri PI linux. I really need the hard real time processing. Thanks mate thats really helpful.

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 24, 2016, 07:07:52 am
content: Quote from: _Wim_ on September 23, 2016, 08:45:20 pmIts quite hilarious I actually had this open in another tab in my web browser. You're right I'm looking at this. Its a dream for this project but I'm terrified of the cost. I'm currently investigating if there's a way I can get the equivalent of this at a lower cost. Or if I can somehow put together something cheaper.I nearly spilled my coffee when I saw that online.

author: _Wim_
author_rank: Super Contributor
timestamp: September 24, 2016, 09:35:19 am
content: Quote from: pepelevamp on September 24, 2016, 07:07:52 amI my opinion 200$ is quite cheap for a platform like this. Building a one-off cheaper will be quite hard. Even doing a small production run below 200$ will not be easy...

author: _Wim_
author_rank: Super Contributor
timestamp: September 24, 2016, 09:42:36 am
content: If there is anything specifically you want me to try (I have a board like this lying around somewhere), just let me know. I used this board one for a filtering project at work, and found it quite easy to get going.It uses Sigma Studio (http://www.analog.com/en/design-center/processors-and-dsp/evaluation-and-development-software/ss_sigst_02.html#dsp-overview) for the programming. This can be downloaded freely, so you can see if it has all the functions you need for your program. If you made a program, I am willing to run it on my board and do a few tests also if desired. Unfortunately we live on opposite sides of the world, otherwise you could borrow mine for some initial testing...Edit: some typos

author: b_force
author_rank: Super Contributor
timestamp: September 24, 2016, 12:58:24 pm
content: Instead of the fundamental frequency, you can also just take the second or third harmonic.It depends on the guitar, but especially with bass guitar, there is only a ghost frequency for the fundamental.This means we hear it (well the brain does), but physically it's not there.On top of that, the amplitude of the first few harmonics can be very low.There are many DSP units on the market these days.The biggest problem here is getting the latency low enough.I know a company who is selling a chip who (I think) would be able to do this in tenths of ns, but I need to ask them.

author: Marco
author_rank: Super Contributor
timestamp: September 24, 2016, 01:37:07 pm
content: I suspect there are efficient algorithms for sliding window auto-correlation (which is often the core of fundamental frequency estimation).

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 24, 2016, 01:43:14 pm
content: Quote from: b_force on September 24, 2016, 12:58:24 pmYeah man that is really pivotal. You're right on the money. I'm just fortunate that the harmonics are all the same note, just up in octaves. Given that, I had thought about going back to intverval/zero-crossing techniques but I would need some high harmonics to stay live for quite some times.The fancy pants analogue-devices DSP mentioned by Wim is actually much cheaper - only $30NZ without the evaluation board.That one chip would do everything I need. I'm OK with settling for 4 channels at this point if I can have it all on one chip.My question would be - how to interface with it. I am running on the assumption that I need a USB to I2C interface chip, which they sell. I can power it with 3.3v easy enough.Also it comes as a big square pin grid array I think ya call it.I don't have much money. I have one of those metal throughole boards that you solder on. I was literally going to solder onto the pins I need & not the rest.This is what I am looking at buying:http://nz.mouser.com/ProductDetail/Analog-Devices/ADAU1452WBCPZ/?qs=sGAEpiMZZMtqO%252bWUGLBzeHI87oni6Df5mckuwn7SiAc%3dAnd here is the chip (I think) I can use to interface with it:http://nz.mouser.com/Search/ProductDetail.aspx?qs=D1%2fPMqvA103RC6OU6bKtoA%3d%3dThis will be the first time I've bought a big boys programmable chip. I've used Arduino enough and I'm an experienced coder - but I haven't say used the ATMega chip without its breakout board before.What are the big noob mistakes I'm making? Because I know I'll be doing something bung. In exchange for your help I offer photos of my cat.

author: Marco
author_rank: Super Contributor
timestamp: September 24, 2016, 01:47:39 pm
content: It's a DSP, but it's not a freely programmable DSP.You'll very quickly run into a wall with how much you can do with it.

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 24, 2016, 01:54:12 pm
content: Quote from: Marco on September 24, 2016, 01:37:07 pmYeah I have a browser full of it at the moment. They kinda all work on the idea of 'how similar am I to myself when shifted X samples left/right?' My gist of it is that if the signal is very similar to itself 1 second ago, its a 1hz signal. Etc.At least the harmonics of a guitar are multiples of each other. I'll be doing some experiments tomorrow with low-brow zero-crossing stuff (thanks for reminding me about the sliding window). I just hope that the arduino can handle 3khz sampling on multiple analogue pins.I plan on doing a high-cut filter by using:lowfreq(t) = ( y(t-1)+y(t) ) / 2 ; //half frequency by blurring with neighboursmooth(t) = y(t) - lowfreq(t); // only high frequency remains by subtracting low frequency component.Hopefully this will mean that all my zero-crossing stuff will be high-frequency only. I also realized that I don't need to DC bias the signal - the Arduino merely treating negative volts as 0 will actually be okay. Because if I'm counting zero crossings, I can just count 0.001 crossings and have practically the same result. Will even be above the noise floor.

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 24, 2016, 01:56:10 pm
content: Quote from: Marco on September 24, 2016, 01:47:39 pmI was under the impression it was fully programmable. I'll have another look at this IDE they offer.

author: _Wim_
author_rank: Super Contributor
timestamp: September 24, 2016, 04:24:45 pm
content: Quote from: pepelevamp on September 24, 2016, 01:56:10 pmAs far as I know, you need to use the provided building blocks. I do not remember there is a block in which you can freely program. They do have a FIR building block, which for filtering means you can do practically eveything, if you are able to generate the correct impulse. Of course using FIR is not ideal for low latency...

author: Marco
author_rank: Super Contributor
timestamp: September 24, 2016, 04:58:15 pm
content: Quote from: pepelevamp on September 24, 2016, 01:54:12 pmThat is the essence of auto-correlation, my point is that if you do autocorrelation say for the last 1024 samples there is probably some efficient incremental algorithm for if you take 992 of the old samples and 32 new ones (ie. a sliding window).

author: hamster_nz
author_rank: Super Contributor
timestamp: September 25, 2016, 10:42:31 pm
content: Quote from: pepelevamp on September 24, 2016, 01:54:12 pmAveraging two samples gives a low pass filter, with a cutoff of 1/2 the sample rate. If you have correctly filtered the input to not include any frequencies over half the sample rate, as they will alias back down and confuse things.Also the way you are processing will cause phase shift as the subtraction isn't symmetrical.Maybe trylowfreq(t-1) = ( y(t-2)+y(t-1)+y(t) ) / 3highfreq(t-1) = y(t-1)- lowfreq(t-1);which is a (shabby) high pass at 1/3rd the sample rate. At a rough approximation that should leave all frequencies between 0.33 and 0.66 of the sample rate relatively untouched (and those greater than 0.5 shouldn't be there in the first place).Also, be weary that some filters look to have no gain, but because of ripple and phase delays you can end up with positive gain under some unlikely inputs - so allow yourself a little headroom.

author: pepelevamp
author_rank: Regular Contributor
timestamp: September 26, 2016, 07:54:17 am
content: Quote from: hamster_nz on September 25, 2016, 10:42:31 pmThanks man that is very helpful. I hadn't realized that it was asymmetrical. This directly affects my primary calculations, so it was a great thing to point out. Big thanks. Aspromised, a picture of my cat: