API reference¶
Every name below is re-exported from the top level: music.note(...) works
regardless of which submodule defines it.
Synthesis¶
Notes¶
Each returns a numpy array of PCM samples. note is the plain wavetable
lookup; the rest layer vibrato, pitch transitions, frequency modulation and
movement onto it.
Synthesize a basic musical note. |
|
Synthesize a basic musical note with a phase. |
|
Synthesize a musical note with a vibrato. |
|
A note with a vibrato that also has a secondary oscillatory pattern. |
|
A note with a pitch transition: a glissando. |
|
A note with a pitch transition (a glissando) and a vibrato. |
|
A note with a glissando and a vibrato that also has a secondary oscillatory pattern. |
|
A note with an arbitrary sequence of pitch transition and a meta-vibrato. |
|
A sound with arbitrary meta-vibratos, transitions of frequency and localization. |
|
Synthesize a musical note with FM synthesis. |
|
A simple note with a transition of localization and resulting Doppler effect. |
|
Makes a trill. |
Sensory stimulation¶
Stimuli for sensory-stimulation work, each rendering one technique catalogued in SSTIM, the Sensory Stimulation Vocabulary. Every docstring names the SSTIM term it implements and states whether the modulation is physically present in the signal or constructed by the listener.
Synthesize a binaural beat: |
|
Synthesize a monaural beat: |
|
Synthesize an isochronic tone train: |
|
Sinusoidally modulate a carrier: |
|
Sweep a carrier's pitch: |
|
Modulate a band of noise: |
|
Orbit a source around the listener: |
A protocol is a sequence of those rather than one of them.
StimulationSession holds that sequence and renders it as
one sound, joining the phases with crossfades centred on their boundaries
so that the session lasts exactly the sum of the durations it was given.
A sequence of stimuli rendered as one sound. |
|
One phase of a session: a stimulus, for a while, ramped into. |
Envelopes and noise¶
Filters¶
Amplitude¶
Synthesize an ADSR envelope. |
|
A shorthand to make an ADSR envelope for a stereo sound. |
|
Creates a note with a vibrato and an ADSR envelope. |
|
A fade in or out. |
|
Cross fade two sounds over duration milliseconds. |
|
An envelope for a linear or exponential transition of amplitude. |
|
An envelope with linear or exponential transitions of amplitude. |
Spectral and spatial¶
Apply a FIR filter to a sonic_array. |
|
Apply an IIR filter to a signal. |
|
Apply an artificial reverberation or return the impulse response. |
|
Make a mono sound stereo and localize it by a very naive method. |
|
Make a mono sound stereo and localize it by experimental methods. |
|
Localize a sound along a straight path between two angles. |
|
Place a mono sound with a measured pair of impulse responses. |
|
Makes a sequence of squeezes of the fragment in x. |
Filter design¶
iir applies coefficients; these compute them, from the four designs the
MASS article specifies. Cutoff, centre and bandwidth are fractions of the
sample rate, which fraction_of converts a frequency in Hertz into.
A one-pole low pass, from the article's equation |
|
A one-pole high pass, from the article's equation |
|
A two-pole band pass, from the article's |
|
A two-pole notch, from the article's |
|
A frequency in Hertz, as the fraction of the sample rate a design wants. |
Input and output¶
Read an audio file and return an array of its values. |
|
The name |
|
Write a sound to a file, mono or stereo, WAV or FLAC. |
|
Writes a mono WAV file for a numpy array. |
|
Write a stereo WAV files for a numpy array. |
|
Play a sonic vector using the |
|
Normalize a mono sonic vector. |
|
Normalize a stereo sonic vector. |
Sequencing¶
Schedules notes and renders them as audio. |
Musical structures¶
Permutations, algebraic groups and change-ringing peals.
Get permutations of n elements in meaningful sequences. |
|
Transposes (shifts) the elements of a permutation by a given step. |
|
Computes the cyclic distance between the two elements of a permutation. |
|
A collection of named peals that can be acted on a domain. |
|
Uses permutations to make peals and represents peals as permutations. |
|
Presents plain changes as swaps and acts in domains to make peals. |
|
Prints a peal with colored numbers. |
Music theory¶
Scales, chords and the harmonic series, counted in semitones from a tonic or
root of zero – which is what pitch_to_freq takes, so any of these
becomes frequencies and then sound in two steps.
The semitones of a named scale, counted from tonic. |
|
A diatonic mode, built by rotating the steps as |
|
The first partials harmonics, in semitones above the fundamental. |
|
The semitones of a named chord, counted from root. |
|
One more third on top of a triad. |
|
Move one note of a chord by whole octaves. |
|
The number of semitones in an interval, from its traditional name. |
|
Every traditional name for an interval of this many semitones. |
|
The interval in semitones between two frequencies, rounded. |
|
How the article classifies an interval. |
The tables these read from are exported too: SCALES, MODES,
MINOR_SCALES and DIATONIC_STEPS for the scales, CHORDS,
TRIADS and SEVENTHS for the chords, and
HARMONIC_SERIES_AS_PRINTED for the article’s own table of partials, and
SIMPLE_INTERVALS and CONSONANCE for the intervals.
Bonds¶
Relations tying a note’s vibrato and tremolo to its frequency, so that a piece decides once how its notes behave rather than note by note.
A set of relations tying a note's characteristics to its frequency. |
|
A bond that rises with the frequency: |
|
A bond that falls with the frequency: |
|
A bond that changes in steps rather than continuously. |
Utilities¶
Conversions¶
Converts a frequency in Hertz to a MIDI note number. |
|
Converts a MIDI note number to the corresponding frequency in Hertz. |
|
Converts a MIDI interval to the corresponding frequency interval in |
|
Generates a list of frequencies based on a list of semitones and a starting frequency. |
|
Converts a difference in decibels to a difference in amplitude. |
|
Converts a difference in amplitude to a difference in decibels. |
|
Returns durations from rhythmic patterns. |
Combining sonic vectors¶
Creates a horizontal stack of arrays while preserving bidimensional |
|
Mixes two sonic vectors. |
|
The name this had while it was the second mixer rather than the general one. |
|
Mix sonic vectors of arbitrary lengths. |
|
Mix any number of sonic vectors, each at its own offset. |
|
Mixes two stereo sonic vectors. |
|
Mix two sonic vector by placing the beginning of the second one a specified number of seconds after the first one. |
|
The name this had before it was renamed for saying, in the name, how it differs from |
|
Converts a sound vector to stereo format. |
|
Resolve stereo arguments for a function. |
|
Applies pan transitions to a sonic vector. |
|
Summarize a namespace of variables. |
Wavetables¶
Provides primary tables for waveform lookup. |
|
One period of a primary waveform, as a lookup table. |
WAVEFORM_SINE, WAVEFORM_TRIANGULAR, WAVEFORM_SQUARE and
WAVEFORM_SAWTOOTH are the lookup tables used by default throughout the
package, and are the names that appear in the synthesis signatures above.
They are re-exported from the top level like everything else, so
music.note(waveform_table=music.WAVEFORM_SINE) works;
music.WAVEFORMS names the shapes waveform_table() can build.
Singing¶
Text-to-speech built on the external eCantorix engine. Run setup_engine() once to
clone it; it also needs git, make, perl and espeak on the
system.
Clone the eCantorix repository into the user's cache directory. |
|
Return the path to the local eCantorix engine. |
|
Render a short sung phrase, to check the engine works. |
Legacy¶
Synthesizer classes kept for backwards compatibility, and as material for making more music.
A configurable sequence walker that renders notes. |
|
Simple synthesizer for sound synthesis with vibrato, tremolo, and ADSR. |
|
A synthesizer that iterates through arbitrary lists of variables. |