This afternoon/evening I worked on the python-related part of our project: finding out libraries in python that would allow us to emit samples of beeps at a given frequency, which I would capture with my smartphone.
I came across pygame (handles audio, video, joystick input and other games’ related stuff) which was very handy. I found out simple snippets that let me interact with the audio output in the pygame users’ mailing list and adapted them for my own needs. So far so good, but when I started generating sound by creating audio samples with numpy (yet another powerful python package that handles scientific computing), it came to be very difficult to generate the exact frequency that I wanted: the higher the frequency, the higher the error ratio. I could tell that because I used audacity to analyze the recorded output (a succession of beeps growing from 440hz to 20khz – which is around the ultrasonic target frequency that will be used for the project – that last about 2 seconds each), extract the central frequency at each beep interval. The error ratio increased gradually from 0% to 25% (which I hope wouldn’t be the case in the final prototype).
Am I wrong or numpy isn’t as powerful as I firstly thought? Hopefully I didn’t spend too much time figuring out what was happening (something to do with integer division and its impreciseness) and decided that the way to go was to generate a WAV file with audacity, run it as a pygame.mixer’s Sound object. (see ref: http://www.pygame.org/docs/ref /mixer.html for more detail)
Still, that doesn’t tell me how I can switch from one base frequency to another (I’m not ready to generate a WAV file for each given output frequency since I consider that it is not the brightest solution I’ve ever thought of)
In the mean time, I would like to see whether I can detect the distance between a given source and a given microphone. This I need to figure out how to do it and is my plan for tomorrow. I think it will enlighten us a lot on the on-board solution that WAMI’s team will have to design, although we’ve already discussed this question more than once. It’s time to break my teeth on FFTs, and spectrogram plotting in python.
It’s around 1:00 am now and I didn’t finish up installing cygwin yet on my desktop computer: I gave up installing PCB tools on my old laptop which is far from having good performances (It would take me 8 hours each time I would re-compile a BSD kernel with regular crashes out of heat for a project I had to run last year)
Good night and sweet dreams,