tags:

views:

929

answers:

4

I want to make a program that takes an MP3 file and breaks it into many smaller mp3 files based on 1-2 seconds of no sound (silence). What is the easiest way to do this in c#?

+1  A: 

Having a solid knowledge of the file's binary format would be a good place to start. That done, you'll know what silence looks like in the file. You may have to define exactly what silence is. Presuming that, like most audio, it started from an analog source, there's almost certainly some noise buried in the "silence". What will your tolerance for ambient/background noise be?

Once you know what you're looking for, just scan through the file, looking for "it".

Simple ...

Adrien
+1  A: 

Bass library. Bass has everything you need. It can access, record and edit media streams like mp3s, allowing you to sample the volume at different time points. It has a .net api, so you can use it in c#. Unfortunately it does cost money if you are using it for a commercial application, but they do provide a free non-commercial license.

Sox is a command-line tool which has an option to split an mp3 on n seconds of silence. You could always use the system command to call sox from c#.

Other related links.

Ripping a CD to mp3 in C# - third party component or api out there?

Audio Libraries for MP3 editing

How do I merge/join mp3 files with c#

This code shows a way to make a CD ripper in C#. There are APIs from some vendors that allow reading audio CD tracks but it is also possible to do it using APIs that allow low level access to CD drives such as ASPI from Adaptec or IOCTL control codes. The latter method is used in this case, because there is no need to install any third party software, it is completely covered by Win32 API functions.

http://www.codeproject.com/KB/cs/csharpripper.aspx

e5
+1  A: 

A program to do this already exists:

http://mp3splt.sourceforge.net/mp3splt_page/home.php

+1  A: 

Splitting the MP3 stream will be difficult to do with any degree of precision. The compressed MP3 data exists as sequential chunks of audio data comprised of many samples. The easiest way to perform this would be to decode the stream either progressively or in its entirety, perform your manipulation, then re-encode it (which as I understand is how most jukebox software does it)

Tullo