# Raptor, the Random Arpeggiator Version 7

Albert Gräf

► To cite this version:

Albert Gräf. Raptor, the Random Arpeggiator Version 7. Proceedings of the 19th Linux Audio Conference, Jun 2025, Lyon, France. hal-05096055

HAL Id: hal-05096055

https://hal.science/hal-05096055v1

Submitted on 3 Jun 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# RAPTOR, THE RANDOM ARPEGGIATOR VERSION 7

Albert Gräf

Computer Music Dept., Institute of Art History and Musicology

Johannes Gutenberg University (JGU) Mainz, Germany

aggraef@gmail.com

## ABSTRACT

The paper is about the latest version of Raptor, the author's randomizing arpeggiator. Version 7 is written in Lua and available as both an Ardour plugin and a Pd external and patch. We give a brief overview of Raptor's functionality, report on its latest advancements, and describe how it can be used in Ardour and Pd.

In memory of Clarence Barlow (27 December 1945 – 29 June 2023).

## 1. INTRODUCTION

Arpeggiators are a kind of auto-accompaniment function of synthesizers and other music-making gear which have been around at least since the 1970s and to this day are used heavily in many styles of electronic and computer music [8]. They are similar to step sequencers, typically offering a variety of different patterns and controls for tempo, octave range, velocity, note length (gate) and repeats, and sometimes probability. However, in contrast to most step sequencers, arpeggiators adjust automatically to the chords played by the musician. Raptor offers all the basic functions of an arpeggiator, but it generates notes in a semi-random fashion based on the mathematical music theories of the late contemporary composer and computer music pioneer Clarence Barlow. It thus offers a much greater variety of patterns and a lot of parameters to control the generated arpeggios.

Raptor is available as free software under the GNU Public License [4]. In the following, we give a brief account of what's new in the current Raptor version and an overview of Raptor's functionality and control parameters. We also illustrate its use in Ardour and Pd by way of some simple examples. More details can be found in the online documentation available under the GitHub link cited above.

## 2. WHAT'S NEW

Raptor has been around for quite some time. Its original stand-alone version (version 4) can be traced back to 2005. This was the first "production" version actually used in a concert within the framework of the "Kultursommer Rheinland-Pfalz" 2005. Version 5 is a port of this version to the author's Pure programming language which consists of a Pd external and main patch. In version 6, the external was then ported to Lua to facilitate its installation and improve cross-platform compatibility; in particular, this made it possible to run Raptor on ARM-based devices such as the Raspberry Pi.

Using Lua also opened up the possibility to implement Raptor as an Ardour plugin which is now included in Ardour as of Ardour version 8 [1], along with some other, simpler arpeggiator plugins also written in Lua [3]. This version 7 of Raptor also offers some important new features, such as latch mode and an improved looper (a.k.a. ostinato) function. The accompanying Pd version is a backport of the Ardour plugin, and thus 100% compatible in terms of the underlying arpeggiator core, as well as the parameters and factory presets. (Earlier Raptor versions offered a similar, but not fully compatible, set of parameters.) While it is ultimately based on Raptor 6, the Pd patch was completely rewritten to provide a better and simplified user interface,

and besides latch and looper modes also provides some new features specific to the Pd version, such as improved transport functions, a MIDI learn facility, and much improved built-in support for a bunch of popular MIDI controllers. This makes it easier to control the algorithm's many parameters in a live performance situation.

## 3. THE ARPEGGIATOR

A complete discussion of the underlying algorithm is beyond the scope of this paper, instead we refer the reader to Barlow's original work [5, 6] and the author's ICMC 2006 paper [7] for details. However, to make the paper mostly self-contained, we have also summarized the mathematical formulas for the measures underlying Barlow's methods in Appendix A.

Raptor is really an algorithmic composition program driven by note input. It keeps track of the chords you play like any arpeggiator, but the note output it generates is in general much more varied than just playing back the input notes in a given pattern. This functionality is enabled by the special "raptor" control. If it is turned off, Raptor will still apply some basic parameters to the velocities and note filters, and produce a traditional arpeggio from the notes you play. If it is turned on, however, Raptor will pick notes more or less at random from a set of *candidate notes* determined by various harmonic criteria. Depending on the parameter settings, the generated notes may be close to the input, or at least harmonically related, or they may be entirely different, so the output can change from tonal to atonal and even anti-tonal in a continuous way. Moreover, Raptor can also vary the tonal strength automatically for each step based on the corresponding pulse weights.

