AndersRPi
Posts: 6
Joined: Tue May 27, 2014 7:56 am

Wireless remote microphone with RPi's

Tue May 27, 2014 8:14 am

Hi all,

I'm interested in finding out whether it would be possible to use 2 Pi's in a remote microhpone tx/rx setup.

Ideally I'd connect them via wireless (maybe ad-hoc depending on signal strength) then use one to constantly transmit a microphone signal from its input jack (using Wolfson sound card) and the other to receive the signal and output it on its audio output jack (also using a Wolfson card).

Latency would need to be reasonably low (<500ms).

Any thoughts or suggestions would be much appreciated.

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Wireless remote microphone with RPi's

Thu May 29, 2014 1:20 pm

I'm using Jack to stream audio.
Jack is available in two versions in the Raspbian repository, I'm using version 2:

Code: Select all

sudo apt-get install jackd2
I have several Wolfson-equipped Pis and shuffling audio between them with Jack works well.

This is how I do it:
In the examples below, the master (with the microphones) is named ob and the slave (with the speakers) is named ob3.
On the master, start a Jack server and then load the Jack net manager into it.

Code: Select all

ragnar@ob:~$ jackd -R -d alsa -r 44100 -P hw:0 -C hw:0 -i 2 -S >> some_log_file 2>&1 &
ragnar@ob:~$ jack_load netmanager
On the slave, start a Jack server with net backend:

Code: Select all

ragnar@ob3:~$ jackd -R -d net >> some_log_file 2>&1 &
Still on the slave, connect its Jack server to the sound card's outputs:

Code: Select all

ragnar@ob3:~$ alsa_out -c 2  -d hw:0 >> some_other_log_file 2>&1 &
ragnar@ob3:~$ jack_connect system:capture_1 alsa_out:playback_1 && jack_connect system:capture_2 alsa_out:playback_2
And, finally, back on the master, connect its sound inputs to the slave:

Code: Select all

ragnar@ob:~$ jack_connect system:capture_1 ob3:to_slave_1 && jack_connect system:capture_2 ob3:to_slave_2
I'm not too concerned with latency myself, but if I remember correctly I got somewhere around 25 ms when I tested it.
In any case it was well below 100.

Pulseaudio is also able to send audio over the network, but I have never used it myself.

--
Ragnar
Last edited by ragnarjensen on Thu May 29, 2014 3:15 pm, edited 2 times in total.

AndersRPi
Posts: 6
Joined: Tue May 27, 2014 7:56 am

Re: Wireless remote microphone with RPi's

Thu May 29, 2014 1:43 pm

Ragnar,

Thanks a lot for your detailed response.

I'll go ahead and order the Pi's with the Wolfson cards and let you know how I get on.

Cheers,

Anders

AndersRPi
Posts: 6
Joined: Tue May 27, 2014 7:56 am

Re: Wireless remote microphone with RPi's

Mon Jul 14, 2014 4:38 pm

Hi Ragnar,

I've got my pi's and the wolfson cards (finally!) and I'm having a bit of trouble with Jack..

With a clean boot of the 'wolfson_3.10_master.img' build, on my master pi (with mics) I run:
  • . /home/pi/Record_from_DMIC.sh
  • alsamixer (to check that the wolfson card is showing up properly, which it is I think- Card: snd_rpi_wsp)
  • sudo apt-get update
  • sudo apt-get install jackd2
  • jackd -R -d alsa -r 44100 -P hw:0 -C hw:0 -i 2 -S >> tx_log 2>&1 &
  • jack_load netmanager
Then I get a whole host of errors from Jack (pic below, you might need to open in new window/tab to see full size..)

Image

Any ideas..?

*** EDIT ***

I added the user 'pi' to the audio group using 'sudo usermod -a -G audio pi' and this got rid of some of the errors but it's still not starting. See pic below:

Image

**************


Thanks

Anders

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Wireless remote microphone with RPi's

Mon Jul 14, 2014 8:11 pm

Jack installed from the Raspbian repositories requires dbus support, which in turn requires that an X server is running.
I compiled jack from source without dbus support.
Or, you could try to start a dbus session before starting jack: https://github.com/jackaudio/jack2/issues/10
--
Ragnar

AndersRPi
Posts: 6
Joined: Tue May 27, 2014 7:56 am

Re: Wireless remote microphone with RPi's

Tue Jul 15, 2014 2:20 pm

Ok, I managed to get a version of Jack running that doesn't require dbus support and got past the memory errors etc.

Now I have Jack and netmanager running fine on the master pi, but it doesn't seem to be launching a server with net back end on the slave properly.

On the slave I get no results when I type

Code: Select all

jack_lsp
. When I try:

Code: Select all

