Tuesday, 20 September 2016

Batsound under Linux and Macs

When running courses on analysing bat echolocation calls, I often get asked if it's possible to run sound analysis software on Mac computers (and occasionally Linux too). There is of course Kaleidoscope from Wildlife Acoustics, but as I run my courses using Batsound, that's not much of a help. You can of course run windows within Linux and Mac OS using virtualisation software (most notably parallels on a Mac), but this has some serious performance issues unless you have a fast machine, plus you need a legal copy of Windows as well.

I have been able to get older versions of Batsound to run under WINE in Linux. WINE stands for the recursive acronym Wine Is Not (an) Emulator and allows Windows programs to run on Macs and Linux machines without having to install windows. It basically converts calls to windows functions into Mac or Linux functions on the fly, so (should) run faster. Wine is also free. However, more recent versions of Batsound have failed to run as they need a Microsoft Visual C++ runtime library as well which is happy under Windows, but less so under Linux (and I assume Macs as well).

Nevertheless, after a lot of tinkering, I have been able to get the latest version of Batsound (version 4.2 not Batsound Touch) to work under Linux. This process should also work for Macs as well.

I've been using crossover by Codeweavers. This is basically a front-end to WINE. It's not free, but profits from Crossover go back into the development of Wine. You can download a trial version and test it out for free though. Crossover makes the installation of windows programs a whole lot easier.

The basic process is to create a Windows 7 bottle to contain all your Batsound programmes, then install the Visual C++ x86 redistributable provided with Batsound (the 2012 version). This will install but not function under Crossover but needs to be there for Batsound to install. Next. install Batsound. Batsound will install and the installation will finish, but Batsound but not work. The finally get Crossover to install the 2010 version of the Visual C++ redistributable which does work under Crossover and which batsound will use. Batsound should work fine. The only thing that seems to be missing is the ability to export graphics, but you can always use a screen grabber for that anyway.

Here is the process step by step:

1. Download and install Crossover.

2. Create a new Windows 7 bottle by selecting the wine bottle icon top left and then clicking +add at the bottom. make sure it's a Windows 7 bottle from the drop down list and give it a memorable name.





3. Now we have a Windows bottle with it's own C: drive and programs directory.

4. We now need to install the Visual C++ redistributable into that bottle.

5. Select the bottle and click Install Windows Software (bottom right).