Raptor's note generation process is quite involved, but at the heart of it there are just two basic "musiquantical" notions and corresponding measures from Barlow's theories: *meter* (which determines a kind of one-to-one pulse weights called *indispensabilities*) and *harmonicity* (a measure for the consonance of intervals calculated from so-called *indigestibilities*). In fact, there are a lot of similarities between Raptor and Barlow's groundbreaking Autobusk program which is based on the same concepts [2]. Both programs can operate in real-time, but Autobusk is driven exclusively by parameter input and will happily produce a constant stream of notes as soon as you turn it on. In contrast, Raptor never becomes "creative" on its own, it *always* requires note input.

Thus, in Raptor harmonicities are used to *filter* candidate notes in relation to its note input (the notes you play). In other words, they determine *what* to play. On the other hand, the pulse weights are used to *assign* various parameters to each step in the pattern, such as note velocities and probabilities, and gate values. That is, they determine *how* to play the notes picked by the filter. The arpeggiator orchestrates the entire process, by taking note input from the musician, feeding the required data to the various parts of the algorithm in each step, and playing back the resulting stream of notes.

One rather unusual feature of Raptor's algorithm is the way that the Barlow indispensabilities drive the entire process by modulating various other parameters. Like in Autobusk, the pulse strengths directly affect note velocity and probability, but in Raptor they also modulate harmonicity and thereby change
the note selection process itself. Another unique feature of the algorithm is the harmonic preference parameter, which lets you prioritize notes by harmonicity, and can also be modulated by pulse strength in an automatic fashion.

In the following we give a brief rundown of Raptor's control parameters as they pertain to both the Ardour and the Pd version. All parameters can be changed in real-time. This is also the data that gets stored in each Raptor preset. Raptor includes various factory presets for illustration purposes which you can use as a starting point for your own presets.

Ranges are given in parentheses. Switches are denoted 0/1 (off/on). Continuous values use the 0 - 1 or -1 - +1 range and can be arbitrary floating point values. These generally denote probabilities or other normalized values (such as indispensabilities, harmonicities, and modulation values) expressed as fractions; some of these (in particular, the modulation parameters) can also be negative to reverse polarity. Other ranges denote integer values, such as MIDI channel and program numbers, MIDI note offsets, or enumerations such as the pattern and pitch tracker modes.

## 3.1. MIDI Controls

These controls let you change the MIDI program and the MIDI channels for input and output.

* pgm (0-128): Sets the MIDI program (instrument sound) of a connected synthesizer. pgm = 0 (the default) means no change, otherwise a MIDI program change message is sent to the output channel.

* inchan, outchan (0-16): Sets the MIDI input and output channels. inchan = 0 (omni) means that notes on all channels will be received, otherwise MIDI input on all other channels will be ignored. outchan = 0 means that output goes to the input channel; otherwise it goes to the given MIDI channel. The default is inchan = outchan = 0, which means that MIDI input will be received on all channels and output goes to the last channel on which input was received.

* transp (-64 - 64): Transposes the output of the arpeggiator by the given number of semitones. (Pd only.)

## 3.2. Arpeggiator Modes

These controls are 0/1 switches which control various global modes of the arpeggiator.

* bypass, latch, mute (0/1): The bypass toggle, when engaged, suspends the arpeggiator and passes through its input as is. This provides a means to monitor the input to the arpeggiator, but can also be used as a performance tool. In latch mode, the arpeggiator keeps playing if you release the keys on your MIDI keyboard, which makes changing chords easier. The mute control suppresses note output of the arpeggiator (the arpeggiator still keeps tracking input notes, so that it is ready to go immediately when you unmute it again).

* raptor (0/1): Toggles raptor mode, which enables the advanced raptor controls discussed below.

