Track-splitting program

The Klipspringer platform includes a program for splitting audio files into shorter tracks, which is started with the terminal command tracksplit1. This is completely separate program, not run from the Klipspringer hub web interface.

The idea is that you run tracksplit on a file that you got as output from recording audio with kliptune, or a devicestream source of the Klipspringer hub, and that the file contains several songs (for instance because it’s a recording of an LP) which you want to split up into one file (track) per song. The tracksplit program attempts to detect the tracks by finding the silence between them, but it normally takes some manual fine-tuning to get it right.

Silence and fading

The silence between tracks is not normally completely silent, and one of the parameters that you usually need to specify manually is how silent something should be to be regarded as silent on the particular recording.

The assumption is that the silence between tracks should be made completely silent in the output track files. At the end of each track, there is a fade-out section, where the virtual silence, more or less quickly turns into total silence, and at the beginning of the track there is a (usually very short) fade-in section, where it goes from total silence to the start of the song.

The available functions for the shape of the fade-in and fade-out are implemented in the MixSpec class, and are the same that can be used for crossfading. By default, the fade-in function is specified as exp,8, which is a fast-growing exponential, and fade-out is lin_pow, which makes the square of the amplitude (which corresponds fairly well to subjective volume) decrease linearly.

When you listen to parts of the recording in klipsplit, you can choose to do so with fading activated or not. When it isn’t activated, you hear the recording exactly as it was made, and when it is activated you hear what the written track files are going to sound like.

Time values

For some parameters, time is specified in seconds, given as a floating-point value, but for most time values the format is h:mm:ss'ff, where only the s part, seconds, is required. The others are h for hours, m for minutes, and f for fractions of seconds. By default, there are 75 fractions in a second, which means that the part after the ' character has to be a number from 00 to 74, always given as two digits.

For instance, 5 means five seconds, 5'25 means five and one third seconds. 5:07'25 means five minutes plus seven and one third seconds, and 1:30:09 means one hour, thirty minutes and nine seconds.

The reason for using seventy-fifths rather than hundredths is that in the “red book” standard of audio CDs, 1/75 of a second (588 sample frames with a 44.1 kHz sampling frequency) is the atomic unit of time. If you want to use hundredths or something else instead, you can specify another value than 75 with the -secatoms option.

Running

You start tracksplit with an audio file as an argument, perhaps preceded by some options (run tracksplit -help for a list of available options). If there is no segmentation specification already made and saved, it starts with trying to detect the tracks, based on the initial values of silence level, minimum track length and minimum gap length (which can be specified with options if you don’t want to start from the defaults).

