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.

note

Synthesize a basic musical note.

note_with_phase

Synthesize a basic musical note with a phase.

note_with_vibrato

Synthesize a musical note with a vibrato.

note_with_two_vibratos

A note with a vibrato that also has a secondary oscillatory pattern.

note_with_glissando

A note with a pitch transition: a glissando.

note_with_glissando_vibrato

A note with a pitch transition (a glissando) and a vibrato.

note_with_two_vibratos_glissando

A note with a glissando and a vibrato that also has a secondary oscillatory pattern.

note_with_vibratos_glissandos

A note with an arbitrary sequence of pitch transition and a meta-vibrato.

note_with_vibrato_seq_localization

A sound with arbitrary meta-vibratos, transitions of frequency and localization.

note_with_fm

Synthesize a musical note with FM synthesis.

note_with_doppler

A simple note with a transition of localization and resulting Doppler effect.

trill

Makes a trill.

Envelopes and noise

am

Synthesize an AM envelope or apply it to a sound.

tremolo

Synthesize a tremolo envelope or apply it to a sound.

tremolos

An envelope with multiple tremolos.

noise

Return a colored or user-refined noise.

gaussian_noise

Synth gaussian noise

silence

Generate a silence of specified length.

Filters

Amplitude

adsr

Synthesize an ADSR envelope.

adsr_stereo

A shorthand to make an ADSR envelope for a stereo sound.

adsr_vibrato

Creates a note with a vibrato and an ADSR envelope.

fade

A fade in or out.

cross_fade

Cross fade in duration milisseconds.

loud

An envelope for a linear or exponential transition of amplitude.

louds

An envelope with linear or exponential transitions of amplitude.

Spectral and spatial

fir

Apply a FIR filter to a sonic_array.

iir

Apply an IIR filter to a signal.

reverb

Apply an artificial reverberation or return the impulse response.

localize

Make a mono sound stereo and localize it by a very naive method.

localize2

Make a mono sound stereo and localize it by experimental methods.

localize_linear

Localize a sound along a straight path between two angles.

stretches

Makes a sequence of squeezes of the fragment in x.

Input and output

read_wav

Reads a WAV file and return an array of its values.

write_wav_mono

Writes a mono WAV file for a numpy array.

write_wav_stereo

Write a stereo WAV files for a numpy array.

play_audio

Play a sonic vector using the sounddevice library.

normalize_mono

Normalize a mono sonic vector.

normalize_stereo

Normalize a stereo sonic vector.

Sequencing

Sequencer

Schedules notes and renders them as audio.

Musical structures

Permutations, algebraic groups and change-ringing peals.

InterestingPermutations

Get permutations of n elements in meaningful sequences.

transpose_permutation

Transposes (shifts) the elements of a permutation by a given step.

dist

Computes the cyclic distance between the two elements of a permutation.

GenericPeal

A collection of named peals that can be acted on a domain.

Peals

Uses permutations to make peals and represents peals as permutations.

PlainChanges

Presents plain changes as swaps and acts in domains to make peals.

print_peal

Prints a peal with colored numbers.

Utilities

Conversions

hz_to_midi

Converts a frequency in Hertz to a MIDI note number.

midi_to_hz

Converts a MIDI note number to the corresponding frequency in Hertz.

midi_to_hz_interval

Converts a MIDI interval to the corresponding frequency interval in

pitch_to_freq

Generates a list of frequencies based on a list of semitones and a starting frequency.

db_to_amp

Converts a difference in decibels to a difference in amplitude.

amp_to_db

Converts a difference in amplitude to a difference in decibels.

rhythm_to_durations

Returns durations from rhythmic patterns.

Combining sonic vectors

horizontal_stack

Creates a horizontal stack of arrays while preserving bidimensional

mix

Mixes two sonic vectors.

mix2

Mix sonic vectors of arbitrary lengths.

mix_stereo

Mixes two stereo sonic vectors.

mix_with_offset

Mix two sonic vector by placing the beginning of the second one a specified number of seconds after the first one.

mix_with_offset_

Mix sonic vectors with offsets.

convert_to_stereo

Converts a sound vector to stereo format.

resolve_stereo

Resolve stereo arguments for a function.

pan_transitions

Applies pan transitions to a sonic vector.

profile

Wavetables

PrimaryTables

Provides primary tables for waveform lookup.

The module-level constants WAVEFORM_SINE, WAVEFORM_TRIANGULAR, WAVEFORM_SQUARE and WAVEFORM_SAWTOOTH in music.utils are the lookup tables used by default throughout the package.

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.

setup_engine

Clone the eCantorix repository into the user's cache directory.

get_engine

Return the path to the local eCantorix engine.

make_test_song

Render a short sung phrase, to check the engine works.

Legacy

Synthesizer classes kept for backwards compatibility, and as material for making more music.

Being

A configurable sequence walker that renders notes.

CanonicalSynth

Simple synthesizer for sound synthesis with vibrato, tremolo, and ADSR.

IteratorSynth

A synthesizer that iterates through arbitrary lists of variables.