API Reference
Basic
Contains basic functions for generating and manipulating sound waves.
composition(f, g)
envelope(f, multiplier)
Returns a function that is the given function multiplied by the given envelope.
sawtooth(freq)
scale(f, factor)
shift(f, offset)
sine(freq)
square(freq)
stack(fs)
strip(f, start, end)
Timbre
Different timbres.
default_piano()
piano(overtunes_multiplier)
Returns a timbre that sounds like a piano. It has overtones proportional to base frequency for n in overtunes_multiplier.
Note: overtunes_multiplier[0] should be 1 in most cases in order to preserve base frequency loudness.
Source code in anymusic/timbre.py
sawtooth_timbre()
sine_timbre()
square_timbre()
Tuning
Make human-recognizable regular sounds.
equal_step_tuning(base_freq, base, eqtm)
Traditional music tuning systems use C * 2^( a + b * 1/12 ) as the frequency where it is the a * 12 + b semitones above the base frequency. However it can be further generalized to C * BASE^( a + b * EQTM ) where EQTM is the equal temperament.
For example, for a 24-EDO scale, BASE is 2 and EQTM is 1/24.
Source code in anymusic/tuning.py
Utils
Miscellaneous functions.
fade_out_exp(lasting, exp)
fade_out_linear(lasting)
note_to_audio(note, tuning, timbre, effect=None)
Returns the audio of the given note. It will be shifted and stripped to the given start and end time.
Source code in anymusic/util.py
Wave
Wave file manipulation.
read_file(filename)
Reads a wave file. Note that it may take a lot of memory if the file is large.
Source code in anymusic/wave.py
write_and_normalize_file(filename, f, duration, framerate=44100, sampwidth=2, progress_bar_interval=50000)
A variant of write_file that normalizes the audio into [-1, 1] before writing. Note that it takes double the time as it tries to sample the entire Audio function into memory and find the maximum amplitude.
Source code in anymusic/wave.py
write_file(filename, f, duration, framerate=44100, sampwidth=2, progress_bar_interval=50000)
Writes a wave file. If progress_bar_interval is not None, then a progress bar will be printed to the console
every progress_bar_interval frames.