Esempio n. 1
0
def test_pswitchone():
    a = iso.PSwitchOne(iso.PSeries(0, 1), 4)
    expected = [0, 1, 2, 3, 0, 1, 3, 2, 0, 1, 2, 3, 3, 1, 2, 0, 3, 2, 1, 0]
    a.seed(0)
    assert a.nextn(20) == expected
    a.reset()
    assert a.nextn(20) == expected
Esempio n. 2
0
def test_pshuffleevery():
    a = iso.PShuffleInput(iso.PSeries(0, 1), 4)
    expected = [
        2, 0, 1, 3, 4, 5, 7, 6, 8, 10, 9, 11, 13, 12, 15, 14, 18, 16, 19, 17
    ]
    a.seed(0)
    assert a.nextn(20) == expected
    a.reset()
    assert a.nextn(20) == expected
Esempio n. 3
0
def test_pskip_regular():
    a = iso.PSkip(iso.PSeries(0, 1), 0.5, True)
    expected = [
        None, 1, None, 3, None, 5, None, 7, None, 9, None, 11, None, 13, None,
        15, None, 17, None, 19
    ]
    a.seed(0)
    assert a.nextn(20) == expected
    a.reset()
    assert a.nextn(20) == expected
Esempio n. 4
0
def test_pskip():
    a = iso.PSkip(iso.PSeries(0, 1), 0.5)
    expected = [
        None, None, 2, 3, None, 5, None, 7, 8, None, None, None, 12, None,
        None, 15, None, None, None, None
    ]
    a.seed(0)
    assert a.nextn(20) == expected
    a.reset()
    assert a.nextn(20) == expected
Esempio n. 5
0
def test_timeline_schedule_count(dummy_timeline):
    dummy_timeline.schedule({
        iso.EVENT_NOTE: iso.PSeries(0, 1),
        iso.EVENT_DURATION: 1
    }, count=4)
    dummy_timeline.run()
    assert len(dummy_timeline.output_device.events) == 8
    assert dummy_timeline.output_device.events == [
        [0, "note_on", 0, 64, 0], [1, "note_off", 0, 0],
        [1, "note_on", 1, 64, 0], [2, "note_off", 1, 0],
        [2, "note_on", 2, 64, 0], [3, "note_off", 2, 0],
        [3, "note_on", 3, 64, 0], [4, "note_off", 3, 0]
    ]
Esempio n. 6
0
def test_event_control_no_interpolation(dummy_timeline):
    """
    Simple case: schedule a series of regularly-spaced control points.
    Output device should receive discrete control events.
    """
    control_series = iso.PSeries(start=1, step=2, length=3)
    dummy_timeline.schedule({
        iso.EVENT_CONTROL: 0,
        iso.EVENT_VALUE: control_series,
        iso.EVENT_DURATION: 1,
        iso.EVENT_CHANNEL: 9
    })
    dummy_timeline.run()
    assert dummy_timeline.output_device.events == [[0, "control", 0, 1, 9],
                                                   [1, "control", 0, 3, 9],
                                                   [2, "control", 0, 5, 9]]
Esempio n. 7
0
#!/usr/bin/python
import isobar as iso

# create a repeating sequence with scalar transposition:
# [ 36, 38, 43, 39, ... ]
a = iso.PSeq([0, 2, 7, 3]) + 36

# apply pattern-wise transposition
# [ 36, 50, 43, 51, ... ]
a = a + iso.PSeq([0, 12])

# create a geometric chromatic series, repeated back and forth
b = iso.PSeries(0, 1, 12) + 72
b = iso.PPingPong(b)
b = iso.PLoop(b)

# create an velocity series, with emphasis every 4th note,
# plus a random walk to create gradual dynamic changes
amp = iso.PSeq([50, 35, 25, 35]) + iso.PBrown(0, 1, -20, 20)

# a Timeline schedules events at a given BPM.
# by default, send these over the first MIDI output.
output_device = iso.io.midi.MidiOut("IAC Driver IAC Bus 1")
timeline = iso.Timeline(120, device=output_device, debug=True)

# assign each of our Patterns to particular properties
timeline.sched({'note': a, 'dur': 1, 'gate': 2})

timeline.run()
Esempio n. 8
0
# sequences, scales, stochastic functions, scheduling and mapping.
#------------------------------------------------------------------------

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, ... ]
#------------------------------------------------------------------------
Esempio n. 9
0
def test_preset():
    a = iso.PSeries(0, 1)
    b = iso.PReset(a, iso.PImpulse(4))
    c = iso.PSubsequence(b, 0, 10)
    assert list(c) == [0, 1, 2, 3, 0, 1, 2, 3, 0, 1]
Esempio n. 10
0
def test_psubsequence():
    a = iso.PSeries()
    b = iso.PSubsequence(a, 4, 4)
    assert list(b) == [4, 5, 6, 7]
Esempio n. 11
0
def test_pseries():
    a = iso.PSeries(2, iso.PSequence([1, 2]), iso.PConstant(5))
    assert list(a) == [2, 3, 5, 6, 8]
Esempio n. 12
0
def test_pmap_args():
    a = iso.PSequence([4, 5, 1, -2, 1, -1.5], 1)
    b = iso.PMap(a, lambda x, y: x + y, iso.PSeries())
    assert list(b) == [4, 6, 3, 1, 5, 3.5]