Compression

Sound files come in two distinct flavours, linear and compressed. Linear files are .wav and family, while compressed files include .mp3 and others. The main difference is that you can directly edit a linear sound file, each value in the simple time ordered list is a amplitude value (sample) for that sound. Compressed formats are composed of frames. Even if you can get an edit directly on a frame boundary the results are often terrible clicks because the uncompressed (recovered) value of a frame depends on its predecessors, hence arbitary frame sequences may be illegal. The prefered method in all cases is to convert to a simple time domain form , then edit, then convert back to mp3.

Editing

Practical editing to achieve your first goal, trimming, is called auto-trimming. The Windows application Sound Forge (which also imports and exports .mp3 files) has a very nice built in function to remove silence. You should also look at the open source Audacity which is scriptable in Lisp. Audio editing terminology is generally 'cutting' a piece of audio out and 'splicing' a piece of audio in. 'butt joins' (pure concatenation) is rare, usually you will use a crossfade. The parameters of each audio segment are therefore, start time, end time, and a transfer function which says how the clip you have cut will fade into the next. Removing silence works by scanning the file to find the rms (root mean square) of lowest average signal level, the noise floor, and chop out all the bits where the signal falls below this. You can get special plugins that are very effective at doing this on voice signals (for exactly your stated application ). My gut instinct is _not_ to try signal processing in Perl, but I haven't tried it (yet) and don't speak from experience. For batch processing offline files it might be effective but slow.



Note: using a very high threshold as a parameter to auto-trimming has an interesting side effect... you actually remove the silences between words and alter the timing of spoken phrases, normally (for TV and Radio) this would be totally unacceptable, but as a study aid the upshot is that you get much better retention because the timescale of the entire lectures salient features is possibly 20% or less of the original.

In reply to Re: MP3 Concatenation by andyf
in thread MP3 Concatenation by dimar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.