anwe79
Posts: 26
Joined: Sat Oct 08, 2011 10:30 pm

Re: Guitar amp modelling

Sat Oct 08, 2011 11:44 pm

I was thinking it would be cool to use a Raspberry Pi to run guitar amp modelling software (guitarix for instance). With some added hardware (Hi-z input preamp to start) you could have an "amp" that fits on your guitar strap :). Plug straight into the PA, and you're ready to go.

The UI would pose some problems, but i suppose one way around them would be to make presets while connected to a proper screen, and then use some very limited input/display to choose among presets while playing.

/Andreas

User avatar
liz
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 5201
Joined: Thu Jul 28, 2011 7:22 pm
Contact: Website

Re: Guitar amp modelling

Sun Oct 09, 2011 3:11 am

Really neat application. I'd be interested to hear how much floating point performance you need to model a guitar amp. Any ideas?
Director of Communications, Raspberry Pi

anwe79
Posts: 26
Joined: Sat Oct 08, 2011 10:30 pm

Re: Guitar amp modelling

Sun Oct 09, 2011 1:39 pm

I'm glad you like the idea :)
Sorry, I have no idea what kind of fp performance is needed.
From "top" i can see that guitarix standalone consumes about 12-15 % cpu on a core i5-2405S (running all cores at 1,6Ghz, ondemand scheduler). What proportion of that is fpu i can't tell without further digging.

With the engine disabled ,the gui alone consumes about 2-3%.
Also, jackd and the irq-thread for my firewire soundcard consumes 25% and 15% respectively. The firewire would of course be out of the equation for Raspberry Pi, but jackd would still be needed (most likely running with the alsa backend). Not sure how much of that would be fp in jackd's case, i think at least it does some sampling rate conversion if needed.

Also, the above numbers are from running with a sampling rate of 96 KHz, 24 bit resolution, which is probably way overkill. For live guitar sound i think 44 KHz (or maybe even less, most guitars are not that wide bandwith) and 16 bit is good enough.

Been thinking a bit more about this, as long as the fp performance is adequate, it should be at least doable. Custom hardware is of course needed:
Hi-Z preamp + ADC/codec (plugged directly to the i/o on the board)
Battery pack
Basic controls (input gain, input overload led, preset switching + display, and output volume)
Possibly an additional headphone output for in-ear monitoring.

Those things should be possible to squeeze into a quite small box, say the size of a guitar tuner.
You could possibly interface the thing with a usb/midi foot switch, but i think i'm getting ahead of myself...

Some custom software would be needed too, but i'll get to that in a later post.
/Andreas

zephod
Posts: 2
Joined: Sun Oct 09, 2011 2:38 pm
Contact: Website

Re: Guitar amp modelling

Sun Oct 09, 2011 3:53 pm

When running basic DSP algos for a guitar amp sim, you could do some decent processing with very little cpu. As a reference - a LOT of popular synths/effects run on 56k dsp's at/around 100mhz. Being able to dedicate everything makes a lot of difference. Small calculation: running a FIR, IIR and waveshaper at 44khz -> a FIR costs about 1 multiply-accumulate per tap.. lets take 32. IIR needs about 12 flops per sample. Waveshapers can be done in any amount of flops.. lets take 10. 10 + 32 + 12 = 54flops per sample. At 44khz = 2.376mflops. Not sure how fast this board can do flops, but if it can run at 10 cycles per flop, this would put you at about 3% cpuload. I suspect it can do much faster with its DSP and GFX core at your disposal.. more than enough room to do some serious rocking ;-)

User avatar
Burngate
Posts: 5972
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Guitar amp modelling

Sun Oct 09, 2011 4:18 pm

I thought I understood the original question, and the first answer. 2nd one made sense as well. Then I got lost. FIR? Is the F fourier? IIR? Please explain for us thickos!

zephod
Posts: 2
Joined: Sun Oct 09, 2011 2:38 pm
Contact: Website

Re: Guitar amp modelling