jack_connect system:capture_1 alsa_out:playback_1 && jack_connect system:capture_2 alsa_out:playback_2
I get an error 'alsa_out:playback_1 is not a valid port'.

Is there any way of manually setting this up? Also do I have to configure the listening ip/ports on the master netmanager instance?

Thanks v much

Anders

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Wireless remote microphone with RPi's

Wed Jul 16, 2014 6:54 am

Hmmm, not sure what goes wrong. I don't have to configure anything.
If I have qjackctl going on the master, I can see the slave pop up as soon as I start it.
The slave announces its presence with udp broadcasts.
--
Ragnar

AndersRPi
Posts: 6
Joined: Tue May 27, 2014 7:56 am

Re: Wireless remote microphone with RPi's

Wed Jul 16, 2014 11:17 am

I was originally trying to get it running on headless pi's without any GUI at all and that seemed to be causing some problems.

I'm now running both pi's on GUI mode but with just the master pi connected to a display and ssh'ing into the other - this seems to be much less error prone.

I managed to get it all working by getting netmanager and the net backend to both listen to the ip address of the master (192.168.1.1):

Code: Select all

#on the master
jack_load netmanager -i "-a 192.168.1.1 -p 19000"

Code: Select all

#on the slave
jackd -R -d net -a 192.168.1.1 -p 19000
Thanks for your help ragnar, it took a while but it's all good! Latency seems to be around 25 ms.

Anders

AndersRPi
Posts: 6
Joined: Tue May 27, 2014 7:56 am

Re: Wireless remote microphone with RPi's

Fri Jul 18, 2014 8:23 am

Just thought I'd mention for anyone who wishes to follow this post:

To get this to work I changed the lines:

Code: Select all

alsa_out -c 2  -d hw:0 >> some_other_log_file 2>&1 &
jack_connect system:capture_1 alsa_out:playback_1 && jack_connect system:capture_2 alsa_out:playback_2
to..

Code: Select all

alsa_out -j hostname_of_slave  -d hw:0 >/dev/null 2>&1 &
jack_connect system:capture_1 hostname_of_slave:playback_1 && jack_connect system:capture_2 hostname_of_slave:playback_2

TobiK
Posts: 4
Joined: Sun Feb 15, 2015 11:53 am

Re: Wireless remote microphone with RPi's

Sun Feb 15, 2015 12:23 pm

Dear ragnarjensen and AndersRPi,

after doing a lot of resaerch on the web, i think this thread is the closest to my problem i could find!

I am trying to setup multiple of RPI's (Model B) over network with wolfson cards and Raspbian via Noobs.
The Goal is to get a modular crossover for audio applications, with each PI filtering a stereo signal vie FIR folding.

My Problem is, that i cannot get jack running with the wolfson card. I am not very good in any kernel related things or in setting up any alsa chains.

My plan was to use the audioadapter of jack with the netmanager and finally some instance of brutefir.

BUT: after i start jackd it crashes after about 30sec.

It would be great, if you can give a step by step explanation how you get jackd working with the wolfson card. It would be particularly interesting, if you used some precompiled kernel like:

https://blog.georgmill.de/2014/04/29/co ... a-new-try/

Or if you compiled everything on your own.
Also it would be great to know how exactly you start jack. Do i have to run the *.sh files from the wolfson package prior to jack?

Please tell me if you need any information, but i think, due to the same RPI's we are using, it should be possible if i just follow your instructions step by step. It would be great if it would work at my PIE's the same way than it works with your's:
I have several Wolfson-equipped Pis and shuffling audio between them with Jack works well.
But when loading netmanager it throws me an error 'Driver is not running' :( I gues i do have a wrong kernel or something like that... I do use the graphical raspbian, so the Dbus thing cannot be the problem i think...

Thank you so much for your help, and if you think this should be moved to another, new thread i will do that!

Tobi

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Wireless remote microphone with RPi's

Sun Feb 15, 2015 7:08 pm

TobiK wrote: I am trying to setup multiple of RPI's (Model B) over network with wolfson cards and Raspbian via Noobs.
I presume the NOOBS you're talking about is the one supplied by Wolfson/element14 and not the ordinary one from the Raspberry Foundation?
TobiK wrote:BUT: after i start jackd it crashes after about 30sec.
This is where you should have inserted all the gory error messages, so we could try to see what goes wrong ;)
TobiK wrote:It would be great, if you can give a step by step explanation how you get jackd working with the wolfson card. It would be particularly interesting, if you used some precompiled kernel like:

https://blog.georgmill.de/2014/04/29/co ... a-new-try/