6. Click Select a Bottle to Install to (you have to keep making sure it's going to install it into the right place - if you find a new bottle appears on the left, it's installed the software to its own bottle and it won't work).


7. Continue and click Select Application and you will be faced with a menu of windows software profiles you can install (we will use these later...). Go to Unknown and Other applications and then Continue.


8. Select Choose installer file Navigate to your Batsound install folder and select vcrredist_x86. This is the Visual C++ redistributable we will need to make Batsound install. Click Open.





9. The redistibutable will now install.


10. Once that has completed, now install Batsound. It's the same process as the redistibutable.

Select the bottle:


Select an application to install and go to Unknown and Other


Select Batsound


And install it.


If it's working so far, you should get the Batsound registration page to enter the serial number.


If you don't get the option to enter your name and serial number then I'm afraid the installation has failed. Go back, delete the bottle and try again.

11. Now Batsound has installed but it won't work. For that we need an older WINE compatible version of the C++ package and we're going to let crossover install that for us.

12. Select the bottle again.


13. Click on install windows software.

14. This time, when you click on select an application to install, type 'visual' into the search box. A lot of options will turn up, but select Microsoft Visual C++ (10.0) Redistibutable, and then click Continue.


15. And then click install.


16. Crossover will first install an xml parser and you need to enter a name (can be made up if you're feeling cheeky).



17. And then the Redistributable will install. Click yes to reading the terms and conditions.


18. If all that goes according to plan, then once that has installed, Batsound should run. Click on your bottle, and then double click the Batsound icon.



All functions seem to work so far, the export graphics option will export a file but it will be empty. I assume there are other graphics libraries that are needed somewhere along the line. Even the audio playback works.

Anyway, this is how I've gotten it to run. If you want to try it I strongly suggest that you download both the demo copies of Crossover and Batsound and try those first before buying either. Oh, and I've not tested it on a Mac, only Linux, but I'd be interested to hear how that goes from any mac users out there.



Wednesday, 29 June 2016

Bat data and GIS

There is still some way to go with seamless integration of GPS data and sound capture data, but the new release of Map-a-Bat Pro goes some way to addressing that. Many detectors now either have built-in GPS or GPS as an optional add-on, and being able to extract that data and map it allows you to locate and map your bat contacts. Not only does this help with surveys, but by using the data with free GIS tools such as Google Maps and Quantum GIS can help you to identify flight lines, important habitat patches and better understand species' habitat preferences.

The workflow for extracting GPS information can sometimes be a little challenging (Google Earth can be a bit annoying in this respect) but the rewards are great, and a little time investment in understanding how to process the data can save a lot of time in the future and add great value to project reports.



From map-a-bat promo material from Wildwood Ecology.

Thursday, 23 June 2016

Auto-identification software.

Last week I ran two workshops for BCT on bat identification. The first whole day workshop was looking at manual identification of bat echolocation. We looked at call characteristics and how we need to understand issues such as directionality, attenuation and analysis protocols to understand what is going on - basically to 'read' a sonogram for the story it tells. Most of this was done through Batsound, which I still think is the best single package for sound analysis, though it does lack some of the other features such as GPS extraction (though I believe the new version of Batsound Touch can do this in some form - it can certainly tag sound files with GPS location anyway).

The second whole day workshop was looking at automatic identification and some of the packages that can be used to do it. We reviewed the principles behind it, some of the assumptions it makes, then looked at the range of software available. We then focussed on Wildlife Acoustics 'Kaleidoscope' and Biotope's 'Sonochiro'. We ran the same sets of sample calls through each and looked at how we interpret the outputs. The participants then had an opportunity to try each of the packages themselves on sets of pre-identified calls and also on some standard field data from a range of different hardware types. Thanks to both Wildlife Acoustics and Biotope for the training licences for each.

In general we found that both packages were pretty good at picking out pipistrelles, though identification of other species was variable. The take home message was really that these packages help to scan huge volumes of files and identify species of interest, but those files then really have to be manually checked, or at least a sub-set manually checked for validation.

This is pretty much what BCT recommends in some guidelines it has published on its website. With fifteen people on each course, it was a great opportunity to explore bat identification. I certainly learnt a lot, and I was running it. We're running it again in September.

Wednesday, 22 June 2016

Bat call broadcasts.

For training purposes, I've been using the Pettersson D1000x to play back previously recorded bat calls so that participants at workshops can then listen through heterodyne, frequency division or even time expansion to practise using bat detectors. The calls have been broadcast through an L400 loudspeaker which is pretty good even up to 100 kHz.

Being a 'belt and braces' sort of person, I was always worried that if the technology decided not to work one day, then the whole workshop would be wasted, so I looked around for another way of broadcasting high frequency .wav files. I initially tried LabVIEW, but the problem with the version I had was that it wouldn't accept .wav files with high sampling rates, so you had to read in the file in other ways, which was cumbersome. In the end, I found a quick and easy way in Matlab.

You will need the Matlab base package, and the data acquisition toolbox. You will also need a compatible data acquisition card capable of Digital to Analog output of about 500 kHz. I use a National Instruments USB-6251 box. You will need a suitable high frequency loudspeaker and some original files to broadcast. If they are time expanded you will just need to put in a little function to raise the sample rate back up 10x (be careful that your card can handle arbitrary sample rates though as 44.1 kHz becomes 441 kHz which some cards may not be able to deal with).

The Matlab code is really ridiculously simple, and easy to adapt to different cards or situations.


% Matlab .m script to select a .wav file and then play that file back


% through a USB D/A Device - in this case a NI USB-6251.


%


% GUI commends to select a file and get the path to that file


[filename pathname] = uigetfile({'*.wav'},'File Selector');


fullpathname = strcat (pathname, filename);


% Use audioread to open the file identified from Pathname: Note that will


% not open batsound .wav format files. Use Batsound to open them and then


% save as standard .wav files first.


[Wave_File, Fs] = audioread(fullpathname);


% Fs is the sample rate it gets from the .wav file. Report it.


Fs


% Plot an oscillogram of the signal to check it has loaded properly.


plot(Wave_File)


% Plots the sonogram though the frequencies aren't right. Currently commented


% out as it takes ages for long files. The y axis option swaps the x and y


% axes to put frequency up the side.


% spectrogram(Wave_File,128,120,128,1e3,'yaxis')


% Reports which devices are found - ni: National Instruments USB-6251 (BNC)


% (Device ID: 'Dev1')


devices = daq.getDevices


% ni is the device label, creates a session.


s = daq.createSession('ni')


% Set the sampling rate to that of the loaded .wav file


s.Rate = Fs


% Add a D/A Output channel. Dev1 is the device and ao0 is the analog output


% channel: 1 2 channels ('ao0','ao1')


addAnalogOutputChannel(s,'Dev1','ao0','Voltage')


% Loop ten times. Change if you want more or less.


for lp = 1:10


% queue the data to the D/A device


queueOutputData(s,Wave_File)


% Start the output of the data and return command to matlab when done


startForeground(s)


end

One day I might get around to writing a nice GUI for it, but this works very well as it is.































Tuesday, 5 April 2016

Pettersson M500-384

Pettersson have just released a new version of the M500 ultrasonic microphone, the M500-384.  While this has a lower sampling rate than the standard M500 at 384 kHz rather then 500 kHz at 16 bit resolution, it can be used on a number of different devices.


The key feature is that a range of operating systems will detect the device via the USB port as a standalone USB microphone, so there is no need for custom drivers. All you need then is an app or program that will support 384 kHz sampling rates.


Audacity should work on all available platforms such as Linux, Mac and Windows. For android, a number of apps have been tested as working, and will provide either recording only, or recording plus a scrolling sonogram, screen.


USB Audio Recorder Pro will record directly from the device but not show you what you are recording or give audible feedback.
Bat Recorder is a fully fledged app that works with USB microphones and gives a nice sonogram, display. Importantly, this app allows the audio monitoring of bat calls, making it function like a normal bat detector.
USB Bat Detector also works but is reported to currently have some issues.






While this device will work with a range of devices, it requires the device to support USB OTG, which is where the device can act as both master and slave. There are apps on the Google Play Store which will test whether the device can support OTG,


This looks like a very nice device that can be used in a whole range of different situations. One thing to note is that you will still need some form of software to analyse the recordings. These applications will record and also display during recording, but will not allow you to review an analyse the signals, you will still need something like Batsound or the new Batsound Touch for that.