Recording With TR


TR is, of course, designed to produce new versions of a piece on a regular basis and make them available to listeners directly via the Internet.  TR uses ogg-vorbis files to accomplish this because they are compact and the finished piece can be easily streamed from the TR server. To make a high quality CD or upload a sequenced piece to Soundcloud, it is better to start with a .wav file format.  This section will describe how to create .wav file copies of TR-sequenced pieces.

The Problem:

In order for TR to sequence a new piece, all the segments must be uploaded via FTP prior to the start of processing.  A typical piece may contain 24 three-minute segments, and if each ogg file segment is on the order of 2.5 to 3 MBytes, that is a total of some  60 to 75 MBytes that must be moved by FTP to the TR server from your composing PC.  This typically takes five to 15 minutes, and is not too inconvenient.  If .wav format files were used instead of the compressed ogg-vorbis files,  the amount of data to be moved would increase by ten times – and it would take hours to upload the segment files to the TR server via FTP.  So in order to create .wav files for the finished piece, some method has to be found to easily move all that source track data into TR.

The solution is use a separate thumb drive to hold the .wav file sequencing program and to load the source track files directly from the PC.  The thumb drive is then removed from the PC, inserted into the TR server, and a new program run to recreate a sequenced piece using .wav files.  When this process has finished, the thumb drive is removed from TR and inserted back into the PC where the .wav files are copied to whatever software you are using to master and copy to a CD.

SR – The TR .wav Sequencer System:

To create a SR .wav file sequencer a second thumb drive is needed.  This should be 8 GB or 16 GB in size.  To create the SR system first format the new drive on your PC with a FAT32 file system using the format commands in Windows Explorer.

When the SR drive is ready, insert this into the running TR server.  Obviously your TR server will need to have at least two USB ports.  Take care to be sure the dimensions of the new thumb drive will let it plug into the second USB port without crowding the existing thumb drive  holding the TR server.

Creating the SR System:

Log into TR as root using Putty.  Navigate to the root directory as follows:

cd /

Create a new directory named hd off the root directory:

mkdir hd

Mount the new thumb drive to the hd directory, as follows:

mount /dev/sdb1 /hd

Now change directories to /hd

cd /hd

You are now on the new thumb drive.  Create the following directory structure there:

mkdir sr

Now change to the sr directory:

cd sr

Make a new cgi-bin directory

mkdir cgi-bin

Go to this new cgi-bin directory:

cd cgi-bin

Now make the following directories:

mkdir S0

mkdir S1

mkdir S2

mkdir sourcetr

The directory structure should now look like the following:


Note: This exact directory structure must be used – including the exact names!  Linux is case-sensitive for directory and file names! 

You need only create these directories once.  But each time you insert the SR thumb drive you will need to mount it to the hd directory from the TR server drive.

Once the directories are in the correct position on the new thumb drive, add the SR program via FTP.  This program is placed in the sr directory of the hd drive.  A listing of the SR .wav file sequencer is shown at the end of this article.  It is a Perl text file and you can copy and past into Notepad and save as  Change the permission to executable as follows:

chmod a+x

Once the permissions are changed on the file and the directory structure is in place, un-mount the SR thumb drive as follows:

umount hd 

Now you can remove the SR thumb drive and insert into your PC.

Using SR:

Re-insert the SR thumb drive into your PC.  You will note that it has the same directory structure as the TR server.  The idea is that is similar to the other TR sequencing programs but now .wav files are used.

To use the SR system, you must create .wav segment files, just like the ogg files used in the TR server.  That means they must be converted from the source midi files directly into .wav format and then edited using Audacity so that each segment is exactly the correct length.  The idea is that you will have the same segment files, cut to the same length – as the original ogg files uploaded to TR via FTP.

The edited .wav segment files are then copied into the /sourcetr folder on the SR thumb drive using Windows Explorer.   This may take a few minutes, but is far faster than uploading via FTP.

Running SR:

Eject the SR thumb drive from your composing PC and reinsert into the TR machine.  Log into TR and remount the SR drive from the root directory:

mount /dev/sdb1 /hd

Now change directories to tr/cgi-bin:

cd tr/cgi-bin

Copy two files to the SR drive:

cp scords.txt /hd/sr/cgi-bin scords.txt

cp staves.txt /hd/sr/cgi-bin staves.txt

Change to the cgi-bin directory on the SR drive:

cd /hd/sr/cgi-bin

Start the program in the background:


You should see the program start – it provides comments to the screen whenever it starts a new section of the code.

You can also track its progress by listing the contents of the /hd/sr directory and watch the .wav files being built.  A 3 layer piece with 24 source segments takes about an hour to build the final .wav file.

Eventually the program will finish and you should see new files in the sr directory:

cd ..

ls -l


