All Projects → lewiswolf → Temperament-Generator

lewiswolf / Temperament-Generator

Licence: other
Real time microtuning in Max MSP and Max for Live

Programming Languages

Max
122 projects
javascript
184084 projects - #8 most used programming language

Temperament Generator

by Lewis Wolf

Written in Max MSP v.8+

Dependencies: bach library v0.8.0b+

The Temperament Generator was developed for real time implementations of microtonal tunings, for use in both compositional and performative settings. The patch works both as a standalone application, running in Max MSP, as well as in Max for Live, with only a small amount of user patching necessary.

There is also a demonstration video for this project.

Basic Use Guide

The Temperament Generator takes in raw MIDI and outputs MIDI with precise pitch bend values relative to the user defined mapping and temperament. The output can be formatted either as standard 14-bit pitch bend values, or as three CC messages primarily for use with Kontakt (for more information on using this patch with Kontakt, see my dedicated repository). Both outputs make use of all 16 MIDI channels to allow for notes to be independently tuned. By toggling Fluid to on, the intonation of held notes can be changed immediately, however this is achieved by repeatedly resending the held MIDI message with the updated pitch bend values, and may cause unwanted interferance.

A user can create up to 10 simultaneous temperaments and map them onto a MIDI device. For each temperament, there are three basic modes available.

  • EQ
    for creating equally divided temperaments.
  • Scala
    for importing .scl files and typing out your own in the console. The syntax for this is documented by Scala file format specification.
  • Series
    for parsing sequential equations, such as those that generate the harmonic series. The syntax for this mode is documented in the bach.expr helpfile contained within the bach library. k is used to represent the sequence of integers 1 <= k <= n where n is the number of Notes detailed in the table below.

When creating each temperament, information is entered into a table like the one shown here.

Type Reference Top Notes Multiplier
EQ 440 880 12 1

This input produces 12TET, with 440hz as a reference pitch and 880hz as a repeat point (octave or psuedo-octave). With Multiplier set to 1, the temperament will cover the entire 128 MIDI note range. When set to 0 this temperament bypasses the Multipler, and all that will be output is 12 pitches between 440hz and 830.61...hz (A4 - G#5). Reference and Top frequencies can be input as floating points or integers, and Top also accepts ratio values (i.e 2/1).

When working in Scala, the psuedo-octave is supplied by the syntax. Changing the Top frequency instead distorts the temperament, whilst maintaing relative interval structure. This is similar to working in Series, such that when using the Pythagorus preset (log(k)/log(2)) to create the harmonic series, this can also be distorted by changing the value for Top, again whilst maintaining relative interval structure.

The Mapping can be calibrated using the Mapping Settings which offers two methods for mapping structures depnding on whether or not they are multiplied.

  • General Settings
    The global output range can be specified here, however the default values correlate to MIDI note 0 and 127.

  • Without Multiplier (Group 0)
    When using this setting, Temperaments are ordered according to the order in which they were input into the table. The reference MIDI note is used to determine the starting note for all Group 0 Temperaments. Group 0 temperaments can either overdub notes generated by Group 1, or be inserted inbetween them.

  • With Multiplier (Group 1)
    Temperaments are merged such that all pitches fall in order and cover the entire 128 MIDI note range. The reference MIDI note corresponds to the reference pitch of a given structure, such that, if the reference pitch is 440hz and the reference note is D5, playing D5 will produce 440hz and all pitches surrounding it will be ordered accordingly.

Using the Temperament Generator with your own Max MSP and Max for Live patches

When using the Temperament Generator with Max for Live, it is important to note that Live does not support the use of mutliple MIDI channels. There have been many workarounds devised to get around this, however to simplify the matter, the Temperament Generator should be used within a Max Instrument, and not as a seperate Max MIDI device. A typical setup is shown in the 'demo amxd' folder.

To help speed up the process of using the Temperament Generator with your own Max MSP or Max for Live patches, a bpatcher and an abstraction have also been supplied.

  • midibae
    This bpatcher is designed to work sympathetically with a poly~. The left outlet outputs MIDI notes (pitch and velocity), as well as target & legacynotemode messages for the poly~. These are controlled using Ignore MIDI Channel/Target MIDI Channel. Target MIDI Channel targets poly~ voices relative to the incoming MIDI channel, and is used to make sure pitch bend values are always paired with the correct MIDI note. When using Target MIDI Channel, it is recommended that your poly~ have 16 voices - one for each MIDI channel. The middle outlet outputs 14bit MIDI pitch bend values. The right outlet outputs raw MIDI.

  • pitchbend
    This works similarly to the mtof object in Max, but takes pitch bend values in the right inlet. Outputs frequency from the left outlet and cents from the right outlet. 0 cents = 440hz.

midibae and the Temperament Generator both accept raw MIDI in the left inlet, as well as two messages.

  1. M4L 1 and M4L 0 which is necessary to tell the patcher whether or not it is running in Max for Live. In both patchers this sets the MIDI input to come from the leftmost inlet rather than an internal midiin.

  2. allnotesoff which should be used to prevent stuck notes.

midibae also accepts the messages mc 1 and mc 0 which toggle Target MIDI Channel. The right inlet is used for cosmetic purposes, and can show or hide various UI elements.

  • target
  • default
  • panic

The right inlet of the Temperament Generator is reserved for use with pcontrol and other messages to thispatcher.

Automation & Presets

When in Live, the Reference, Top & Notes settings can be automated via the automation lanes.

  • Ref - Reference
  • Top - Top
  • Div - Notes

Automation can also be controlled using several global sends from within Max.

  • s autoPRE - to select presets
  • s autoREF - Reference
  • s autoTOP - Top
  • s autoDIV - Notes

It should be noted that automation functionality is limited, and both the sends and automation lanes will only effect the individual Temperament last changed/selected. For best results, reserve automation for use with only one temperament or switching between presets.

Presets are global, and are stored in the parent folder. Updating presets whilst in Live will automatically update all instances of the patcher.

File I/O

The Temperament Generator is capable of loading scala tuning files (.scl) and can also export scala tuning files, Anamark tuning files (.tun) and spreadsheets (.csv). The exported scala file targets the currently selected temperament, transposed relative to 0 cents. The exported spreadsheet contains the complete mapping of the 128 MIDI note range. Any unused MIDI notes will not appear in the spreadsheet.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].