* loop (0/1), loopsize (0-16): This engages Raptor's built-in looper which repeats the last few bars of output from the arpeggiator. The loopsize control specifies the number of bars to loop. If input runs short then the looper will use what it has, but it needs at least one complete bar to commence loop playback. You can toggle the loop control at any time and it will switch between loop playback and arpeggiator output immediately, which comes in handy if you need to get your hands free to record a generated pattern or play along on a different track. In the Pd version, the current loop can also be saved to disk as text and reloaded at a later time. (In the Ardour version, you can record the loop to a MIDI track instead.)

## 3.3. Arpeggiator Controls

These controls are always in effect (unless the looper is active), no matter whether raptor mode is on or off. The modulation controls (velmod, gatemod, pmod) vary the corresponding parameters according to normalized pulse weights (i.e., indispensabilities) of the current step. These values can also be negative which reverses polarity. E.g., velmod = 1 means that the note velocity varies from minvel to maxvel, *increasing* with the pulse weight, whereas velmod = -1 varies the velocities from maxvel to minvel, *decreasing* with the weight. If velmod = 0, then the velocity remains constant at the maxvel value. The other modulation controls work in an analogous fashion.

* tempo (0-240): The tempo measured in quarter beats per minute (bpm). (Pd only. In Ardour, the tempo is taken from the timeline.) See Section 3.5 below for details.

* meter (1-16): This is a pair of numbers which specifies the desired time signature. The first value (the numerator) specifies the number of beats in a bar. The second number (the denominator) specifies the base pulse a.k.a. the unit of the beat. Thus, e.g., 4 4 denotes common time, a.k.a. 4/4. The base pulse can be further divided into tuplets with the division parameter, see below. (Pd only. In Ardour, the meter is taken from the timeline.)

* division (1-7): Number of subdivisions of the base pulse. E.g., in a 4/4 meter a division value of 2 gives you duplets (eighth notes), 3 gives you (eighth) triplets, etc. The resulting number of steps you get is the numerator of the meter times the number of subdivisions.

* up, down (-2 - +2): Range of octaves up and down. Both values can also be negative. Typically, you'd use a positive (or zero) value for the up, and a negative (or zero) value for the down control. But you also might want to use positive or negative values for both, if you need to transpose the octave range up or down, respectively.

* mode (0-5): Sets the pattern mode. The collection is a bit idiosyncratic, but should nevertheless be familiar and cover most use cases: 0 = random, 1 = up, 2 = down, 3 = up-down, 4 = down-up, 5 = outside-in (alternate between low and high notes). Default is 1 = up.

* minvel, maxvel (0-127), velmod (-1 - +1): Sets minimum and maximum velocity. The actual velocity varies with the pulse weight, by an amount given by the velmod control.

* gain (0-1): This control ties in with the *velocity tracker*, a function which calculates a kind of envelope from the velocities of the notes that you play and adjusts the velocities of output notes generated by the arpeggiator accordingly. The gain value actually controls the mix between preset velocity values (minvel, maxvel) and the calculated envelope, ranging from 0 (all envelope) to 1 (all preset; this is also the default).

* gate (0-1), gatemod (-1 - +1): Sets the gate (length of each note as a fraction of the pulse length). The actual gate value varies with the pulse weight, by an amount given by the gatemod control. An actual gate value of 0 forces legato across rests if notes are being filtered out.

* wmin, wmax (0-1): Deterministic pulse filter. Pulses with a weight outside the given wmin - wmax range will be filtered out. As the deterministic pulse filter uses the pulse weights, it filters notes in a musical fashion by gradually removing less salient pulses while wmin is increased. Conversely, it can also give you syncopation a.k.a. an off-beat rhythm when decreasing wmax.
* `pmin`, `pmax` (0-1), `pmod` (-1 - +1): Probabilistic pulse filter. The given minimum and maximum probability values along with the corresponding modulation determine through a random choice whether a pulse produces any notes. You can disable this by setting `pmax = 1` and `pmod = 0` (which are the defaults).

## 3.4. Raptor Controls

These controls only affect the arpeggiator if it runs in raptor mode. The modulation controls (`hmod`, `prefmod`, `smod`, `nmod`) work as described above to vary the corresponding parameter with the pulse weight of the current step. The controls filter and order candidate output notes according to various criteria, which determines which notes are eventually output by the arpeggiator in each step.

* `hmin`, `hmax` (0-1), `hmod` (-1 - +1): This filters candidate notes by comparing their (modulated) average harmonicity with respect to the input chord to the given bounds `hmin` and `hmax`. The harmonicity function being used here is a variation of the one in Barlow's Autobusk program, please see my ICMC 2006 paper for details [7, Section 8]. Some interesting harmonicity thresholds are at about 0.21 (the 5th), 0.17 (the 4th), 0.1 (major 2nd and 3rd), and 0.09 (minor 7th and 3rd). To hear the effect, try varying the `hmin` value while playing a single note.

* `pref` (-1 - +1), `prefmod` (-1 - +1): This parameter doesn't affect the candidate notes, but sorts them according to harmonic preference. The arpeggiator will prefer notes with high harmonicity if the value is positive, notes with low harmonicity if it is negative, and simply choose notes at random if it is zero. The preference also varies according to the `prefmod` modulation control with the current pulse weight. Basically, a high `pref` value tends towards a tonal, a low one towards an anti-tonal, and zero towards an atonal style, but of course this also depends on the harmonicity range set with the `hmin` and `hmax` parameters. This parameter can be very effective if the arpeggiator has enough candidate notes to choose from. E.g., `pref = 1` with `hmax = 1` will give you a high degree of tonality even if `hmin` is very low.

* `smin`, `smax` (-12 - +12), `smod` (-1 - +1): Determines the minimum and maximum step size in semitones between consecutive steps. Note that these values can also be negative, allowing for down-steps in an “up” pattern, and the step size can be modulated according to pulse weight. Since Raptor picks notes more or less at random, these parameters give you some control over how large the steps can be. You can also effectively disable this (set `smin = 0` and `smax = 12`), but in this case make sure to also enable `uniq` mode (see below), otherwise the arpeggiator may just play the same note over and over again.

* `nmax` (0-10), `nmod` (-1 - +1): Sets the maximum number of simultaneous notes (modulated according to pulse weight). Thus Raptor, unlike most arpeggiators, can play more than one note at a time, but this only works in raptor mode.

* `uniq` (0/1): When set to 1, makes sure that notes are not repeated between consecutive steps.

* `pitchhi`, `pitchlo` (-36 - +36), `pitchtracker` (0-3): Set this to extend the octave range (up/down) by the given number of semitones. This gives you finer control over the range of candidate notes in raptor mode. Also, using the `pitchtracker` control, you can have the arpeggiator follow the (highest and lowest) notes you play and automatically adjust the range of candidate notes accordingly, taking into account the up/down and `pitchhi/pitchlo` settings. The pitch tracker can be run in four different modes, 0 =

off, 1 = on (follow both high and low notes), 2 = treble (only follow the high notes), 3 = bass (only follow the low notes).

## 3.5. Time and Sync

The frequency at which pulses are being triggered depends on the meter (including division) and, of course, the tempo. One important thing to note here is that by convention, the tempo is *always* specified in *quarter* beats per minute, no matter what the actual base pulse of the meter is. This means that you can switch meters on a whim without having to constantly adjust the tempo when changing the base pulse.

E.g., at a tempo of 120 bpm, quarters run at 500 ms per step, 8ths at double speed (250 ms/step), 16ths at quadruple speed (125 ms/step), etc., no matter what the actual denominator of the meter may be. Raptor also allows you to use non-standard base units such as 6 (= quarter triplets), 12 (= 8th triplets), or even more exotic values such as 10 (= 8th quintuplets) which run at 333 ms, 166 ms, and 200 ms per step at 120 bpm, respectively. This makes it quite easy (or at least possible) to deal with really complex time signatures. However, if you just need triplets, an easier and more traditional way to get these is to choose a “straight” base meter and adjust the division parameter instead.

In Ardour, both tempo and meter are determined by the timeline. The Pd patch has its own controls for these parameters, and can also sync to an external time source (MIDI clocks). In either case, the division parameter is controlled separately. Also, tempo, meter, and division are *not* preset data; i.e., they are not recorded in presets and thus won't change when recalling presets. (Tempo, meter, and division *are* saved by the looper in the Pd version, however.)

