aleatora package

Submodules

aleatora.audio module

aleatora.audio.get_playback_stream(streams)
aleatora.audio.play(*streams, mix=False)
aleatora.audio.play_callback(outdata, frames, time, status)
aleatora.audio.play_record_callback(indata, outdata, frames, time, status)
aleatora.audio.run(*streams, blocksize=0)
aleatora.audio.setup(device=None, channels=1, input=False, **kwargs)
aleatora.audio.volume(vol=None)

aleatora.chord module

class aleatora.chord.chord(descriptor, name=None, notes=None, inv=0, oct=4)

Bases: object

Simple chord class.

Create from MIDI notes via chord([60,64,67]) or by name via chord(‘C’), optionally specifiying the inversion and octave.

alberti(dur=0.125)
arp(dur=0.125)
aleatora.chord.get_chord_by_name(name, inv, oct)
aleatora.chord.spn_to_pitch(cls, oct)

Convert Scientific Pitch Notation (pitch class + octave) to a numeric (MIDI) pitch.

aleatora.fauxdot module

aleatora.fauxdot.GeneratorPattern_getitem(self, index=None, *args)

Calls self.func(index) to get an item if index is not in self.history, otherwise returns self.history[index]

aleatora.fauxdot.beat(pattern, dur=0.5, sus=None, delay=0, amp=1, bpm=120, sample=0)
aleatora.fauxdot.buffer_free(buffer)
aleatora.fauxdot.buffer_read(buffer)
aleatora.fauxdot.event_stream(degree, dur=1, sus=None, delay=0, amp=1, bpm=120, sample=0)
aleatora.fauxdot.pattern_to_stream(patternish)
aleatora.fauxdot.tune(degree, dur=1, sus=None, delay=0, amp=1, bpm=120, root=0, scale=P[0, 2, 4, 5, 7, 9, 11], oct=5)

aleatora.filters module

aleatora.filters.bpf(stream, f, q=1.0)
aleatora.filters.feed(stream, buffer_size, fn)
aleatora.filters.hpf(stream, f, q=1.0)
aleatora.filters.lpf(stream, f, q=1.0)
aleatora.filters.notch(stream, f, q=1.0)
aleatora.filters.var_comb(stream, amp, delay_stream, max_delay)

aleatora.midi module

Support for event streams, messages, instruments, MIDI devices, and MIDI files.

This module includes functions for working with MIDI devices and files, but it also describes a basic interface for _events_ and _instruments_ which is useful even if you don’t care about MIDI itself.

A event consists of some data; for example, a typical MIDI message like Message(type=’note_on’, note=60, velocity=100). The important thing is that events do not include timing information. Instead, the timing is inherent in the event stream. Event streams consist of tuples of events. The timestamp of an event is given by its position in the stream. At any point in the stream, multiple events may occur simultaneously (tuple of length > 1), or no events may occur (empty tuple).

Because event streams yield tuples, they may be composed in parallel by addition: event_stream_a + event_stream_b creates a combined event stream with all the events from both.

An _instrument_ is any function that takes an event stream and returns a sample stream.

Example usage: play(midi.poly_instrument(midi.input_stream()))

class aleatora.midi.Message(type, note, velocity=None)

Bases: object

aleatora.midi.input_stream(port=None)
aleatora.midi.make_poly(monophonic_instrument, persist_internal=False)
aleatora.midi.poly(monophonic_instrument=None, persist_internal=False)
aleatora.midi.sampler(mapping, fade=0.01)

Instrument that maps MIDI pitches to streams. Resamples to account for octave jumps.

aleatora.midi.save(stream, filename, rate=None, bpm=120)

aleatora.net module

class aleatora.net.OSCMessage(address, tags, args, index)

Bases: tuple

property address

Alias for field number 0

property args

Alias for field number 2

property index

Alias for field number 3

property tags

Alias for field number 1

aleatora.plugins module

class aleatora.plugins.Plugin(path, block_size, sample_rate, volume_threshold, instrument)

Bases: object

class aleatora.plugins.PluginEditor(instance)

Bases: object

close()
on_close()
open()
wait()
class aleatora.plugins.PluginInstance(plugin, input_stream, plugin_params, sample_rate, block_size, volume_threshold, instrument)

Bases: aleatora.streams.core.Stream

load(path)
run()
run_with_events(**kwargs)
run_with_samples(**kwargs)
save(path)
aleatora.plugins.cleanup()
aleatora.plugins.load(path, block_size=512, sample_rate=48000, volume_threshold=2e-06, instrument=False)
aleatora.plugins.load_instrument(path, block_size=512, sample_rate=48000, volume_threshold=2e-06)
aleatora.plugins.setup()

aleatora.profile module

Profile streams.

Example usage:

>>> from aleatora import osc, profile
>>> _ = list(profile('osc', osc(440)[:10.0]))
>>> _ = list(profile('mix', (osc(440) + osc(660))[:10.0]))
>>> profile.dump()
Real-time budget: 22.676us per sample
osc: 441001 calls (1 ending)
    0.098us avg | 0.043s total | 0.43% of budget
mix: 441001 calls (1 ending)
    0.226us avg | 0.099s total | 0.99% of budget
>>> profile.reset()
class aleatora.profile.profile(key, stream)

Bases: object

Profile streams.

Example usage:

>>> from aleatora import osc, profile
>>> _ = list(profile('osc', osc(440)[:10.0]))
>>> _ = list(profile('mix', (osc(440) + osc(660))[:10.0]))
>>> profile.dump()
Real-time budget: 22.676us per sample
osc: 441001 calls (1 ending)
    0.098us avg | 0.043s total | 0.43% of budget
mix: 441001 calls (1 ending)
    0.226us avg | 0.099s total | 0.99% of budget
>>> profile.reset()
data = {}
static dump()

Print out collected profiling data.

static reset()

Reset profiler.

aleatora.speech module

aleatora.speech.fix_song(song, divide_duration=True)
aleatora.speech.gen_xml(song)
aleatora.speech.get_num_syllables(text)
aleatora.speech.sing(*args, divide_duration=True, voice='us1_mbrola')
aleatora.speech.speech(text, lang='en', slow=False, tld='com', filename=None)

If filename is provided, load precomputed speech from that if it exists; otherwise save to it. (This is better than freezing because the audio is compressed, as provided by the server.)

aleatora.wav module

aleatora.wav.load(filename, resample=False, multichannel=False)
aleatora.wav.load_array(filename, resample=False)
aleatora.wav.save(comp, filename, chunk_size=16384, verbose=False)

Module contents

Music composition framework based on streams.