trackall.wav is the equivalent of the TR sequence as specified by the scords.txt and staves parameters.  It should be the same as the ogg file that was streamed from the TR web page.You can un-mount the drive, re-insert it into the PC, and copy the wav file into your favorite editor.


SR Program Listing:

Here is the program listing:


# SR1 Sequence Program for wav Files
# This program generates a sequenced .wav piece from an existing coordinate set

# Clean out coordinate folders S0, S1, S2
$Sc = “./”;
system ($Sc);
# Get Configuration data from Files

# Get Stave Info
open (stv, “staves.txt”);
$Nstaves = <stv>;
chop ($Nstaves);

$fps = <stv>;
chop ($fps);

$segs = <stv>;
chop ($segs);
# Calculate number of coordinates needed
$Ncoords = $segs * $Nstaves;
# print (“NCords = $Ncoords \n \n”);

# Player segment file copy program

# Initialize
$I1 = 65;
$SCTR = 1;

# Print to screen
# print (“\n —– Getting Coordinate Sets —– \n”);

# Open scords.txt file
open (CS, “scords.txt”);
# Start loop for segment sets

while ($SCTR <= $segs) {

print (“\n Getting coordinate set $SCTR \n”);

if ($Nstaves >= 1){
$S0Coors = <CS>;
chop ($S0Coors);
chop ($S0Coors);
# chop ($S0Coors);
# print (“S0Coors = $S0Coors \n”);
$Mp = “.wav”;
$SRFN0 = “S0_” . $S0Coors . $Mp;
# print (“Source File 0 = $SRFN0 \n”);
$DF0 = chr($I1) . “D0.wav”;
# print (“Dest File Name = $DF0 \n”);
$Sc = “cp ” . “sourcetr/” . $SRFN0 . ” S0/” . $DF0;
# print (“System Command = $Sc \n “);
system ($Sc);

if ($Nstaves >= 2) {
$S1Coors = <CS>;
chop ($S1Coors);
chop ($S1Coors);
$Mp = “.wav”;
$SRFN1 = “S1_” . $S1Coors . $Mp;
# print (“Source File 1 = $SRFN1 \n”);
$DF1 = chr($I1) . “D1.wav”;
# print (“Dest File Name = $DF1 \n”);
$Sc = “cp ” . “sourcetr/” . $SRFN1 . ” S1/” . $DF1;
# print (“System Command = $Sc \n “);
system ($Sc);

if ($Nstaves == 3){
$S2Coors = <CS>;
chop ($S2Coors);
chop ($S2Coors);
$Mp = “.wav”;
$SRFN2 = “S2_” . $S2Coors . $Mp;
# print (“Source File 2 = $SRFN2 \n”);
$DF2 = chr($I1) . “D2.wav”;
# print (“Dest File Name = $DF2 \n”);
$Sc = “cp ” . “sourcetr/” . $SRFN2 . ” S2/” . $DF2;
# print (“System Command = $Sc \n “);
system ($Sc);
# Increment loop counter
$SCTR = $SCTR + 1;
# Roll loop
$I1 = $I1 + 1;

# Close coordinate file

close (CS);

# exit(10);
# Create Track Files

print (“\n Building track1 file \n”);

if ($Nstaves >=1){
#Sox Command Here
$Sc = “sox /hd/sr/cgi-bin/S0/*.wav /hd/sr/track1.wav”;
# print (“System Command = $Sc \n “);
system ($Sc);

print (“\n Building track2 file \n”);

if ($Nstaves >=2){
# Sox command Here
$Sc = “sox /hd/sr/cgi-bin/S1/*.wav /hd/sr/track2.wav”;
# print (“System Command = $Sc \n “);
system ($Sc);

print (“\n Building track3 file \n”);

if ($Nstaves >=3){
# Sox Command Here
$Sc = “sox /hd/sr/cgi-bin/S2/*.wav /hd/sr/track3.wav”;
# print (“System Command = $Sc \n “);
system ($Sc);

print (“\n Merging Files into Trackall \n”);

# sox mixing commands to build trackall.wav

# Merge Track Files using Sox

if ($Nstaves == 1){
#Sox Command Here
$Sc = “cp /hd/sr/track1.wav /hd/sr/trackall.wav”;
# print (“System Command = $Sc \n “);
system ($Sc);
if ($Nstaves == 2){
# Sox command Here
$Sc = “sox -m /hd/sr/track1.wav /hd/sr/track2.wav /hd/sr/trackall.wav”;
# print (“System Command = $Sc \n “);
system ($Sc);
if ($Nstaves == 3){
# Sox Command Here
$Sc = “sox -m /hd/sr/track1.wav /hd/sr/track2.wav /hd/sr/track3.wav /hd/sr/trackall.wav”;
# print (“System Command = $Sc \n “);
system ($Sc);

print (“\n Mixing Finished! \n”);







%d bloggers like this: