LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   wall wart linux to allow audio monitoring via wifi network (http://www.linuxquestions.org/questions/linux-newbie-8/wall-wart-linux-to-allow-audio-monitoring-via-wifi-network-928205/)

sneakyimp 02-07-2012 07:26 PM

wall wart linux to allow audio monitoring via wifi network
 
I play in a band and we rent a rehearsal space in a building that also houses other bands. Occasionally, we drive over there hoping to record something and there are all kinds of other bands rehearsing so it's not quiet enough. The facility has free wi-fi so I want to set up something (cheap) which would allow me to listen via a microphone or webcam so I can tell if it's busy and/or loud before trekking over there.

I was thinking of getting one of those wall wart linux boxes and attaching a microphone or webcam to it, but have very little experience either with the little computers or with getting a USB device (like a mic or webcam) to connect to a linux box and share its data over the internet.

Because there is no fixed IP or domain associated with the wifi network at this facility, I expect I would need to write a cron script that would check in every so often with one of my servers so the wall wart could keep me apprised of its current IP address.

Beyond that, I'm kind of lost. Any advice about linux drivers for mics, etc. and how to share the audio data via internet would be much appreciated.

yooy 02-08-2012 03:11 AM

check internet radio programs, maybe there is one with mic support and you are done. You don0t need a mic driver but a soundcard driver if anything.

sneakyimp 02-08-2012 03:04 PM

I just don't see how a soundcard is going to fit into a wall wart. On the other hand, I do have a USB microphone and most of these wall wart things have USB jacks.

LinuxNoobX 02-08-2012 03:12 PM

I am a little fuzzy on the set up of externals on a Linux machine but once you have the recording portion set up where the band is playing you can use a hyper intuitive service called livestream to do web broadcasts and watch the band play from any internet terminal... the service also has a few other features. I was testing it for the purposes of monitoring my apartment remotely... the ghetto is not very friendly to a man with a decent computer setup :) . Livestream is browser-based so it should be compatible with Linux or any end-user OS for that matter. Z/Z

sneakyimp 02-08-2012 03:19 PM

The point is not to watch the band play or to stream the band at all. The point is for the band to check when they are at home whether the building is quiet or not.

For example, While at home, I get a hankering to record my new song, Mr. Winnar, and would like to know if it is quiet enough in the rehearsal complex to go down and record some moody acoustic brilliance. I pull out my computer (or phone) and type in the IP address of the wall wart machine running down at the space and in doing so I can hear what's coming through the mic at the rehearsal complex.

A couple of important things:
1) Our recording setup is a windows machine and probably consumes a few hundred watts of electricity. We don't want to leave this on 24-7. That's why I'm thinking wall wart as they only consume about 5 watts.
2) I'm not really interested in paying for a streaming service just for this use. I'm not afraid of writing my own cron jobs and/or apps to get at the audio data on the mic. Just wondering if there's some open source thing out there that might make it easy.

LinuxNoobX 02-08-2012 03:30 PM

The streaming service is free but if all you want to do is check volume levels then a used netbook with Linux and teamviewer ( other variations of team work too but it is the only one I can think of ) should keep power consumption low and allow you to monitor the place remotely on-demand 24/7... most netbooks have built-in webcams and in a lot of cases built-in mics which suck but are fairly sensitive. Z/Z

sneakyimp 02-08-2012 03:51 PM

OK I like this thinking, but this netbook would need to be set up to auto-answer or something. Unless I'm mistaken, someone has to allow a user to connect to a team viewer session. If it's possible to fire up team viewer on this netbook and prevent it from sleeping and then the netbook can auto-answer team viewer connections, that would pretty much rule. This sounds a lot simpler than the other approach I was thinking. I was expecting to
1) set up wall wart computer to check in to my apache web server via a cron job to say "Here I am at IP www.xxx.yyy.zzz".
2) When I access from home, I go to my apache web server and find out where the wall wart checked in from then try to access that IP
3) set up some kind of streaming access to the wall wart

I realized this morning that I have no control over the wifi router at the rehearsal complex and would therefore be unable to route incoming requests to the wall wart computer in my rehearsal space. The problem is something like this:
1) wall wart recently checked into my apache server and said "As you can see I'm www.xxx.yyy.zzz and my LAN address is 192.168.1.123"
2) I go to my apache server which tells me to visit www.xxx.yyy.zzz
3) I send a request to port 12345 at www.xxx.yyy.zzz
4) WiFi router is the machine connected at www.xxx.yyy.zzz and says "lolwut?" and drops the request

LinuxNoobX 02-08-2012 04:20 PM

I am trying to figure out if you are trying to access a computer remotely or trying to make weaponized anthrax.

From the place you are monitoring you just have to set the display to dim never or after 10 mins and disable hibernation... with team you can set up a shared account easily so as long as both computers are accessing the internet and have team running then you can execute team and access any computer you have on the team network that is connected to the internet.

