experimental.quantizer
Shared classes for quantization support
@author Chris Iverach-Brereton <ve4cib@gmail.com> @year 2023
- class experimental.quantizer.CommonScales
A collection of common scales that can be used in other scripts to support quantization
The Major135[6|7] and Minor135[6|7] scales are inspired by the Doepfer A-156 quantizer
- class experimental.quantizer.Intervals
A collection of musical intervals as indices for the Quantizer __get_item__ and __set_item__ methods
For example, if you have a Quantizer and want to enable the Perfect4th you can simply use
q = Quantizer(...) q[Intervals.P4] = True
This class uses the short notation for intervals. See https://en.wikipedia.org/wiki/Interval_(music) for more information.
The abridged summary: * single case-sensitive letter for the interval type * a number from 1-8 indicating the size of the interval * P = perfect * M = major * m = minor * d = diminished * A = augmented * three exceptions: S = semitone (equivalent to m2/A1), T = Tone (equivalent to M2/d3), TT = Tritone (equivalent to d5/A4)
- class experimental.quantizer.Quantizer(notes=None, name='')
Represents a set of semitones we can quantize input voltages to
By default this represents a chromatic scale, with all notes enabled. Notes can be changed by setting scale[n] = True/False, where n is the index of the semitone to toggle
Implements __get_item__ and __set_item__ so you can use Quantizer like an array to set notes on/off
- Parameters
notes – A boolean array of length SEMITONES_PER_OCTAVE indicating what semitones are enabled (True) or disabled (False). If None, all notes are enabled. If not-none, the provided array is copied into this instance.
name – The human-readable name for this scale. The name can be displayed on the module’s screen by some scripts.
- Raises
ValueError – if len(notes) is not equal to SEMITONES_PER_OCTAVE
- quantize(analog_in, root=0)
Take an analog input voltage and round it to the nearest note on our scale
- Parameters
analog_in – The input voltage to quantize, as a float
root – An integer in the range [0, 12) indicating the number of semitones up to transpose the quantized scale
- Returns
A tuple of the form (voltage, note) where voltage is the raw voltage to output, and note is a value from 0-11 indicating the semitone