Then you arrive at a prompt where you enter one of the following commands at a time:

  • l (list) shows the current segmentation into tracks. Each track is shown with

    • the track number, starting from 1,
    • the fade-in function specification and fade-in time,
    • the time range of the mid part of the track (between the fading sections), relatively to the input file,
    • the fade-out function specification and fade-out time, and
    • the length of the silent part at the end of the track,

    After the track list, the trailing time of the input (not set to be included in any track) is shown.

  • p (play) starts playing audio at a given position. It takes the following optional arguments:

    • A track number. For instance, p 2 plays from the beginning of track 2. No track number or track number 0 refers to the start of the whole input.
    • A colon followed by a section number 0–3, where 0 is the start of the track (the fade-in section), 1 the mid section, 2 the fade-out section, and 3 the silent end section. For instance, p 4:2 starts playing from the beginning of the fade-out section of track 4.
    • Time offset. For instance, p 2 10'08 starts playing 10+8/75 seconds into track 2, and p 4:2 -5 starts playing five seconds before the fade-out section of track 4.
    • Duration. For instance p 5 -2 2 starts playing two seconds before the beginning of track five and stops playing at the beginning of track five. This is convenient when you want to listen for exactly where sound starts or stops. When playing stops, by default an extra 0.2 seconds of silence is sent to the output. This is because in some situations (for instance when listening with Bluetooth headphones), the final part of the sound may otherwise be lost. The amount of silence added can be modified with the -flushsec option when starting the program.

    While audio is being played, the following keys can be pressed:

    • < skip track backwards
    • > skip track forward
    • ▲ skip 30 seconds ahead
    • ▼ skip 30 seconds back
    • ► skip 5 seconds ahead
    • ◄ skip 5 seconds back
    • f activate/deactivate fading
    • p save current position
    • r restore saved position, or go to the starting position if p has not been pressed
    • q stop playing
  • q (quit) exits the program.
  • w (write) outputs track files. No arguments (or a 0 argument) means write all tracks. One track number argument means only output that track. Two arguments are start and end track to write.

    The format and file name of the written files are controlled by the type and name values (see below). The location is controlled by the -dir command line parameter.

  • v (value) lists or sets values. Without arguments, all values are listed. Possible arguments are:
    • fading, followed by true or false, activates or deactivate fading during playback (the p command).
    • silence, followed by a number between 0 and 1, specifies the fraction of the maximum amplitude that is considered silent when looking for the silent sections between tracks.
    • track, followed by a number, sets minimum non-silent number of seconds to be accepted as a track.
    • gap, followed by a number, sets minimum non-silent number of seconds to be accepted as gap between tracks.
    • itime, followed by a number, sets default fade-in time in seconds.
    • otime, followed by a number, sets default fade-out time in seconds.
    • ifade, followed by a fade specification, sets default fade-in function type.
    • ofade, followed by a fade specification, sets default fade-out function type.
    • name, followed by a name string, sets the base file name for writing with w and saving with s. By default, the names of output files are based on the input file name.
    • type, followed by an audio file format, sets the format for w. Valid formats are raw, flac, wav, and mp3.
  • m (modify) changes a track time. Takes three arguments: the track number; which time to modify, which is start, end, in, or out; and a time that specifies the change in time (positive or negative). For instance, m 2 start -3'25 sets the mid-section of track 2 to start three and one third seconds earlier, and m 4 out 1 increases the fade-out time of track 4 by 1 second.
  • e (end), with a time argument, modifies the final silent time of the last track. (The silent end times of other tracks are calculated from the surrounding positions and lengths, and cannot be directly specified.)
  • f (fade), sets the in or out fade function of a track. Takes three arguments: the track number, in or out, and the fade specification.
  • d (delete), with a track number argument, makes the track disappear into its surrounding silence.
  • j (join), with a track number argument, makes the track part of its predecessor, removing a gap.
  • r (rescan), makes a new attempt to find gaps. Without arguments (or a 0 argument), it runs detection again on the whole input. With a track number argument, it attempts to find one or more gaps in the middle of the track, and if so increase the number of tracks. One or more of the silence, track or gap should be changed before issuing the r command, or it won’t result in any change.
  • c (cut), introduces a track splitting point at the given position, without considering whether there is any silence. It takes two arguments: a track number and a time offset inside the mid section of the track.
  • h (hop) introduces, drops, or changes a hop in playing. A hop is can be used for instance to get rid of a backward skip in a vinyl recording. Possible aguments are:
    • new followed by track number, a time offset for the hop in the track, and a time for the length of the track.
    • drop followed by hop number (starting from 0), to remove a hop.
    • hop number, p, and a time, to change the start position of the hop.
    • hop number, l, and a time, to change the length of the hop.
  • s (save), writes the current track segment specifications to a JSON file. The file location and name are determined by -dir command line argument and the name value. When klipsplit is restarted, it attempts to find a saved specification and load it, rather than run a new track detection.
  • o (open), loads a track segment specification from a file saved with s.
  • ? (help), prints a short summary of commands.

If your JVM is version 22 or newer, you should be able to use command line editing at the prompt. Press ▲ and ▼ to move between previous commands, which you can issue again after editing.

Notes

  1. The command is a shell script that launches the Java class TrackSplitter. Hence, Java needs to be installed, but Node.js doesn’t.