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)?."

31 of 278 comments (clear)

  1. Audacity? by techsoldaten · · Score: 4, Informative

    I don't know if this is really what you are looking for, but Audacity is what I would look at. Perhaps a custom module could be written to handle random samples.

    M

    1. Re:Audacity? by krog · · Score: 5, Funny

      I think what this guy is looking for is a CS student who will write it for him. This is how academia works.

    2. 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.

    3. 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?)

  2. Yeah I know a program by BillsPetMonkey · · Score: 4, Informative

    Audacity and a relatively simple plugin. Open source software is good like that.

    --
    "It's not your information. It's information about you" - John Ford, Vice President, Equifax
  3. Simple... by Anonymous Coward · · Score: 5, Funny


    Pick up Microsoft Visual C++ then look at their time and sound librar.. uh.. oh.. IT colour scheme hurt brain... cannot continue.. blarerhfdsl jjjjjjjjjjjjjj fjwkef

  4. Easy... by xsupergr0verx · · Score: 5, Funny

    Ask P-Diddy.

    He frequently samples other artists' work and then makes millions. Reminds me of an archived Onion article, which you now must pay for

    --

    Click here for a free picture of an iPod!
    1. Re:Easy... by Nick+of+NSTime · · Score: 4, Funny

      P. Diddy's testimony at his trial was a sample of OJ Simpson's testimony with Puffy's "Unh, yeah" recorded on top.

    2. Re:Easy... by Valiss · · Score: 4, Funny

      "No, see, OUR recording goes ding ding ding dada ding ding, ad ding ding ding dading ding. It's different."

      --

      -Valiss
  5. Use mp3split by mrAgreeable · · Score: 5, Informative

    Sounds like a job for a really simple shell script driving mp3split. Sounds a lot easier than a custom chip!

  6. 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.

    1. Re:Privacy concerns... by Anonymous Coward · · Score: 5, Funny
      It would be pretty embarrasing to have to explain this:
      Voice1: Yeah, I'm the director. I can get you a part.
      Voice2: Really?! This is so exciting!
      Voice1: Of course, you'll need to auditi--
      [snip]
      Voice1: eah baby, suck it. Oh yeah!
      Voice2: Mmmmmffff!
      Voice1: Oh yeah! Oh yes! God yess!!!
      Voice2: Mmmmfff! Mmmf mm!
      Voice1: Yes! Yes! I'm cu--
      [snip]
      Voice1: --s the best ever. Now it's your turn.
      Voice2: Oh, I like a man who returns the favor..
      Voice1: Hey, what's this.. WHAT THE FUCK!?! HOLY SHIT! YOU'RE A GU--
      [snip]
      Voice3: I can't believe you fell for that!
      Voice4: We all knew. Are you fucking blind?
      Voice3: Hahh! hah! ha!
      Voice1: SHUT UP!!
      Voice2: I thought you knew.
      Voice1: Fuck you, dude!!
      Voice3: Did he tell you he's a director?
      Voice2: Yeah, does this mean I'm not getting the part?
      Voice3: HA!! ha ha ha!!
      Voice2: What's so funny?
      Voice4: Dude, he works in a seven ele--
      [snip]
      Voice1: --unches like a guy.
      Voice3: HA!! HA HA!!
  7. This is really simple by Anonymous Coward · · Score: 5, Informative

    Jump to a a random offset, look for the sync-word, copy a number of frames, repeat. The MP3 format is made of frames, there is no per-file header and since the format is designed to be used in streaming applications and to be robust against errors, you can jump right to the middle and grab a couple of frames without worrying about the rest. Many webpages have the frame spec. Here is one.

  8. Modified PyMP3Cut? by AceMarkE · · Score: 4, Informative

    Perhaps something based off of PyMP3Cut ? I haven't used it, but the description seems pretty relevant ("PyMP3Cut was designed to slice high quality MP3 recordings of day-long congresses into smaller per-speaker MP3 files. It only needs the exact same amount of disk space as the original file to slice, even less if you plan to skip some parts, which PyMP3Cut can do automatically if you use a specially formatted *SKIP* entry in your timeline. It was successfully used many times against several hundredths megabytes MP3 files.").

  9. 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.

    1. Re:DON'T DECODE by LnxAddct · · Score: 4, Informative

      Even with the interframe bit reservoir you only need to pull out a maximum of 9 frames to have playable audio.
      Regards,
      Steve

  10. really random by Doc+Ruby · · Score: 4, Funny

    If they're desperate enough to use your program, they don't have to "40 save a and b to a table". The odds that they'll get the same random number again are lower than the probability that they'll use the program ;).

    --

    --
    make install -not war

  11. Not difficult by Effugas · · Score: 5, Informative

    MP3 is a bitstream, so you can basically use the language of your choice to seek to arbitrary offsets, slice wherever you like for as long as you like, and whatever frames are broken will simply not get decoded. You may of course want to actually have on-frame-boundry edits (they generally sound better and play more reliably, especially on ipod which doesn't have great stream reassembly code). cutmp3 can work:

    http://www.puchalla-online.de/cutmp3.html

    There's lots of pure windows code to do this too:

    http://www.programurl.com/software/cutter.htm

    But if you want to code this yourself, there's some excellent Perl libraries for managing MP3:

    http://search.cpan.org/~nuffin/MPEG-Audio-Frame- 0. 08/Frame.pm

    (and most directly speaking to what you're working on)

    http://search.cpan.org/~ilyaz/MP3-Splitter-0.02/ Sp litter.pm

    It's not too bad to use Perl either, especially with the Perl Packager. Given only one host with the full Cygwin Perl install, you can create compiled executables that encapsulate everything you need down to a single file. It rocks!

    http://search.cpan.org/~autrijus/PAR-0.85/script /p p

    I imagine though that you'd eventually want to only analyze random chunks that contain speech, or at least speech like frequency distributions. This is trickier, and I don't know if there's Perl code to do it. Maybe you could investigate Praat's internal scripting language?

    http://www.fon.hum.uva.nl/praat/

    Praat is pretty mind-bogglingly cool -- it's worth checking out no matter what.

    --Dan

    P.S. Yes, I've been working on some mildly related stuff. How could you tell? :-)

  12. Re:Still big brother by schodackwm · · Score: 4, Interesting
    Amen....

    the OP said as much

    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...').

    compare, for example, to the latest (federal) medical privacy rules, www.hhs.gov/ocr/hipaa/

    --
    [this sig has been trunca
  13. what batteries do you use? by mantera · · Score: 4, Interesting

    You ask a person to carry an 18 hour voice recorder... I'm just curious what batteries you use.

  14. 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
  15. Just ask the RIAA by TrevorB · · Score: 4, Funny

    Just ask the RIAA. They've got some great software for taking an MP3, extracting bits of the file, and replacing the rest with (loud) white noise. Should be perfect for your needs.

  16. Re:Java? Python? PERL? by Fastolfe · · Score: 5, Informative
    This made it on the front page? Lame.

    Agreed..

    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.

    Or five minutes in Perl with MP3::Splitter:
    perl -MMP3::Splitter -e 'mp3_split($_,{},[ rand(64800), 30 ], ...) for @ARGV' filename.mp3
  17. 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...

  18. Re:Java? Python? PERL? by revscat · · Score: 5, Funny

    Me: 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.

    You: perl -MMP3::Splitter -e 'mp3_split($_,{},[ rand(64800), 30 ], ...) for @ARGV' filename.mp3

    I would like to take this opportunity to say that Perl guys are smartasses.

  19. I refuse to help this dude by phearlez · · Score: 4, Funny
    simply based on the pretention overload in the first paragraph of the article:

    James Pennebaker and I developed the method at the University of Texas at Austin at the end of the last century.

    Oh you mean FOUR YEARS AGO? Bunghole.

    --
    Bad management trumps ideology - Show the world you want better leadership. http://www.timefornewmanagement.com
  20. Here's a nice elegant hack. by MadFarmAnimalz · · Score: 5, Funny

    Use small Windows-based devices and don't give it any further thought. The OS will crash at random (you don't have to pay extra for this, it does it out of the box), thereby giving you the fragmented recordings you seek.

    On the other hand, you could do it with an embedded linux device too; the frequent battery changes will have the desirable effect.

    Okay I confess I wrote this post to confuse the moderators into inaction; he's bashing windows -- no, he's bashing linux -- oh FUCK what to do...

    The correct moderation, gentle mod point merchant, is `funny'.

    --
    Blearf. Blearf, I say.
  21. Re:Java? Python? PERL? by juan2074 · · Score: 4, Funny

    Alright, everybody. Stop posting. It looks like we're done here.

  22. Re:flame bait by DennisInDallas · · Score: 5, Funny

    You can't run Open Source code on Windoze without destroying the American way of life!, pinko

  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
  24. mpgedit is what you want by zot+o'connor · · Score: 4, Informative

    This is what you want:

    mpgedit has a -e flag so you could do

    mpgedit -e 1:20-1:30 -e 600:20-601:10 -f file.mp3

    Would grab from 1 minute 20 seconds to 1 minute 30 seconds, and from minute 600, 20 seconds to minute 601, 10 seconds of file.mp3 into file_1.mp3 and file_2.mp3

    I use it to cut the 2 hour mp3 of the bbc news hours into 5 minute chunks so my mp3 player will let me skip segments.

    With a bit of scripting you could do random cuts of any size mp3.

    It claims to work under windows, but I have not tested it there.

    --

    --
    Zot O'Connor