Or if you compiled everything on your own.
I compiled my own kernel(3.10.25), because I need a display driver that is not in the stock kernel.
I also compiled jack itself from source, to get a dbus-free version.
TobiK wrote:Also it would be great to know how exactly you start jack. Do i have to run the *.sh files from the wolfson package prior to jack?
I run the scripts to set up the Wolfson cards before I start jack.
On the master, I have a bunch of scripts to set things up (it's a pretty complicated setup), but the ultimate commands to start jack are

Code: Select all

jackd -P 70 -d alsa -r 48000 -P hw:0,0 -C hw:0,0 -i 2 -S
jack_load netmanager
On the slaves, it's simply

Code: Select all

jackd -R -d net
TobiK wrote:Please tell me if you need any information
Every error message from jack you can find. Also the output from these commands:

Code: Select all

aplay -l
aplay -L
arecord -l
arecord -L
uname -a
cat /proc/version
cat /proc/asound/cards
TobiK wrote:
I have several Wolfson-equipped Pis and shuffling audio between them with Jack works well.
But when loading netmanager it throws me an error 'Driver is not running'
Probably because jackd isn't running at all or that jackd is unable to communicate with the sound card.
--
Ragnar

TobiK
Posts: 4
Joined: Sun Feb 15, 2015 11:53 am

Re: Wireless remote microphone with RPi's

Mon Feb 16, 2015 5:25 pm

Thank you for the very fast and accurate reply!

I really used the original NOOBS Raspian, but with this Kernel copied into the root:

https://blog.georgmill.de/2014/04/29/co ... a-new-try/

Thank you for pointing me out to the original wolfson image file. I was a little afraid to use that one because of the size and that it will probably not be maintained. Well, now it is running. I can use BruteFIR and the Pi does a very good job. Only one problem remains: It has something to do with the sync.

I use the audioadapter on the slave as described here:

https://github.com/jackaudio/jackaudio. ... r_NetJack2

In my opinion, due to re-sampling, no delay should occur between the master and the slave. But i can hear a clear 'echo effect'.
If i start the slaves it tells me, i am 'synced', because i started the master with -S option.
Also i tried pretty high buffer sizes (-n = 4 and 8192 samples) but still there was some delay between master and slave!
When starting the slave, the master tells me: connection with latency 1then 2 then 3 then 4.
It is important to know, that the absolute latency is absolutely no concern for me.

Do you know if there is the possibility to sync master and slaves?
Or can only the slaves be synced (would be fine for me, too)??
Or is everything, due to network and different clocks, always out of sync?
OR (this is my suspicion) am i missing any parameters?

Thank you for your help,

Tobi


Edit:

I guess "syncing with latency = 4" output means that 4 periods of jack are used for communication. This page

http://manpages.ubuntu.com/manpages/tru ... rce.1.html

says something like
But the main usecase is of course a LAN, where it can achieve one jack
period of latency.
which lead me to that suspicion... ;)

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Wireless remote microphone with RPi's

Mon Feb 16, 2015 7:43 pm

TobiK wrote:...no delay should occur between the master and the slave. But i can hear a clear 'echo effect'.
That is latency, i.e. the audio packets are delayed because it takes time to process them or transport them over a network. You will always have some.
TobiK wrote:If i start the slaves it tells me, i am 'synced', because i started the master with -S option.
I think we have a question of semantics here ;)
"Synced" doesn't mean "at the exact same point in time", but rather "at the same speed or rate". It is important when using networked jack slave servers for their main purpose; processing. The master sends audio to a powerful processing slave, which then sends it back to the master. The slave mustn't expect incoming audio or return audio to the master at any other rate than that the master operates at. There will still be latency (delays) but when the two servers have synced, the latency never varies.
If you are listening to both master and slave, the latency will be heard as an echo if it's big enough, but the echo doesn't get longer or shorter over time because the servers are in sync.

The audioadapter has to resample because the clocks on the master's and slave's soundcards often doesn't run at exactly the same rate. That resampling adds to the latency.
TobiK wrote:Do you know if there is the possibility to sync master and slaves?
They probably already are :)
TobiK wrote:Or can only the slaves be synced (would be fine for me, too)??
I'm not sure what you mean with that, so the answer is probably "no" :D
TobiK wrote:Or is everything, due to network and different clocks, always out of sync?
Yup, this is it. Probably not out of sync, though, but with some latency.
TobiK wrote:OR (this is my suspicion) am i missing any parameters?
I don't think so. You seem to have a pretty good grasp on things.
TobiK wrote: I guess "syncing with latency = 4" output means that 4 periods of jack are used for communication. This page

http://manpages.ubuntu.com/manpages/tru ... rce.1.html

says something like
But the main usecase is of course a LAN, where it can achieve one jack
period of latency.
which lead me to that suspicion... ;)
Yep, the two servers have determined that they have to allow for that much time in order to be able to stay in sync with each other.

In my setup I have one master and two slaves. Slave 1 sits next to the master in the same switch. Latency is ten milliseconds, just about audible if you have good ears. Slave 2 sits in another part of town, and latency is typically several hundreds of milliseconds.
--
Ragnar