Sun Oct 09, 2011 4:21 pm

FIR = finite impulse response filter. Pretty much any frequency-response you may want, but no self-oscillating resonance.

IIR = infinite impulse response filter. Has severe limits on the frequency response, but can do heavy resonance (as far as numerical instability if you dont watch out... NOISEBURSTS!)

Beware of wikipedia if you are going to look these up... heavy math ahead.
Waveshaper -> something that distorts the shape of 1 wave in to another.

User avatar
Burngate
Posts: 5972
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Guitar amp modelling

Sun Oct 09, 2011 4:35 pm

Thanx!

User avatar
Burngate
Posts: 5972
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Guitar amp modelling

Sun Oct 09, 2011 4:38 pm

So my first hi-fi amp forty years ago had an IIR before it had blue smoke

User avatar
jzu
Posts: 26
Joined: Mon Aug 01, 2011 8:02 am
Contact: Website

Re: Guitar amp modelling

Tue Oct 11, 2011 3:51 pm

Do you really need to use Jack on a dedicated box, one which would have no user interface bar a few pushbuttons? Wouldn't a pure ALSA program perform better in this context?

anwe79
Posts: 26
Joined: Sat Oct 08, 2011 10:30 pm

Re: Guitar amp modelling

Tue Oct 11, 2011 9:34 pm

Not sure how good alsa is with latency, thats where jack really shines, but since its dedicated the story might be different here... Low latency is critical for this though, more than say 10 ms is definitely noticable and affects your playing.

Although since jack would run on top of alsa, i'm not sure how that really works latency-wise. On a dedicated system you could prioritise alsa beyond what would be usable on a normal box. I have little experience running jack on top of alsa, I know with the ffado backend i can get about 2 ms latency with few problems (occasional glitches, 4 ms is likely rock solid).

anwe79
Posts: 26
Joined: Sat Oct 08, 2011 10:30 pm

Re: Guitar amp modelling

Tue Oct 11, 2011 10:06 pm

Oh, btw, that might all beside the point anyway... Many "pro"-audio sound programs on linux (guitarix for one) depend solely on jackd for input/output. Using them on bare-metal alsa would probably mean the input/output parts would need to be rewritten or overhauled, which is probably a bit beyond my current skill set. Jack adds a lot of flexibility and convenience too.

PS The cpu load of jack seems to be (not too surprising) highly sample frequency dependent. I just tested at 44.1 KHz on ffado and the load drops to about 13% and 5% for the irq-thread. However, on alsa the load drops to ~1% each! So the jackd cpu load might not be a big problem after all. I think memory might be a bigger problem.

User avatar
jzu
Posts: 26
Joined: Mon Aug 01, 2011 8:02 am
Contact: Website

Re: Guitar amp modelling

Wed Oct 12, 2011 8:46 am