## 3.6. The Looper

Raptor's looper is (by design) quite basic. Its main purpose is to give you a quick way of putting a generated musical phrase on repeat while you have your hands free for playing along, twiddling knobs, or capturing that precious pattern before it vanishes forever. If you need more features, then I'd recommend running Raptor as an Ardour plugin, or the Pd patch alongside a DAW or external groovebox tailored to live usage. In particular, this also gives you the ability to record the *input* to the arpeggiator, which makes it much easier to tweak the results later.

# 4. RAPTOR IN ARDOUR

Ardour makes it very easy to run multiple instances of Raptor in concert, each with their own automation lanes to control Raptor's parameters in real-time. To these ends, you'd typically use one “master” MIDI track to feed note data to a number of different MIDI buses or tracks. (Using tracks rather than buses for the Raptor instances is useful, in particular, if you'd also like to record Raptor's output on each track.) E.g., Fig. 1 shows a little arrangement of this kind.

Here, the topmost “Raptor” track has all the note data being fed into the other tracks. The mixer strip on the left shows the “Organ” track running a Raptor instance into an instrument. The other tracks have been set up in a similar fashion. For details, please check the corresponding Ardour session which can be found in the raptor-freejazz.ardour-session-archive file (link). Note that this file can be opened as is in Ardour's “Select session file” dialog, if you change the dropdown list at the bottom from “Ardour sessions” to “Session Archives”. The session assumes that you have the General MIDI Synth and setBfree instrument plugins installed, available from x42-plugins.com. There's also an audio rendering of the session available that you can listen to if you don't have Ardour installed (link).
<figure><img src="image_2.png" /><figcaption>Figure 1: Raptor Ardour session.</figcaption></figure>

## 5. RAPTOR IN PD

The Pd version includes a main patch with all the requisite controls to operate Raptor in a live performance. This includes transport and looper controls, a beat counter, a quick dial for the first 20 presets, and a panel with on-screen GUI elements for all the parameters, as can be seen in Fig. 2.

<figure><img src="image_3.png" /><figcaption>Figure 2: Raptor in Pd (Purr Data).</figcaption></figure>

While all parameters are accessible with mouse and keyboard using GUI controls in the main patch, Raptor also has built-in support for a number of popular MIDI controllers like the Novation Launchkey and Launchpad, the Novation Launch Control XL, the AKAI APC mini and MIDIMIX, and some of the Hercules DJ Control devices. Other MIDI devices can be used as well, by utilizing the built-in MIDI learn capability. This gives you easier access to at least the most important parameters in a live performance.

Multiple instances of the main patch can be run in concert, in which case one instance acts as the time master to which all other instances sync up, and it is also possible to sync Raptor to an external time source via MIDI clocks, so that it can be used alongside a DAW or stand-alone gear such as the AKAI MPC. Moreover, Raptor instances can be assigned to the decks of a DJ controller in order to control loop playback with the big jog wheels for some fun scrubbing action. Some examples can be found in the Raptor repository [4]. These consist of a main patch which embeds various Raptor subpatches for the parts of the ensemble. It also sets up various parameters in each subpatch such as the preset used in each part, so that the ensemble is ready to go as soon as the main patch has been loaded (cf. Fig. 3).

<figure><img src="image_4.png" /><figcaption>Figure 3: Raptor ensemble.</figcaption></figure>

## 6. CONCLUSIONS AND FUTURE WORK

Like other tools of its kind, Raptor is suitable both for live performances and compositional purposes. You'd probably want to use the Pd patch for the former, and the Ardour version for the latter, although the Pd patch can also be used as a stand-alone composition tool in combination with any DAW or external groovebox.

What makes Raptor stand out from the crowd, in my opinion, is its unusual approach using mathematical models for both harmony and meter as the underlying algorithmic composition engine, in lieu of classical music theory, traditional statistical methods such as Markov chains, or the generative AI techniques which have become popular in recent years. This makes its results quite predictable and very controllable in a live situation, while also providing a lot of musically interesting variation in its output. Other approaches often excel either in predictability or inventiveness, but not both at the same time.