TobiK
Posts: 4
Joined: Sun Feb 15, 2015 11:53 am

Re: Wireless remote microphone with RPi's

Mon Feb 16, 2015 10:18 pm

Hi there,

thank you for the semantics!! :) For me, something was synced, if i get an output at exactly the same time for any given input through any two 'machineries'. But i guess your explanation with an constant latency over time makes more sense (if i got that right)! :D

So, i know, the jack_netmanager is meant to be for processing on the slave machines, but not for audio playback due to the resample issues.
BUT: If i know the latency between all the outputs after once started all the slaves (and the one master) in my setup, i could add frequency independent delays (in BruteFir) that would virtually eliminate latency between my sound outputs. The overall delay will rise to the longest delay in the setup then.

For this, i have a few questions in my mind:
1) Do i have the same latency at all outputs when i start the same setup (switch, Pie's, master&slaves) twice?
2) If i virtually eliminate the latency, how 'low' in latency can i go? I guess, if BruteFir supports that (But due to the Filterdesign it should be able to do so, simply make the sum of 1Sample with Wight 1 sample(i) = sum (sample(i+1)+1)), i can reach sample-accuracy.
I know, it's a bit of an 'Brute Force' Method, but in the end, there should be a modular FIR Audio Crossover for DIY-Hifi Enthusiasts:) . One Crux is, that Multichannel sound cards can get pretty expensive, or are limited in resolution and channels via USB and that i did not find an I2S multichannel sound card. Also Firewire needs an ITX Board with a lot of unneeded stuff...And that would all be 'non open source (due to Manufacturers of Soundcards)'.

So i will give the Delay-Compensation a try. I could imagine that it will work!! First Step: I have to think about a method to measure the Delay between the Outputs. Perhaps with some differential circuit and an amplifier. If two spikes get from 'echoed' to 'silent', the right delay is found. Some purely software based solution would be much more cool, though :)

Thanks a lot again for your help and explanation of semantics!

Tobi

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Wireless remote microphone with RPi's

Mon Feb 16, 2015 10:54 pm

TobiK wrote: 1) Do i have the same latency at all outputs when i start the same setup (switch, Pie's, master&slaves) twice?
Yes, that is my experience.
TobiK wrote:2) If i virtually eliminate the latency, how 'low' in latency can i go? I guess, if BruteFir supports that (But due to the Filterdesign it should be able to do so, simply make the sum of 1Sample with Wight 1 sample(i) = sum (sample(i+1)+1)), i can reach sample-accuracy.
I have never used BruteFir myself, but I think you can set delays on both inputs and outputs. As far as I can tell, the input and output structures of its configuration file have "delay" and "subdelay" fields. If I've understood it right, you should be able to get accuracy down to 1/100th of a sample.
--
Ragnar

TobiK
Posts: 4
Joined: Sun Feb 15, 2015 11:53 am

Re: Wireless remote microphone with RPi's

Tue Feb 17, 2015 7:08 pm

Hey there,

first results are frustrating. The following is happening:
Playback of a 1000Hz sawtooth via Jack directly over the master, or via netmanager over the slave. i use one of the two stereo signals from the two outputs (master&slave) and record them on my desktop PC with xoscope and an Edirol interface opened with

Code: Select all

aoss padsp xoscope 
.

I trigger on the one signal, and in no setup described below the delay between the two signals is constant.
Once it varies with mouse movement (=processor capacity) on the slave or on the master machine. I think this effect is described in the wiki of Netjack2

https://github.com/jackaudio/jackaudio. ... r_NetJack2

If there is no sync at all, the delay varies without any outer actions. Thus, i cannot use this concept for my idea, i'm afraid. :|
A constant delay, would have been no problem, but with shifting of the time between the signals, no crossover can be built.

Thank you for your help, anyway, now i have 5 pies wolfson audio cards and Hifiberrys for sale :(

Is there anything i forget?
The Problem also is, that i just cannot imagine HOW this effect can happen. It must mean, that when playback'ing music over audio or netadapter, the music on the slave is streched or compressed in time.
I also tried this with an headphone syncron to the Osilloscope (left from master, right from slave) and the listening experience was exactly what one could see at the screen.
My last hope that all slaves will be delayed the same amount at the same point in time. This effect would have nothing to do with an HiFi approach (with the netadapter), but one could use the filters with audio adapter, because the master would delay the signal (that is not used), ans not the slave....Lets see and hope, but i have little hope...

listed the cases mentioned above:
I can run the master and slave in sync mode or not in sync mode.
I can add an audioadapter on the slave or an netadapter.
The buffersize does not solve the problem.

Thank you and if you do have any ideas, please tell me :)!!

Tobi

Return to “Other projects”