My own project, a real-time audio processor for guitar, currently runs on a Debian Slug (Linksys NSLU2, no FPU) with an USB interface using the ALSA API. Of course, I intend to port it on the Raspberry Pi, which should be a breeze. The effects I wrote include a delay, a flanger, and a distortion. Its current latency is a showstopper with this setup, however: >20 ms is too much for real-time playing. Does anybody know if it could come from the USB stack, ALSA, or some other parameter? Would switching to the Jack API enhance this latency? (Doubtful, but I don't really know the possible interactions between the ALSA and Jack subsystems...)

User avatar
[email protected]
Posts: 4
Joined: Fri Aug 12, 2011 7:01 pm

Re: Guitar amp modelling

Wed Oct 12, 2011 7:15 pm

Quote from Burngate on October 9, 2011, 17:38
So my first hi-fi amp forty years ago had an IIR before it had blue smoke
No doubt it had several IIR filters even before the magic smoke escaped.
What version of Windows[sup]Ⓖ[/sup] do I run? Why, X11 R6, of course!

anwe79
Posts: 26
Joined: Sat Oct 08, 2011 10:30 pm

Re: Guitar amp modelling

Thu Oct 13, 2011 5:31 pm

@jzu: Cool project! I don't know much about USB-audio on linux, but i'll give it a stab anyway...
I know there are quite a few "semipro" or pro audio interfaces that use USB with reasonable latencies. According to http://alsa.opensrc.org/Usb-au....._latencies 4-6 ms should be possible with some tuning, so the linux usb stack is probably not at fault. However, I suppose there might be large hardware buffers on your specific audio interface that get in the way. There might be a way to probe the interface for buffer sizes or maybe even change them, not sure.

If you want to find out if the hardware is at fault, I guess you could make a crude latency test by writing directly to the hardware device (bypassing alsa), reading it back from the input device (via loopback cable), and time the delay. That would at least give you the output+input latency of your hardware.

/Andreas

User avatar
jzu
Posts: 26
Joined: Mon Aug 01, 2011 8:02 am
Contact: Website

Re: Guitar amp modelling

Thu Oct 13, 2011 8:04 pm

The ">20 ms" number comes from recording both the sound of the strings and the output through an amp with a microphone into Audacity, and measuring the time between the dry signal and the processed one. I have yet to try to tune this module parameter, however - thanks for the tip.

This latency is not that annoying with time-based effects such as delays and flanging, but you do notice it when only the distortion is on, and it impairs your playing. For your amp modeling project, you should first make sure this problem can be solved.

Another potential issue I was wondering about was floating point computing. Sooner or later, I think I'll need FFTs and the like, and you will anyway. Can we use libm.so in a transparent way? Or does the architecture require to call special instructions/routines/whatever?

User avatar
jzu
Posts: 26
Joined: Mon Aug 01, 2011 8:02 am
Contact: Website

Re: Guitar amp modelling

Tue Oct 18, 2011 11:26 am

Back after a bit of homework. The ARM integrated FPU itself could handle float and double operations in a standard/transparent way. Now, what could be done with the GPU? Are there software components around, which would allow us to offload some of the math-intensive computing?

sonicase
Posts: 3
Joined: Sun Oct 23, 2011 11:14 pm

Re: Guitar amp modelling

Mon Oct 24, 2011 6:47 pm

i thought about doing this too
i'm more of a pc guy though i hear you can put vst on linux
you could probably use those cheap usb soundcards for the input and output

User avatar
reiuyi
Posts: 165
Joined: Sun Oct 09, 2011 4:59 pm
Contact: Website

Re: Guitar amp modelling

Tue Oct 25, 2011 12:12 am

Behringer produces low-end USB soundcards that cost close to nothing. I even got one for free when I bought a keyboard a while back. I think it's called UCA 222 or UCA 202.

The quality isn't really spectacular, though it's just above your average chipset and it has in/out, a headphone port and fiber optic.

Conveniently, it's about the same size as raspi is, and takes all power from USB. I wanted to use it with my Raspi because I doubt the onboard sound of raspi is going to be fun to listen to (besides AC3 on hdmi of course)

User avatar
jzu
Posts: 26
Joined: Mon Aug 01, 2011 8:02 am
Contact: Website

Re: Guitar amp modelling

Tue Oct 25, 2011 1:23 pm

From what I read somewhere else on this forum, the quality of the embedded PWM output could be pretty good, but we'll need an input device anyway.

anwe79
Posts: 26
Joined: Sat Oct 08, 2011 10:30 pm

Re: Guitar amp modelling

Tue Oct 25, 2011 10:45 pm

An el-cheapo USB-card is definitely the easiest way to get an input and I'll use one for starters, but i want to explore the possibilties of adding an ADC module, for the challenge if nothing else :).
There is an I2S-bus, so adding an ADC seems straightforward, at least hardware-wise. There's an ALSA driver with I2S-support for SoC's, but Broadcom support seems to be lacking. Maybe some of the Ti OMAP code could be reused since it's also ARM (OMAP 2 are 1136 based, which seem similar to the 1176 in RPi), need to dig more. Kernel driver hacking might be a bit over my head though... As you notice this may be a pipe dream, but i'll at least research it some more before i drop the idea.

Good to hear the fpu is usable. I'm no good with DSP-level stuff, the math boggles my mind, so my input on that will be limited. I'm still keeping my finger crossed about an API for the onboard DSP.

I do know my way around Debian though (was a sysadmin for a while), so i think I'll focus most of my efforts on optimizing the system and streamline it for running audio stuff. I won't go full distro or anything crazy, just make some scripts to set things up and get rid of unneeded stuff etc. At least that's were i'll start when i get my hands on a Pi. Then i'll tinker with guitarix of course and see if i can get it running smoothly and take it from there.

User avatar
jzu
Posts: 26
Joined: Mon Aug 01, 2011 8:02 am
Contact: Website

Re: Guitar amp modelling

Wed Nov 23, 2011 1:18 pm

You should stay clear from these ultra-cheap dongles you find on eBay, believe me, I tried them. You get sound, all right, and a lot of noise too. I'm currently testing the Behringer UCA202 reiuyi was talking about. This is way better. Its form factor matches the RPi Gerber I've printed a few days ago. Neat!

I haven't tested Fender-type single coils directly connected to it, only humbuckers through other (buffered) pedals. The raw signal level provided by single coils might be a tad too low - we'll see.

How much for a standalone 16-bit ADC chip? Last time I checked, ordering a single MAX 1132 from Maxim would cost a few Raspberries. And it would probably need a preamp stage (I like FETs here). Compare this with ~ €25 for an UCA202...

TechColab
Posts: 27
Joined: Tue Mar 06, 2012 10:27 am

Re: Guitar amp modelling

Wed Mar 07, 2012 3:33 pm

jzu said:

How much for a standalone 16-bit ADC chip? Last time I checked, ordering a single MAX 1132 from Maxim would cost a few Raspberries. And it would probably need a preamp stage (I like FETs here). Compare this with ~ €25 for an UCA202...

I've been looking at making an 24-bit/192kHz ADC/DAC board using the highly reputed Wolfston chips found in hi-end systems.  Which are incredibly cheap:

DAC (wm8741geds) for £12.03  ADC (wm8786geds) for £1.98

These are prices for single units from Farnell.

spamel
Posts: 196
Joined: Sun Jan 01, 2012 8:43 pm

Re: Guitar amp modelling

Wed Mar 07, 2012 4:03 pm

I can play guitar. That is all I can contribute here as the jargon has gone right over my head! I have a Floor Pod Plus, pretty neat bit of kit and some fun can be had with it. If you get anything upband running, let us know as I will certainly try it out. Wifi connected guitar, sounds like fun!

User avatar
ayecapn
Posts: 9
Joined: Wed Mar 07, 2012 7:13 pm

Re: Guitar amp modelling

Wed Mar 07, 2012 7:24 pm

Would be interesting to test the idea on a ratty old solid-body electric (knock-off LP) and machine out a hole in the back to place the device, rather than attaching it to the guitar or the strap.
"I'm going to be spending too much time and money with this stupid thing" - me

Stewrat
Posts: 5
Joined: Tue Mar 06, 2012 3:29 pm

Re: Guitar amp modelling

Wed Mar 07, 2012 8:08 pm

I don't understand all the high end maths but I am interested in this project. I've had immense fun whacking cheap ukuleles and cigar box guitars through cheap amps and the free version of amplitube on my laptop. At my level, almost any level of latency makes no difference - treat it as echo

And I suspect that is where the potential "value" lies - perhaps not in creating a state of the art modelling box, but rather in unlocking creativity with something that is "good enough" to get music departments and hobbyists making instruments and processing the bejeezus out of their sounds.

These are the kinds of ideas to get Pis into all sorts of non-computing areas - music, art, chemistry, sport etc etc.

Let the good times roll!

Return to “Other projects”