rend -- split data tokens from specified Humdrum spines into component sub-tokens


rend [-s] -i 'target_interp' -f reassign-file [inputfile ...]


The rend command breaks apart data tokens from selected input spines into one or more sub-tokens distributed across one or more newly created output spines. The user specifies which input spine or spines are to be split. The manner in which the signifiers are to be distributed is specified in a separate reassignment file.

Humdrum data tokens often contain more than one type of information or type of signfier. For example, the **pitch representation consists of three parts (not including cents deviation): the pitch letter name, the accidental, and the octave number (e.g. A#4). In some tasks it may be useful to split such information into separate spines. For example, a user may wish to reformat the following spine:

as three independent spines:
The rend command allows each occurrence of a target exclusive interpretation to be replaced by specified output spines. The user selects how the signfiers (characters) in the input spines are to be distributed to the replacement output spines. Signifiers (ASCII characters) are identified using UNIX regular expression syntax (see regexp (6)).

The above transformation may be achieved by invoking the following command:

rend -i '**pitch' -f reassign

The -i option specifies the target input interpretation, i.e., the input spine(s) to be processed. The -f option specifies a reassignment-file (named reassign) containing the following records:

Reassignment files consist of one or more records, each containing two strings separated by a tab. The left-most string identifies the name of the new spine to be generated. The right-most string defines an associated regular expression. Any input signifiers matching the regular expression will be echoed as output in the associated spine. In the above case, all numbers are echoed in the first spine (**octave), all letters plus the sharp (#) and flat (b) signs are echoed in the second spine (**note), whereas only sharp and flat signs are echoed in the third spine (**accidental). The order of the output spines preserves the order of the assignments in the reassignment file. In the above case, for example, the order of the output spines will be **octave, **note, **accidental for each input spine labelled **pitch.


The rend command provides the following options:
-f reassignmaps input tokens to output tokens according to definitions given in the
file reassign
-hdisplays a help screen summarizing the command syntax
-i target_interpprocess all input spines whose exclusive interpretations are labelled
-smatches a single instance of the given pattern rather than all instances
Options are specified in the command line.


Consider the following example:

rend -i '**kern' -f noterest song01

and the associated reassignment file named noterest:

**notes []A-Ga-g[#-]+|^=+[0-9]*
**rests [\\.0-9r]+|^=+[0-9]*

This command specifies that each **kern spine in the file song01 is to be split into two new spines dubbed **notes and **rests. The first regular expression -- '[]A-Ga-g[#-]+|^=+[0-9]*' -- indicates that the following strings should be echoed in the data records for **notes: the upper-case letters A to G and the lower-case letters a to g, plus the characters [, ], #, and -. Alternatively, rend will echo any data token beginning with one or more equals-signs, followed by zero or more numbers.

Similarly, the second **rests spine will contain characters that match the regular expression '[\\.0-9r]+|^+=[0-9]*'. This includes the period (.), all numbers (0-9), plus the letter r. Alternatively, rend will echo any data token beginning with one or more equals-signs, followed by zero or more numbers.

Given this command, the following input:

!! Commented input.
2C 2Ehum.2r
will produce the following output:
!! Commented input.
C E2 2hum..2r
Notice that rend correctly handles Humdrum multiple-stops (such as 2C 2E). Notice also that if no match is made, a null token (.) is output.


DOS 2.0 and up, with the MKS Toolkit. OS/2 with the MKS Toolkit. UNIX systems supporting the Korn shell or Bourne shell command interpreters, and revised awk (1985).


cleave (4), extract (4), humsed (4), recode (4), regexp (4), regexp (6)


Note that, apart from spine-path terminators, no other spine-path indicators are permitted in spines containing the target interpretation.


If the interpretation targetted for processing appears in a spine starting with a different interpretation, the output will fail to generate the proper spine terminator and add-spine path indicators. The result is a non-Humdrum file. Consider the following command:

rend -i '**ex1' -f reassign input

and the associate reassignment file (reassign):

**let [a-z]
**num [0-9]

Given the following input:

the corresponding output is given below. Note the absence of appropriate spine-path indicators between lines 4 and 5 (hence the output is non-Humdrum).