Click here to Skip to main content
14,605,816 members

Easy MP3 Recording (also using iTunes)

Rate this:
4.58 (4 votes)
Please Sign up or sign in to vote.
4.58 (4 votes)
28 Aug 2010CPOL
Class library and working program allowing you to easily record MP3, wav and raw pcm files. Can also integrate with iTunes.


A year ago, my sister and I wanted to make Mp3 back-up copies of everything we had bought on iTunes. So I wrote this program and posted an article on it. However, the program itself was complicated to use and cumbersome in its code as I never bothered to clean up the code once I had finished programming. However, recently it became necessary for me to produce an easy-to-use version. So, while I was improving the design of the application, I thought I'd improve the code as well. As a result, I have produced a library with three useful classes in it (and some helper classes used internally). The two classes are Recorder and iTunes Recorder Extension. Recorder is the base recording class that uses the Istrib libraries (available from here) to record stuff. This can easily be incorporated into any application that wishes to record stuff. iTunes Recorder Extension is more specific as the name suggests. This class provides an easily used object that links iTunes and its libraries with the Recorder class and Istrib libraries.

Using the Code

To use my code is very simple. You need simply to create a Recorder object or iTunesRecorderExtension object. Then setup a few objects and call one of the Start functions.

For this article, I will deal with the iTunesRecorderExtension object as that is what is used in my application though the Recorder class is available and just as easy to use.

To create an iTunesRecorderExtension object, simply do the following:

iTunesRecorderExtension TheRecorder = new iTunesRecorderExtension(true, "A Folder Path");

There are two parameters:

  • DoUseLog - bool
  • ALogFolderPath - string

DoUseLog should be true if you wish to use my Log class. A Log object is a simple way of reading and writing from a text file but in a log format. When you tell the log to write an entry, it automatically adds the long date and time and splits records up so it can be easily read. If you want to use a log, you must also pass it a Log Folder Path. This is a string containing the path to the folder you wish the log to be stored in. For the iTunesRecorderExtension, there are two logs; the Recorder log which comes from the underlying Recorder object and the Application log which comes from the iTunesRecorderExtension and stores information. The Recorder log records when recording starts of each track and what track it was. Also, any errors that the Recorder object encounters are logged. The Application log records when overall recording starts and finishes and also any errors the Recorder object passes back and its own errors.

To use the class, you must do three things:

  1. Select the SoundCaptureDevice
  2. Give it a folder name to store the recorded track in
  3. Tell it to record

To select a sound capture device, you should use a combo box on screen as working out which device has got sound playing on it and which are simply other unused sound cards, etc. is not supported.

The following code adds the available devices to a combo box and could be put in a load function at the start of the application:

List<object> Objects = new List<object>(); 
for (int i = 0; i < TheRecorder.AvailableDevices.Count; i++) 

The following code transfers the users' selected device to the iTunesRecorderExtension object:

TheRecorder.Device = (Istrib.Sound.SoundCaptureDevice)

To tell the iTunesRecorderExtension object where to save the recorded track, you need one line of code:

TheRecorder.OutputFolder = OutputFolderBox.Text;

The file name is worked out automatically. The files are also sorted by subfolders. The top layer is the Artist, the next subfolder is the Album and in that the track is stored. (Note: If the Artist and or Album is blank/null, they are set to the text 'Blank'!)

Finally you must tell the iTunesRecorderExtension to record. This can be done in two ways, one records immediately and one waits till a designated time to start recording and another time to stop recording. The second way I developed because it meant I could record overnight without having to stay up!

The first way is as follows:


(Note: Even if you have already set the sound capture device, it must be passed again to make sure that one has been set.)

The second way is just as simple with only two extra parameters, StartTime and EndTime. StartTime is the time (accurate to hour and minute, not day or second) that you want recording to begin. EndTime is the nominal time you want recording to end. Recording is told to stop at this time, however, recording continues until the track playing when the EndTime is reached has finished. This ensures that you don't get only half a track recorded, however, if you are recording long audio books, you may want to work out what time recording will end before setting the EndTime!

The code for starting and ending looks like this:

TheRecorder.StartWaiting(dateTimePicker1.Value, dateTimePicker2.Value, 


It's that easy! ;D

Some other properties that I have included are Recording and Waiting. Recording returns whether the application is still recording even if the EndTime has been reached/passed. Waiting returns whether the application is waiting for either a StartTime or EndTime to be reached (no distinction is given).


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ed Nutting
United Kingdom United Kingdom
No Biography provided

Comments and Discussions

Questionerror while run the software Pin
Member 1052461414-Jan-14 22:00
MemberMember 1052461414-Jan-14 22:00 
Questioncant get the application to start Pin
clwprogrammer14-Aug-11 12:23
Memberclwprogrammer14-Aug-11 12:23 
AnswerRe: cant get the application to start Pin
Ed Nutting20-Aug-11 21:00
MemberEd Nutting20-Aug-11 21:00 
GeneralRe: cant get the application to start Pin
clwprogrammer20-Aug-11 21:37
Memberclwprogrammer20-Aug-11 21:37 
GeneralRe: cant get the application to start Pin
Ed Nutting20-Aug-11 21:48
MemberEd Nutting20-Aug-11 21:48 
GeneralDownloads do not work Pin
Johann Krenn27-Aug-10 23:16
MemberJohann Krenn27-Aug-10 23:16 
AnswerRe: Downloads do not work Pin
Ed Nutting28-Aug-10 3:14
MemberEd Nutting28-Aug-10 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 27 Aug 2010


16 bookmarked