TrackMaker





...now where was I?.· Oh yes!

In recent years I have taken to using my Iyonix to ‘edit’ sound recordings. I use an audio CD recorder (Pioneer PDR509) to record things like concerts from BBC R3. At first I tended to record directly onto an audio CDR, and this was the final version I kept. However I found that I kept wanting to ‘edit’ the recordings to remove unwanted talk or noises before/after the music, and to collect selected pieces on a given CDR. Hence my practice nowdays is to use the recorder to record items onto an audio CDRW disc, then put this disc into the drive on my Iyonix, load the files, edit them, and write the edited results back onto a CDR. I have written some software to help the process. Having been doing this for a while it occurred to me that the details and the program might be of interest to other RO users.

Around four years ago I started writing a series on manipulating ‘sound’ files using a RO computer[1]. At the time I intended to go on to discuss editing and manipulating sound files in various ways. Alas, the series was interrupted by what Harold MacMillan once described as, “Events, dear boy, events!” Since many of you will have the old issues – either in print or on the Archive CDROMs – I won’t go over all of the contents of the previous articles, but you may find them useful if you have access to the old issues.

In what follows I assume you have a RO computer with a drive that can read/write audio CDs, and a copy of !CDBurn (or !CDVDBurn, or some equivalent). This will allow you to load the sound data onto your hard disc, and write any edited output back onto a CDR(W) to play on your audio systems. In this article I will look at the actual process of editing, using as an example the program !TrackMaker. A copy of this should be available with the magazine.

Pic2.png - 182Kb

Fig 1

You are welcome to use it ‘as is’, or to examine it and use the details to help you with any similar processes you wish to perform. Please note, though, that I am one of the world’s worst programmers. So although the program works, it would not win any prizes for being well-written!

First I’ll say how to set up and use !TrackMaker. Then I’ll go on to outline how it works.

Before you can use !TrackMaker you have to create three directories which it requires. These are called CDsnip_in, CDsnip_out, and EditLists. In my case I have put them all in a directory ADFS::HardDisc4.$.CD_tracks. It is up to you where on your hard discs you locate them, but they all have to be in the same directory. The next step is to ensure that !TrackMaker knows where the find them. To do this, type the complete path string into the text file Path which is inside !TrackMaker. Fig1, shows these directories collected in my CD_tracks directory, and the location and contents of my !TrackMaker.Path file. Once you have set up the above !TrackMaker can be run in the usual manner for an application.

Any sound files you wish to process should be put into the CDsnip_in directory. If you are taking these from an audio CD using !CDBurn then they should be saved as ‘data’ files, not ‘wave’ format files. I use !PlaySound to listen to the sound files. This also displays the duration of the file in mins/secs and the time of the instant being played. Hence I use this to determine the times at which I want the input file to be split into tracks.

Pic1.png - 389Kb

Fig 2

Figure 2 shows an example. I have listened to the sound file C2 and decided that I want to break it into tracks that start at 2mins 52secs, 6mins 35 secs, 10 mins 11secs, etc from the start of C2. I then type these values into a text file which I save in the EditLists directory. Note that the edit list has the same file name as the sound file to be processed. Also note that the format of the list of times in the EditList file. Each line specifies one of the times, in sequential order, with two digits for the number of mins, a space, then two digits for the number of seconds into that minute.

A double-click on !TrackMaker opens up a task window and the program asks for the name of the file to be processed. Enter this and press <return> in the usual way. The program then processes the sound file and puts the tracks into the CDsnip_out directory. The names used for the output files being taken from that of the input, but with a suffix which indicates which track in the sequence it represents. The tracks can now be written back onto an audio CD. If you write them ‘disc at once’ in sequential order the result should have no audible gaps or clicks. Hence the only sign when playing the audio CD is that you now have track number markings at the chosen times.

I use !TrackMaker to add track start locations at convenient places – e.g. just before the start of each movement in a symphony. I also use it to snip away sections of talk, etc, before/during/after the music so I can then just write the music I want onto an audio CD. This means I can, for example, record a part of a Radio 3 concert by leaving the CD recorder running for an hour or so. The result is one long track on a CDRW. I then use !TrackMaker to select the sections I want, and write these to an audio CDR. The CDRW is then erased and can be re-used.

One ‘quirk’ of !PlaySound seems to be that it is unable to cope with ‘long’ files. There seems to be a size limit – somewhere between 15 and 20 mins – above which it won’t actually play the sound data file. Also, if you click on its slider to move to another part of the file being played there is a delay which becomes quite long if you ‘rewind’ a long file. For this reason I tend to find it useful to initially use !TrackMaker to snip a long sound data file into 10 minute snippets, then use !PlaySound on each of these in turn to determine the locations where I actually wish to snip the original. I then put these times into the editlist file, delete the 10 min tracks from the CDsnip_out directory, and run !TrackMaker again. I then check the start and finish of each of the tracks to see they are as I require, delete any unwanted tracks, and write the results to a CDR so I can listen to the results on my audio systems. This process has essentially replaced by previous one of recording concerts I wish to keep onto tapes, and gives better results as well as being very flexible.

Pic3.png - 108Kb

Fig 3

Figure 3 shows the settings that !PlaySound require to play the data files correctly. Looking at this, you can also see how it displays the times for the duration of the file and the instant currently being played.

!TrackMaker operates by reading the input file in 1-second ‘blocks’. Each block consists of 44100 sample words. Each sample word consisting of two bytes representing the left-hand channel sample for that instant, and two bytes representing the right-hand one for the same instant. The program keeps a count of how many blocks it has read, and this allows it to know how many seconds of the input file has been read/written. Before it reads/writes the first block it reads the first line of the Edit List and works out how many seconds (blocks of data) should be written to the first output file. It then read/writes these, one at a time, until it reaches the block (time) the edit list line has specified when the next output file (track) should start. It then closes the output file it was using and opens the next one. It also reads the next edit list line to determine how long it should continue writing to this new output file. This process then repeats until the program has read all the data in the input file. It then closes the final output file and stops.

Although the process works with a ‘resolution’ of one second (one block) it also monitors the size of the blocks being read. So if the input file isn’t precisely an integer number of seconds long, the last fraction of a second is correctly read and written into the final output file. In principle, the program could have used smaller blocks and offered a resolution for the track snip times of less than a second. However this would have slowed down or complicated the process, and I felt that 1 second resolution was fine for normal use. Hence the edit list and the program assumes that only integer values for the times will be used. This means that you can only use times like “04 23” in the Edit List to mean “4mins 23sec”. You can’t use “04 23·45” to indicate a split point which isn’t an integer number of seconds along the input file.

The version of !TrackMaker I have given to Paul to provide with Archive was compiled on my Iyonix and runs OK on that. I think it will run OK on other machines, but I have not checked this myself. It includes, though, the source code, so could be recompiled using the ‘Acorn’ C/C++ compiler package on other machines. You are also welcome to use the code if you wish, and it includes some simple comments to identify which procedures do what. That said, experienced programmers will probably use my code as an example of how not to write a program in ‘C’, and then impliment the process in a better way!

All being well, I hope in a later article to cover how to assess the ‘statistics’ of audio tracks, and then to use this to alter them – e.g. to adjust the volume level and make the output louder or softer if you wish. However such processes can be more complex if you wish to do them correctly, so I’ll leave the details to another time.

Jim Lesurf
7th Jun 2006

[1]  
Archive V15 - Issue 3 Page 35, Issue 4 page 35, and Issue 5 page 28

returnblue.gif - 6Kb