コード例 #1
0
def test_pdegree():
    a = iso.PDegree(iso.PSequence([0, 1, -1, None, 7], 1))
    assert list(a) == [0, 2, -1, None, 12]

    # Test on array values
    a = iso.PDegree(iso.PSequence([[0, 1], [2, 3], [None, -1]], 1))
    assert list(a) == [(0, 2), (4, 5), (None, -1)]
コード例 #2
0
#!/usr/bin/env python3

#------------------------------------------------------------------------
# isobar: ex-lsystem-stochastic
#
# Generates a stochastic L-system arpeggio
#------------------------------------------------------------------------

import isobar as iso

import logging
logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s")

notes = iso.PLSystem("N[+N--?N]+N[+?N]", depth=4)
notes = iso.PDegree(notes, iso.Scale.majorPenta)
notes = notes % 36 + 52

timeline = iso.Timeline(180)

timeline.schedule({"note": notes, "duration": 0.25})
timeline.run()
コード例 #3
0
#!/usr/bin/env python3

#------------------------------------------------------------------------
# isobar: ex-subsequence
#------------------------------------------------------------------------

import isobar as iso

import logging
logging.basicConfig(level=logging.DEBUG, format="[%(asctime)s] %(message)s")

scale = iso.Scale.pelog
sequence = iso.PDegree(iso.PBrown(0, 3, -12, 12), scale)

offset = iso.PStutter(iso.pattern.PWhite(0, 4), 2)
sequence = iso.PSubsequence(sequence, offset, 4)
sequence = iso.PPermut(sequence)
sequence = sequence + 64
sequence = iso.PReset(sequence, iso.PImpulse(24))

amp = iso.pattern.PSequence([45, 35, 25, 40]) + iso.PBrown(0, 1, -15, 10)

gate = iso.pattern.PBrown(1.5, 0.01, 0.6, 2.5)

timeline = iso.Timeline(120)
timeline.schedule({
    "note": sequence.copy(),
    "amplitude": amp.copy(),
    "duration": 0.25,
    "gate": gate.copy()
})
コード例 #4
0
ファイル: 04.ex-permutations.py プロジェクト: muteboy/isobar
#
# Use simple permutations to generate intertwining musical structures.
#------------------------------------------------------------------------

import isobar as iso
import random

import logging
logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s")

#------------------------------------------------------------------------
# Create a pitch line comprised of multiple permutations on a pelog scale
#------------------------------------------------------------------------
ppitch = iso.PShuffle([random.randint(-6, 6) for n in range(6)])
ppitch = iso.PPermut(ppitch)
ppitch = iso.PDegree(ppitch, iso.Key("F#", "pelog"))

#------------------------------------------------------------------------
# Create permuted sets of durations and amplitudes.
# Different lengths mean poly-combinations.
#------------------------------------------------------------------------
pdur = iso.PShuffle([1, 1, 2, 2, 4], 1)
pdur = iso.PPermut(pdur) / 4

pamp = iso.PShuffle([10, 15, 20, 35], 2)
pamp = iso.PPermut(pamp)

#------------------------------------------------------------------------
# Schedule on a 60bpm timeline and send to MIDI output
#------------------------------------------------------------------------
timeline = iso.Timeline(60)
コード例 #5
0
#
# Brownian walk around a scale.
#------------------------------------------------------------------------

import isobar as iso

import logging

logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s")

#------------------------------------------------------------------------
# walk up and down a minor scale
#------------------------------------------------------------------------
scale = iso.Scale([0, 2, 3, 7, 9, 11])
degree = iso.PBrown(0, 2, -8, 16)
notes = iso.PDegree(degree, scale) + 60

#------------------------------------------------------------------------
# add a slight 4/4 emphasis and moderate variation in velocity
#------------------------------------------------------------------------
amp = iso.PSequence([40, 30, 20, 25]) + iso.PBrown(0, 2, -10, 10)

timeline = iso.Timeline(170)
timeline.schedule({
    "note": notes,
    "duration": 0.25,
    "gate": 0.9,
    "amplitude": amp
})

try:
コード例 #6
0
#------------------------------------------------------------------------

import isobar as iso

#------------------------------------------------------------------------
# Turn on some basic logging output. 
#------------------------------------------------------------------------
import logging
logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s")

#------------------------------------------------------------------------
# Create a geometric series on a minor scale.
# PingPong plays the series forward then backward. PLoop loops forever.
#------------------------------------------------------------------------
arpeggio = iso.PSeries(0, 2, 6)
arpeggio = iso.PDegree(arpeggio, iso.Scale.minor) + 72
arpeggio = iso.PPingPong(arpeggio)
arpeggio = iso.PLoop(arpeggio)

#------------------------------------------------------------------------
# Create a velocity sequence, with emphasis every 4th note,
# plus a random walk to create gradual dynamic changes.
# Amplitudes are in the MIDI velocity range (0..127).
#------------------------------------------------------------------------
amplitude = iso.PSequence([50, 35, 25, 35]) + iso.PBrown(0, 1, -20, 20)

#------------------------------------------------------------------------
# Create a repeating sequence with scalar transposition:
# [ 36, 38, 43, 39, 36, 38, 43, 39, ... ]
#------------------------------------------------------------------------
bassline = iso.PSequence([0, 2, 7, 3]) + 36
コード例 #7
0
import isobar as iso
from isobar.io import MidiFileOutputDevice

import logging
logging.basicConfig(level=logging.DEBUG, format="[%(asctime)s] %(message)s")

key = iso.Key("C", "major")

filename = "output.mid"
output = MidiFileOutputDevice(filename)

timeline = iso.Timeline(iso.MAX_CLOCK_RATE, output_device=output)
timeline.stop_when_done = True

timeline.schedule({
    "note": iso.PDegree(iso.PSequence([ 0, 1, 2, 4 ], 4), key),
    "octave": 5,
    "gate": iso.PSequence([ 0.5, 1, 2, 1 ]),
    "amplitude": iso.PSequence([ 100, 80, 60, 40], 4),
    "duration": 1.0
})

timeline.schedule({
    "note": iso.PDegree(iso.PSequence([ 7, 6, 4, 2 ], 4), key),
    "octave": 6,
    "gate": 1,
    "amplitude": iso.PSequence([ 80, 70, 60, 50], 4),
    "duration": 1.0
}, delay=0.5)

timeline.run()