metalj
Posts: 212
Joined: Sat Feb 07, 2015 11:56 pm

Bare metal for real time sound?

Sat Feb 28, 2015 8:12 pm

I read if I want to change sounds in real time I would need to learn bare metal. What is the best book to learn bare metal for the raspberry pi? Also have any musicians turned the RPI into a stompbox or a mixer or teleprompter yet?
Backspace 28 times :)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12398
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Bare metal for real time sound?

Sun Mar 01, 2015 1:02 pm

not convinced you will need to go as far as to use bare metal for this, yes linux isn't "real time", but I don't think that matters in this case, all sound systems use buffering so that millisecond "hiccups" don't matter.

p.s. changed subject line, just "bare metal" doesn't describe a post in the bare metal section well.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Bare metal for real time sound?

Sun Mar 01, 2015 2:46 pm

Yeah, "soft real time" should be more than good enough for most sound usages. You might want to try Sonic Pi, which does "real time" livecoded music / sound synthesis in ruby.

User avatar
aTao
Posts: 1087
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: Bare metal for real time sound?

Sun Mar 01, 2015 3:20 pm

metalj wrote:I read if I want to change sounds in real time I would need to learn bare metal. What is the best book to learn bare metal for the raspberry pi? Also have any musicians turned the RPI into a stompbox or a mixer or teleprompter yet?
All depends what you want to do..

Your reference to stompbox implies a synth, Raspbian should cope well enough for that as a sample player (real time sound generation or formant synth is a different story). Raspian should also cope with users controls to create the samples since it would only have to work a the rate you can twiddle a knob.

If, you did really need a formant synth, or an eq or mixing system then even bare metal is going to give you problems*, the only serious way to go would be an external DSP

* trust me, even with the grunt of the PI2 real time audio is a 'mare
>)))'><'(((<

Avoncliff
Posts: 35
Joined: Fri Dec 09, 2011 5:24 pm

Re: Bare metal for real time sound?

Mon Mar 02, 2015 11:02 am

How real is real time?
Sound travels though the air @ 1msec per foot ( in round numbers).
So a 10 msec delay is much like being 10feet from the sound source.
At a 1msec delay, with headphones, the sound will be heard earlier than a guitarist would hear it live.

metalj
Posts: 212
Joined: Sat Feb 07, 2015 11:56 pm

Re: Bare metal for real time sound?

Tue Mar 03, 2015 1:21 am

I want to make a effects box that I could plug a guitar into and then out to mixer or amplifier. Distortion, modulation, pitch changer effects, real time reverse audio. Also I want to make a mixer with similar effects. My concern came from using my cellphone as a microphone because there is an awful delay also most computer programs add effects to guitar parts after they are recorded and I'm not interested in that I want to use gear live on stage.
Backspace 28 times :)

User avatar
aTao
Posts: 1087
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: Bare metal for real time sound?

Tue Mar 03, 2015 10:47 am

metalj wrote:I want to make a effects box that I could plug a guitar into and then out to mixer or amplifier. Distortion, modulation, pitch changer effects, real time reverse audio. Also I want to make a mixer with similar effects. My concern came from using my cellphone as a microphone because there is an awful delay also most computer programs add effects to guitar parts after they are recorded and I'm not interested in that I want to use gear live on stage.
Delays, pitch change, reverse audio are probably possible, distortion , I guess so, modulation probably not unless you have access to top flight audio coding.

The biggest problem is making absolutely sure you always have the next sample out on time, any deviation whatsoever and you will get an audible click. This was a show stopper and even company killer in the early days of computer studio equipment (I sent at least one manufacturer to the fail bin because of the problems). It all happened just after Macs lost their monopoly of video edit gear, PCs failed abysmally to start with but got their act together. Then, all cock sure of them selves they went for the audio market and died a horrible death. A first glance you would thin that if you can handle video data rate then audio would be simple, but video comes in chunks (frames) and a processor has a fair bit of time to sync to a new frame, audio has to clock out on the dot every sample else fail.

Next thing to do is work out just how each effect would work in code, try some with offline (not real time) converting stored samples, then try to build up to live audio.
When you find a task that just jams up think about an external system, either voltage controlled analogue hardware or go the whole hog and get some DSP, I think I rememebr someone posting about an external DSP board...
>)))'><'(((<

metalj
Posts: 212
Joined: Sat Feb 07, 2015 11:56 pm

Re: Bare metal for real time sound?

Tue Mar 03, 2015 5:41 pm

By modulation I ment reverb and delay I apologize if I used the term incorrectly. Yeah I guess I will work on recorded samples first then work my way up to analog signal manipulation. Side question: is there anything more sensitive that a microphone for analyzing audio data?
Backspace 28 times :)

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Bare metal for real time sound?

Tue Mar 03, 2015 6:01 pm


User avatar
aTao
Posts: 1087
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: Bare metal for real time sound?

Tue Mar 03, 2015 8:29 pm

metalj wrote:By modulation I ment reverb and delay I apologize if I used the term incorrectly. Yeah I guess I will work on recorded samples first then work my way up to analog signal manipulation.
Ah.. now then.. Delay effects are memory hungry, not processor so you're on a win there. Delay effects: delay, echo, reverb, pitch shift, chorus.
Delay:
read sample into ring buffer, read sample at a different index in buffer; advance both pointers.
Echo:
same as delay but mix the output back into the input, either software multiply then add or outside in analogue world with voltage (or PWM) controlled mixer (RPi sets the control voltage, good use of PWM here)
Reverb: just en echo with a short offset between read and write pointers in the ring buffer, fancy ones use multiple read [pointers and mix the signals together, really fancy ones use many buffers running ate different delay rates).
Pitch shift:
short echo system but with the read pointer stepp9ng at a different rate from the write pointer, for this you would need to take 2 or more consecutive reads and average them (hted by exact ratio of time to when the sample was read) to get a sample out at the right time./
Chorus:
2 or more pitch shifts working side by side.
Side question: is there anything more sensitive that a microphone for analyzing audio data?
A microphone is what is called a transducer, it converts one signal medium to another (air pressure waves to electrical) it does not really do any analysing. There are ultra good ultra expensive mics, there are very expensive rubbish ones, there are dirt cheap brilliant ones and the good old SM58. Most audio analysers are didgital now, and if you dont need real time you can write one that will run just fine on the RPi (even better on tghe RPi2) in which case, if your signal starts as a digital signal, keept that way (no mucking about in the air and all that m'larky) If you must try to get precision anaysis of a real life sound then you are going to need a very expensive calibrated precision mic.
As for more sensitive, then if you know how to use your ears just right (there are tricks to it), electronics have a lot of catching up to do.
>)))'><'(((<

Return to “Bare metal, Assembly language”