A Closer Look


How does TR sequence your music?  The short answer is that TR obtains data from the Internet and decides which music files – and in what order – to build a sequenced track(s) that can be played through a web page.  Here is an overall diagram:




You compose your music, as always, using a convenient notation program.  There are two (or three) staves – treble and bass –  and these are broken into equal-sized segments of 2 or 3 minutes each.  Note that the tempo and time signature must be identical for each segment – using sox, TR will preserve the beat across segment boundaries as the segment files are concatenated and mixed.  These segment files are saved and converted to .ogg by any convenient program you are already using.

The source (.ogg) files must then be edited so that they are exactly the same duration and that this corresponds precisely to the number of beats in the file.  My midi-to-.ogg file converter   adds extra dead time at the end of a segment file for some reason, so this must be edited out. For example, if the segments are 64 measures in common time at a tempo of 80 beats per minute, then each segment file has to be exactly (64 X 4)/80 = 3.2 minutes or 3 minutes 12 seconds long.  Using Audacity – or some other editor – the length of each file can be cut to exactly 3:12.000  In this way the first beat of the succeeding measure after the end of a file will be correctly placed when the segment files are concatenated.

In this above diagram, two staves have been broken into 4 segments each. These segment files are trimmed to the exact length in time and saved as .ogg  files with special names that identify each segment staff number and coordinate.  The staff indications here are S0 and S1 and the coordinates are 000, 001, 010 and 011 – four coordinate numbers in binary form.   The segment files are edited to the exact length in time for the number of beats in the file prior to uploading to TR.

These files are uploaded via FTP to a special folder on the Slax LP server /sourcetr and this is where the TR program looks for them when creating a new sequence.

How The Sequencer Works:

There is a controller program running on the TR server that looks for a signal from the user to begin creating a new sequence.  This is activated when the user presses the Start Sequencing button on the configuration web page.  The controller also has a timer that automatically enables a new sequence when a pre-determined amount of time has elapsed (this time is also set by the user in the configuration web page.)

In this example, the sequencing program is set up to retrieve the temperature, humidity and wind velocity readings from 15 selected cities around the US and assign coordinates that determine the final track sequences.  Here is what happens:


Let’s say the first temperature reading received from the Internet is 48 F in Chicago.  The sequencer uses the following algorithm to calculate a three-digit binary coordinate as follows:

<0 F = 000
0 F to 55 F = 001
>55 F to 110 F = 010
>110 F = 011

The first reading is 48 F, so the sequencer assigns a coordinate of 001 for the first segment chosen for the first track.  The S0_001 file is copied into a new folder – /S0 and given the name AD0.ogg.

The next city is fetched from the random database and the temperature retrieved.  In this example  it is Phoenix with a temperature of 89 F.  This corresponds to a coordinate of 010 and so the file S1_010 is copied to /S1/AD1.ogg.  This becomes the first segment of the second track.

This process continues, as shown below:



A temperature reading from Los Angeles at 75 F equates to a coordinate of 010 and so the file S0_010 is copied to /S0/BD0.ogg.  Similarly, a reading from Casper, Wyoming at -3 F creates a coordinate of 000 and the source file S1_000 is copied to S1/BD1.ogg to continue building the second track.

The sequencer program continues gathering weather data and calculating coordinates until enough segments are copied into /S0 and /S1 to build up what will become the  track1.ogg and track2.ogg files.  These track files are created using the sox concatenate command that joins all the files in a given directory (/S0 and /S1).  The track1.ogg and track2.ogg are merged using the sox -m command and then linked to the player in a webpage that the sequencer builds for the user.

Some Notes:

The maximum number of files per staff is 8 and the maximum number of tracks is 3.  So you can create up to 24 segments distributed in three sets of staff (stave) files.  The sequencer will automatically scale the incoming temperature coordinates between 0 F and 110 F and break the intervening temperatures among the number of staff files that you uploaded.  Same with humidity and wind velocity. So more files per staff provides a more varied final track.

The maximum number of segments in the final version of the piece is 16, so the length of the piece will be the time of each segment (2 or 3 minutes, typically) times the number of segments called for (4 to 16) in the configuration screen.  So if you wrote 8 three-minute segments for three staffs and you configured for 16 segments in the final version the sequencer will obtain 48 coordinates, copy 48 segment files and create three tracks 48 minutes long.  Best to start out with, say, four files for each staff and a final length of 6 segments and this will generate a piece of 12 to 18 minutes long.

It takes time to obtain the Internet data, calculate the coordinates, copy the source files and build the final track files.  This can vary between 60 minutes for a small random sequence to over an hour for a larger sequence.

Be mindful also of the size of the files your are uploading and the size of the sequence you are building.  All of this has to fit in about 2 MBytes of usable space on a thumb drive.

More About Algorithms:

There are other algorithms in TR to sequence the files.  For example, in one weather algorithm the weather in US cities are used to build the tracks  In another weather algorithm, the weather for cities in both North and South America are used.   A third weather algorithm uses the temperature, humidity and wind velocity of 16 European cities to create the coordinates.  The weather data is obtained from Weather Underground.

In another algorithm, MapQuest traffic alerts are used to set the sequence of the files.  These come from 50 US cities – in one algorithm the cities are grouped from largest to smallest.  In another, by time zone.

A randomly generated coordinate algorithm is also available.  These sequence types are chosen by the user from the configuration page, as shown below:


The user can select any of the available algorithms to sequence the .ogg files that were uploaded to the TR server.  The number of staves (staffs) and the number of files per stave, however, must be set to match what was actually uploaded.