It must be said, however, that arpeggiators available in MIDI keyboards, synthesizers, and software have also progressed quite substantially in the past decade, offering probabilistic elements and a lot of variation, going well beyond merely playing back the given notes across various octaves in some order. Therefore benchmarks and comparisons of Raptor with other existing approaches are definitely in order. To these ends, getting Raptor in the hands of many existing Ardour users will hopefully provide valuable feedback.

One downside of Raptor is its sheer number of parameters which goes way beyond what is on tap with more traditional arpeggiators. This is nothing new, however, complex synthesizer and effect units suffer from the same issue, and thus similar remedies can be applied here to tame the complexity. Having a good preset system is one obvious solution. Raptor already has this, but it could still be further refined to facilitate preset creation and recall in the Pd version. Also, Raptor currently has no built-in macro controls which would let you change multiple parameters at the same time. This could be added to the existing MIDI learn facility of the Pd version in a future release, but in order to also have it work in Ardour, macro controls would need to be added to the arpeggiator core itself.

## 7. ACKNOWLEDGEMENTS

Thanks are due to the anonymous reviewers for their suggestions.
## 8. REFERENCES

[1] Ardour 8.1 — What's new. https://ardour.org/news/8.1.html.

[2] Autobusk, 2000. https://www.musikinformatik.uni-mainz.de/Autobusk/.

[3] agraef/ardour-lua, Nov. 2024. https://github.com/agraef/ardour-lua.

[4] agraef/raptor7, May 2024. https://github.com/agraef/raptor7.

[5] C. Barlow. On the Quantification of Harmony and Metre. In *The Ratio Book*, pages 2–23. Feedback Papers, 1999.

[6] C. Barlow. *On Musiquantics*. Number 51 in *Musikinformatik & Medientechnik*. JGU, Mainz, 2012.

[7] A. Gräf. On Musical Scale Rationalization. In *Proceedings of the 2006 International Computer Music Conference, ICMC 2006, New Orleans, Louisiana, USA, November 6-11, 2006*, pages 91–98. Michigan Publishing, 2006.

[8] M. Vail. *The Synthesizer: A Comprehensive Guide to Understanding, Programming, Playing, and Recording the Ultimate Electronic Music Instrument*. Oxford University Press, USA, 2014.

## A. HARMONICITY AND INDISPENSIBILITY FORMULAS