Livestream works in much the same way... these are moron Windows end-user methods that work with Linux... configurations that use apache or online hosting or anything like that are beyond my scope until I start my projects up again. Z/Z

sag47 02-08-2012 04:38 PM

If it were me I would write (or find) a sound meter which measures the dB coming in on the microphone (basically how loud the environment is).

Server side
On the server side I would have munin set up which simply receives data and logs it in a graph.

Client side
Write a munin plugin which uses the sound meter to measure the decibels of the room and submit the check automatically to the munin server with the sound level as a integer value in dB.

Then the sound in the room can be measured at regular intervals over time and graphed. Then you may start to see trends when nobody is at the room. Historical trend data is more useful then real time listening in this case in my opinion. You could then create your own schedule around when nobody is usually there (or the lowest noise level periods since there may always be environment noise).

***EDIT***
Terms you might want to look for is sample peak programme meter (SPPM) in plain text or terminal for linux.

alsa peak meter

Are a few I've looked up. Some promising results but no one off solution without writing your own so far.

***EDIT***
Sample software I found which could be used to write a pure text sound meter plugin.
***EDIT***
With help from the #alsa channel I found the sox command which can give you statistics on a sound file. So you can record the environment for 1 second (or more) and then run statistics on the file using an audio analyzer.
Code:

sox MYFILE.wav -n stat
#one liner to record one second and then analyze the sample using sox.
arecord -d 1 -f cd -t wav foo.wav &> /dev/null && sox foo.wav -n stat

You could then process the output of the sox command using python or perl and then output in a format that munin can understand. The parts you want to keep track of for the noise levels are the amplitudes. More specifically the "Maximum amplitude".

***EDIT***
So to get the maximum amplitude for a plugin you would want to run the following command...
Code:

#!/bin/sh

case $1 in
  config)
        cat <<EOM
graph_title Maximum Amplitude
graph_vlabel mamplitude
mamplitude.label max_ampl
EOM
        exit 0;;
esac

echo -n "mamplitude.value "
arecord -d 1 -f cd -t wav /tmp/foo.wav &> /dev/null && sox /tmp/foo.wav -n stat 2>&1 | grep 'Maximum amplitude' | awk '{print $3}'
rm -f /tmp/foo.wav

And there's your munin plugin. Pretty cool journey. Thanks custos-mundi from #alsa on freenode for helping me find the tools I need and breaking the problem down.

SAM

sneakyimp 02-17-2012 01:24 PM

OK I've been preoccupied with other stuff, but I did manage to test Teamviewer using my ASUS netbook and it works pretty darn well. I get video too. This is definitely an option. I'm considering just installing teamviewer on the pc in question. I've got my kill-a-watt and can see how much electricity is being consumed.

sag47: Amazing info. The graph approach does sound very interesting because it would give one a good idea ofwhen the quiet times are, generally speaking. THANK YOU so much for the detailed info. Coding in C is a little deeper than I'd like to get, but I may just do it anyway. At the moment, I'm wondering whether I can connect my logitech USB microphone to a wall wart linux box. In particular, where would one find the driver? How can one determine what sort of audio is being fed into the wall wart box?

sag47 02-17-2012 02:41 PM

Quote:

Originally Posted by sneakyimp (Post 4605284)
sag47: Amazing info. The graph approach does sound very interesting because it would give one a good idea ofwhen the quiet times are, generally speaking. THANK YOU so much for the detailed info. Coding in C is a little deeper than I'd like to get, but I may just do it anyway. At the moment, I'm wondering whether I can connect my logitech USB microphone to a wall wart linux box. In particular, where would one find the driver? How can one determine what sort of audio is being fed into the wall wart box?

The drivers for webcams are generally supported out of the box. I just linked you to a support document which points you to kernel modules (drivers) for different webcams if it is not automatically supported.

Also for the solution I gave you, you don't have to program in C. I gave you the complete solution (arecord records the audio sample, sox gives you the amplitude from that sample). The programming you see is a munin plugin (basic bash) and I even added to the plugin in a blog post. They are both tested working examples and can be graphed as of this post.

sneakyimp 02-17-2012 02:44 PM

Most excellent. Sorry to ask already-answered questions. Currently overwhelmed with day job.

I'm truly grateful. rep++

theNbomr 02-17-2012 03:02 PM

How about getting a motion detector, such as the ones used to control outdoor lights, which I believe provide a contact closure when they detect motion. Then, on your wall wart form-factor host, find something that has a binary input of some sort, like a printer port, or game port, or even a serial port that implements modem-control lines. These kinds of inputs should be very easy to monitor with a simple userspace program that can be called as a CGI from the web server, or can simply beacon out to a remote web server whenever the empty/occupied status changes. If you aren't up to writing such code, it is probably simple enough that someone would be able to provide it right here without too much sweat.

--- rod.


All times are GMT -5. The time now is 06:42 AM.