Slashdot Mirror


Sampling Short Sequences From Long MP3 Recordings?

mehl writes "I am a professor for social psychology at the University of Arizona and I am looking for help with finding / developing a special program. In my research, I ask participants to carry around a digital voice recorder while they go about their normal lives. The voice recorder then tracks the ambient sounds in their environments and produces an 'acoustic log' of a person's day. We then use these ambient sound recordings as source data for various person perception studies. For privacy reasons, we are required to sample brief snippets of ambient sounds instead of recording an entire day continuously ('Big Brother is listening to you...'). So far, we have achieved this by modifying the hardware of a digital voice recorder (triggering it with an external microchip). With the high turn-over in player models, however, this strategy has turned out to be short-sighted (every half a year we have to build a new chip). I am thinking about switching strategy, recording continuously in the first place (no problem with the current generation of flash memory) and then sampling (random) snippets after the fact from the continous recordings. Does anybody know of an existing program that can randomly (or pseudo-randomly; e.g., 30 sec every 10 min) and automatically sample short sequences from a day-long (18 hours) mp3 recording? What would it entail to develop such a program (for Windows)?."

26 of 278 comments (clear)

  1. Still big brother by Anonymous Coward · · Score: 1, Insightful

    You'd be making a full recording though... wouldn't that still qualify as personal invasion.

    1. Re:Still big brother by Lord+Kano · · Score: 2, Insightful

      To be honest, if I were involved in something unsavory that day, I wouldn't return their recording device.

      LK

      --
      "Hi. This is my friend, Jack Shit, and you don't know him." - Lord Kano
  2. Privacy concerns... by Drewskee · · Score: 4, Insightful

    If I was a participant in this research I think I would be more concerned with my privacy if they were physically recording everything and then just 'randomly sampling' what they needed later. Having the trigger physically on the player seems much more reassurring. But hey, maybe I'm just paranoid.

  3. Perl can by Anonymous Coward · · Score: 2, Insightful

    Download the MP3 Module, RTFM and do it!

  4. Java? Python? PERL? by revscat · · Score: 3, Insightful
    This made it on the front page? Lame.

    Does anybody know of an existing program that can randomly (or pseudo-randomly; e.g., 30 sec every 10 min) and automatically sample short sequences from a day-long (18 hours) mp3 recording? What would it entail to develop such a program (for Windows)

    10 a = rand number
    20 b = a + 30 seconds
    30 open MP3 with appropriate sound API, get sound between a and b
    40 save a and b to a table so you don't use those values again
    50 goto 10

    Why does this seem absurdly simple to me? I think just about any modern language with a decent set of libraries will be able to handle this, if there isn't a shareware app out there already. In any case I couldn't imagine that it'd take more than half a day or so to do this in Java or Python.

    1. Re:Java? Python? PERL? by mandos · · Score: 5, Insightful

      Why does this seem absurdly simple to me?

      It probably probably sounds simple to you because it is. However, this professor said that pyschology was his field, not computer science or programming. I personally think it's great that someone that far out of a tech field has found an useful application for modern technology AND that he decided to check with those most likely to understand the finer details of the techonology. Maybe /. isn't the best place, but I think it's great that he's trying to combine a couple of fields of study to develop something new.

      --
      Mike Scanlon
  5. ...recording continuously in the first place... by FerretFrottage · · Score: 2, Insightful

    Doesn't this void your privacy requirements you previously mentioned. I understand you want to grab short samples after the fact, but you'll still have access to all the continous data to begin with.

    --
    "Look Lois, the two symbols of the Republican Party: an elephant, and a fat white guy who is threatened by change."
    1. Re:...recording continuously in the first place... by GreyPoopon · · Score: 2, Insightful
      Doesn't this void your privacy requirements you previously mentioned.

      For those of you with privacy concerns and questioning the use of Windows for the target platform, I'd like to submit that maybe the intent is to let those participating in the study run the program to extract the desired snippets and send them in, which mitigates somewhat the privacy concerns and probably *would* require that the app run on Windows.

      Not trying to point the finger at FerretFrottage...just a convenient reply point...

      --

      GreyPoopon
      --
      Why is it I can write insightful comments but can't come up with a clever signature?

  6. Why the artificially imposed limit of Windows only by djh101010 · · Score: 2, Insightful

    This is the sort of application that screams for a script, rather than some sort of drag-n-drool GUI windows-ish thing. There are several audio sampling and processing utilities over at sourceforge.net, which would be suitable for this sort of thing.

    Maybe it's because my background is in the *nix world, but it'd be a half-day project to get this up and running done on a *nix box with something free from sourceforge.

    Usually one wants to design the solution to fit the problem, not to introduce more complexity by limiting what the solution can be chosen from. Doesn't seem to be the case in this guy's project. I also can't imagine finding audio sampled snippets of someone's day all that interesting, but I'm sure there are people who enjoy that sort of thing?

  7. DON'T DECODE by interiot · · Score: 4, Insightful
    Whatever solution you choose, just note: YOU CAN DO THIS WITHOUT DECODING AND RE-ENCODING.

    If you set things up properly (namely limiting the use of the interframe bit reservoir), then there are many utilities which will allow you to pull out specific frames from within an MP3 file. This should both be much faster from a processing standpoint, and not incur more data loss from two encodings.

  8. Re:MP3 chunks? by stratjakt · · Score: 2, Insightful

    dd if=(my mp3) of=(sample file) bs=(mp3 frame size, or size of "one second" of audio) skip=(start from) count=(duration)

    There you go. Write some script to make up the values in parentheses.

    On to tackle the next great engineering mystery of computer science. Maybe I'll solve some of those NP-complete problems, or install one of those really sweet case fans that light up when the music plays!

    --
    I don't need no instructions to know how to rock!!!!
  9. Exactly... by moxiez · · Score: 1, Insightful

    ... the reason why I couldn't handle college and dropped out. Dumb ass profs like this... Please explain the value of this? What happened to teaching people things they could use? Geez, and I wonder why other countries kick our asses when it comes to education??? /rolls eyes

  10. I don't think this meets your privacy standards... by barfy · · Score: 3, Insightful

    The recordings exist. Just because you will somehow post process them, I don't think you have really met your standard of not recording the whole day.

    Would you submit them under subpeona? Will they be destroyed? When? How?

    I think anybody in the CS dept could write the program you require. But I am pretty sure you are going to have to keep coming up with a way to do this "pre-record". And exactly why is it so hard to just buy *enough* recorders?

  11. Re:MP3 chunks? by The+Bungi · · Score: 2, Insightful
    Yah, and you can get dd (and most all other GNU tools) for Windows from here, or by installing Cygwin.

    Problem solved. Next!

  12. Why change hardware? by laird · · Score: 2, Insightful

    I don't understand why he'd need to change the hardware every six months. Sure, there are new MP3 players, but as long as they've implemented on a model that is sufficient for their work, who cares whether there are newer models out (other than that old models will get cheaper, which is nice).

    And the idea of recording an entire day and sampling seems terrible in terms of both privacy and efficiency. If you can record a day's samples in a $75 MP3 flash-based player plus a tiny circuit that randomly presses the record button twice every so often, why bother using a $400 hard-drive based MP3 player, recording an entire day, then copying that day to a desktop computer, then sampling out random tiny bits of the day.

  13. A use for undergrads by kegegg · · Score: 2, Insightful

    This sounds like a great opportunity for an undergrad student. Most undergrads CS/EE at top universities, etc. would have been able to write this as a freshman in high school. As an undergrad myself, I've been employed at an acoustics lab writing scripts in matlab, C, PHP, etc. to do this sort of thing. Cheap labor, exellent results. They'd love to work for references and beer money and can develop custom idiot-proof software. Just post a flyer or post to the CS newsgroup.

  14. Don't be so hard on this guy... by jonasmit · · Score: 4, Insightful

    He is a professor of social psychology not a software developer - give him a break. For an average developer this would be a very simple task - a few days at the most for a simple command line tool or sparse GUI app (Algorithm would be quite simple and all modern languages would support the features you need). You could look for an online forum where developers bid on projects like this for extra money. Usually these sites (Somebody post one I can't remember any of them now but a google search might help you) are very low cost solutions for simple one-off applications like you need. But, since you are part of a University I would contact the CS or IT department and see if there are any Undergrads who would like a small project to make some extra money and/or put on their resume. This would also help solve the problem of setting up your computer to make sure the code works properly (minor configurations would be necessary). Hope all goes well...

  15. Re:Audacity? by Anonymous Coward · · Score: 3, Insightful

    while true do
    dd if=/dev/sound bs=[size of 10 second sample] count=1 | gzip -c >> output.raw
    sleep [time between samples]
    done

    Whaddya mean, you must use windows at any cost?

  16. Re:Audacity? by sp0rk173 · · Score: 4, Insightful

    Which gives the CS student experience to put on his/her resume, and helps forward the research of the non-coder academic.

  17. Re:Use mp3split by Anonymous Coward · · Score: 1, Insightful

    If you'd actually read the article, the issue was that they wanted a solution that didn't require a custom chip because they needed an updated chip every 1/2 year or some junk due to player/recorder model changes.

  18. Re:I don't think this meets your privacy standards by kilgortrout · · Score: 2, Insightful

    Not to mention that surrepticious electronic recording is a felony in many states(ask Linda Tripp). You may want to contact your law dept. as well as your CS dept. However, I suspect that what you are really studying is slashdot social behaviour and your post is just a ruse to elicit responses. Forget it, we're on to you.

  19. simple solution: lame, shell, dd, and maybe sox by zikzak+muzak · · Score: 1, Insightful

    most people are suggesting something complicated, but this is exactly what the shell and lots of little programs are for.

    1. use lame to decode the mp3 file to raw data

    $ lame --decode -t input.mp3 source.raw

    2. use dd to extract the bytes corresponding to the times you want. assuming you want 1 second clips and the input file is 16 bit 44k stereo, the dd command might look something like this:

    $ dd if=source.raw of=second.raw bs=176400 count=1 skip=30

    the above command will extract the 30th second from your sound and put it in second.raw

    3. if you want to accumulate all the seconds you've extracted, use cat

    $ cat second.raw >>total.raw

    4. writing a nifty little shell script and reencoding back to your desired format is left as an exercize for the reader. (hint: man sox; man lame; info bash)

    You can do all this on windows. just install cygwin. I do a lot of algorithmically generated music and video and i use basically the above approach when all i want to do is make a whole bunch of simple edits of sampled sound. You don't need any sound editing software for what you describe.

  20. customize the mic, not the player.. by pocopoco · · Score: 2, Insightful

    >triggering it with an external microchip). With the high
    >turn-over in player models, however, this strategy has
    >turned out to be short-sighted (every half a year we have
    >to build a new chip).

    Almost every recorder has a noise/voice activation mode and most of the ones I've used had a mic or line-in as well. So just have an external mic -> custom chip that cuts it off when needed -> recorder. I suppose you could crack open the player and get between the internal mic if you wanted to as well. Either way the custom bit will never go obsolete. I record lectures I go to and found quality is much better with a good external mic anyway, even if it's a pocket size one like the small Sony conference mics.

  21. Re:Audacity? by orthogonal · · Score: 4, Insightful

    snip four line shell script that pretty much (except converting to mp3 format) accomplishes what is desired by submitter

    What amazes me is that this precisely the sort of thing to do in software, yet the submitter contends that up until now they've done it with a custom designed and custom built chip.

    I mean, the guys at http://rockbox.haxx.se could do it in about 15 minutes, and provide a GUI on the MP3 recorder.

    Naturally, this is easier to do when MP3 recorders are running open source software, so to an extent this is a rant at all the manufacturers of computing appliances who see a competive advantage in closed source: you lost my purchase, and who knows how many purchases from this professor and while requiring him to shell out even more for a custom chip to do in hardware what is ridiculously easy to do in software (as the parent poster shows by using that complex and little-known software technique, calling sleep()).

    I'm not criticizing the parent: his code does the right and the simplest thing; the problem is with manufacturers whose use of closed source precludes such elegantly simple solutions.

    A big part of the reason that the IBM PC took off in such a big way in the early 1980s was becuase it was open source: not the code to MS-DOS, but the architechtural specification of the hardware itself. This cost IBM money when "clone"-makers were able to produce "monkey copies" of the PC, but that very competetion made PCs much more popular, and soon dominant over other (possivly techically superior) brands like Ape or Amiga. The open specs also allowed a myriad of other companies to offer add-on hardware from co-processors to graphics cards, and even allowed software authors to optimize for the IBM-PC (who here is old enough to remember what peripheral's memory was mapped to address B800, and the advantages to manipulating the data there directly?)

    Did opening the IBM-PCs architecture finally cost or benefit IBM. We'll never know. But it is likely that the PC market, and thus the market for home PCs and peripherals, and software for home PCs and the World Wide Web, would never have been near as big without IBM's decision to open the PC even to competitors.

    Manufacturers of closed-source appliances would do well to consider what they gain, and what they lose by preventing customers from fully using their products. (The careful reader will see that the antecedent of "their" in the previous sentence is ambiguous; the astute reader will understand why: just whose product is it, the company that makes it or the customer who buys it?)

  22. Side question ... by Etyenne · · Score: 2, Insightful

    Since you want to analyze ambient sound, should'nt you be using a lossless codec instead of MP3 ?

    --
    :wq
  23. Is that legal? by suwain_2 · · Score: 4, Insightful

    I'm not sure that your proposed solution fits with your previously-mentioned privacy concerns. Sure, you'll only see a given part, but you're still recording the whole thing.

    It'd be like having the FBI record your calls 24/7, but only listen to them if something came up, or having police be able to raid your house the moment they suspected you, but not look at what they gathered without a warrant. Even if they were completely honest in carrying it out, it's still too Big Brother-ish.

    I think that, if the requirements say you can only record brief snippets, then you can only record brief snippets; not record everything and only listen to brief snippets. While it's the same from your perspective, it's not the same in terms of what's actually happening, and it sounds like it's completely bypassing your privacy concerns.

    If you're already designing an external microchip, why not design a whole little recorder?

    --
    ________________________________________________
    suwain_2 :: quality slashdot p