Raptor uses a slightly modified version of Barlow's original harmony formula, $h(x) = 1/(g(x)+1)$, where for each *rational* interval (frequency ratio) $x = p_1^{a_1} p_2^{a_2} \cdots p_n^{a_n} > 0$ with prime factors $p_1 < p_2 < \cdots < p_n$ and their (positive or negative) multiplicities $a_1, a_2, \ldots, a_n$, $g(x) = |a_1| g(p_1) + |a_2| g(p_2) + \cdots + |a_n| g(p_n)$. That is, we simply sum up all the “prime indigestibilities” $g(p)$, taking into account their absolute multiplicities. The prime indigestibilities in turn are defined using Barlow's formula: $g(p) = 2(p-1)^2/p$. Thus, for instance, $g(5/4) = 2 \times (4^2/5) + 2 \times 2 \times (1^2/2) = 8.4$. (There are alternative formulas for the prime indigestibilities which can be used here, such as $g(p) = p-1$ which is related to Euler's “gradus suavitatis”; please see [7] for details.)

The above formula maps the harmonicity of the unison to 1 (rather than infinity, as in Barlow's original formula $h(x) = 1/g(x)$), which is more convenient to handle computationally. We also “factor out” octaves by just setting $g(2) = 0$, since in our application we are only concerned with tone classes rather than absolute pitches. Now, given some input notes $x_1, \ldots, x_n$, we can assign a harmonicity measure to a “candidate note” $y$ by computing the average harmonicity

$$ \bar{h}(x_1, \ldots, x_n; y) = \sqrt[q]{h(q(x_1, y)) \cdots h(q(x_n, y))}, $$

where $q(x, y)$ denotes the integer ratio assigned to the interval between some notes $x$ and $y$. (Note that we employ a geometric mean here, which appears to work better in this context than the arithmetic mean.) Of course, Raptor works with MIDI notes, to accommodate for that we can simply map the absolute difference between $x$ and $y$ (which is the number of semitones in the interval) to the corresponding integer ratio in a precomputed rationalization of the 12 tone equal temperament scale and then compute the corresponding harmonicity value from that ratio.

As is discussed in [7], the “disharmonicity” function $g$ provides a measure for the complexity of a rational interval, which is empirically related to its “sonance” (consonance or dissonance). In fact, it turns out that if we define $d(x, y) = g(x/y)$ for each rational scale points $x, y$, then the resulting harmonic distance function $d$ is a metric in the mathematical sense. This provides (heuristic) justification for our use of the harmonicity values derived from this metric for musical purposes.

For the pulse weights, we employ Barlow's indispensability formula from [5] as is. This formula is a lot more complicated,

as the goal is to provide a single formula which deals with even the most complex time signatures, and still yields pulse weights which sound convincingly. We assume that the meter is given in a “stratified” form, as a list of prime numbers $q_1, \ldots, q_n$, going from the topmost level $q_1$ of divisions of the bar, to the lowest level $q_n$ (the basic beat). $N = q_1 q_2 \cdots q_n$ is the total number of beats at the lowest level.

We then define the indispensability $I_{q_1, \ldots, q_n}(k)$ of beat $k = 1, \ldots, N$ as

$$ \sum_{i=1}^{n} q_1 \cdots q_{i-1} P_{q_i} \left( \left\lfloor \frac{(k-2) \bmod N}{q_{i+1} \cdots q_n} + 1 \right\rfloor \bmod q_i + 1 \right) $$

Here $P_q(k)$ are the prime indispensabilities ($k = 1, \ldots, q$), $q_1 \cdots q_{i-1}$ the number of beats above, and $q_{i+1} \cdots q_n$ the number of beats below the $i$th level ($i = 1, \ldots, n$). The prime indispensabilities in turn are defined as follows:

* If $q \le 3$, then for $k = 1, \ldots, q$:

$$ P_q(k) = (k - 2) \bmod q $$

* If $q > 3$, then for $k = 1, \ldots, q$:

$$ P_q(k) = \begin{cases} \lfloor q/4 \rfloor, & k = q - 1 \\ I'_{q-1}(k-1), & k = q \\ I'_{q-1}(k), & \text{otherwise} \end{cases} $$

The indispensabilities $I'$ for prime factor $q$ in the latter formula are defined recursively in terms of the indispensabilities for a down-by-1 number of subdivisions $q-1$ as follows:

$$ I'_{q-1}(k) = \begin{cases} I_{PF(q-1)}(k) + 1, & I_{PF(q-1)}(k) \ge \lfloor q/4 \rfloor \\ I_{PF(q-1)}(k), & \text{otherwise} \end{cases} $$

where $PF(q-1)$ are the prime factors of $q-1$ in descending order.

The basic idea is that in order to come up with the indispensabilities for a prime $q$, you take the (general) indispensabilities for $q-1$ beats stratified as $PF(q-1)$, add a new pulse with indispensability $\lfloor q/4 \rfloor$ at the second-last position, and increment all existing indispensabilities at or above this value by 1. This makes sure that all resulting weights are unique again. For instance, a meter with 5 beats will be reduced to 4 beats with weights 3-0-2-1 (as calculated recursively). Then we increment all weights $\ge \lfloor 5/4 \rfloor = 1$, yielding **4-0-3-2**, and insert a new pulse with weight $\lfloor 5/4 \rfloor = 1$ at the second-last position, which yields the final result **4-0-3-1-2**.

I don't think that anyone really knows how Barlow came up with this formula. All I can say is that it seems to work reasonably well, at least with the usual kind of complex meters I tried it with, involving prime subdivisions of up to 11. Note that I have taken apart the original formula from [5] into its constituent parts in order to make it more readable and clarify what is going on there. This formulation is also how the indispensability function is implemented in the Raptor program.