Ejemplo n.º 1
0
def test_set_wait_for_next_beat():
    set = live.Set()
    set.tempo = 120.0
    set.play()
    set.wait_for_next_beat()
    set.stop()
    assert True
Ejemplo n.º 2
0
def test_set_load():
    if os.path.exists(LIVE_TMP_SET_PATH):
        os.unlink(LIVE_TMP_SET_PATH)
    set = live.Set()

    #------------------------------------------------------------------------
    # Load nonexistent file
    #------------------------------------------------------------------------
    with pytest.raises(IOError) as excinfo:
        set.load(LIVE_TMP_SET_NAME)
    assert excinfo

    #------------------------------------------------------------------------
    # Load file containing invalid data
    #------------------------------------------------------------------------
    with open(LIVE_TMP_SET_PATH, "w") as fd:
        fd.write("foo")
    with pytest.raises(live.LiveIOError) as excinfo:
        set.load(LIVE_TMP_SET_NAME)

    #------------------------------------------------------------------------
    # Load valid file
    #------------------------------------------------------------------------
    set.save(LIVE_TMP_SET_NAME)
    set.load(LIVE_TMP_SET_NAME)

    os.unlink(LIVE_TMP_SET_PATH)
Ejemplo n.º 3
0
def test_set_scan():
    set = live.Set()
    assert set.scanned == False
    assert len(set.tracks) == 0
    set.scan()
    assert set.scanned == True
    assert len(set.tracks) == 6
Ejemplo n.º 4
0
def live_set():
    set = live.Set()
    set.scan(scan_devices=True, scan_clip_names=True)
    set.quantization = 0
    set.tracks[4].stop()
    time.sleep(0.2)
    return set
Ejemplo n.º 5
0
def test_set_time(t):
    set = live.Set()
    set.time = t
    #------------------------------------------------------------------------
    # Time update does not happen instantly. Wait briefly.
    #------------------------------------------------------------------------
    time.sleep(0.1)
    assert t == set.time
Ejemplo n.º 6
0
def test_set_get_group_named():
    set = live.Set()
    set.scan()

    group = set.get_group_named("1. Group")
    assert group == set.groups[0]

    group = set.get_group_named("Nonexistent")
    assert group is None
Ejemplo n.º 7
0
def test_set_get_track_named():
    set = live.Set()
    set.scan()

    track = set.get_track_named("2-Operator")
    assert track == set.tracks[1]

    track = set.get_track_named("Nonexistent")
    assert track is None
Ejemplo n.º 8
0
def test_set_stop():
    set = live.Set()
    set.play(reset = True)
    time.sleep(0.1)
    set.stop()
    time.sleep(0.1)
    t0 = set.time
    time.sleep(0.1)
    assert set.time == t0
Ejemplo n.º 9
0
def test_set_save():
    set = live.Set()

    set.save(LIVE_TMP_SET_NAME)
    set.load(LIVE_TMP_SET_NAME)
    assert len(set.tracks) == 0

    set.scan()
    assert len(set.tracks) == 6
    set.save(LIVE_TMP_SET_NAME)
    set.load(LIVE_TMP_SET_NAME)
    assert len(set.tracks) == 6

    os.unlink(LIVE_TMP_SET_PATH)
Ejemplo n.º 10
0
    def start_ableton_thread(self):
        is_running = os.system("ps axc -o command  | grep -q ^Live$") == 0
        if not is_running:
            raise RuntimeError("Please run Abelton and open the Looper project")
        print "Initializing Ableton connection"
        # Initialization is done on the main thread.
        self.live_set = live.Set()
        # Patch pylive's console dumping.
        self.live_set.dump = lambda *args: None
        self.live_set.scan(scan_clip_names=True, scan_devices=True)
        
        print "Setting up Ableton session"
        assert self.live_set.tempo == 120, "Tempo must be 120"
        assert len(self.live_set.tracks) == 23, (
            "Didn't find all tracks, make sure you have the right file opened "
            "and that groups are expanded in Ableton!"
        )
        for track in self.live_set.group_named("0. Recordings").tracks:
            assert len(track.clips) == 0, (
                "Found clips in track '%s', "
                "please delete all 'Recording' clips in Ableton" % track.name
            )
        for track in self.live_set.tracks:
            self.live_set.set_track_mute(track.index, 0)
            track.stop()
        self.live_set.stop()
        self.live_set.time = 0
        for track_to_play in ("Stab Synth 1", "Stab Synth 2"):
            track = self.get_track_named(track_to_play)
            # track.volume = 0
            track.mute = 1
            track.clips[0].play()
        
        
        self.beat_length = 60 / self.live_set.tempo 
        
        self.user_tracks = {}
        self.active_tracks = {}
        for role in (UserRole.RIGHT_USER, UserRole.LEFT_USER):
            self.user_tracks[role] = {
                Track.MELODY: SynthLead(self.live_set, role, self.recording_ended),
                Track.HARMONY: SynthHarmony(self.live_set, role, self.recording_ended),
                Track.DRUMS: Drums(self.live_set, role, self.recording_ended)
            }
            self.active_tracks[role] = None

        self.ableton_thread = Thread(target=self.ableton_thread_func)
        self.ableton_thread.daemon = True
        self.ableton_thread.start()
Ejemplo n.º 11
0
def ableton_thread():
    live_set = live.Set()
    live_set.scan(scan_clip_names=True, scan_devices=True)
    drums = Drums(live_set)
    melody = SynthLead(live_set)
    harmony = SynthHarmony(live_set)
    while True:
        time.sleep(0.1)
        right_hand, left_hand, head_height, body_depth = kinect.param_values
        print "Params: (%.3f, %.3f, %.3f, %.3f)" % kinect.param_values
        drums.set_parameter1(right_hand)
        drums.set_parameter2(left_hand)

        melody.set_volume(1 - head_height)
        harmony.set_volume(1 - body_depth)
Ejemplo n.º 12
0
def ableton_thread():
    live_set = live.Set()
    live_set.scan(scan_clip_names=True, scan_devices=True)
    beat_length = 60 / live_set.tempo 
    # drums = Drums(live_set)
    melody = SynthLead(live_set)
    # harmony = SynthHarmony(live_set)
    melody_output = mido.open_output("IAC Driver Bus 1")
    clock_input = mido.open_input("IAC Driver IAC Bus 2")
    tick_count = 0
    for message in clock_input:
        if message.type == "clock":
            tick_count += 1
            if tick_count % 24 == 0:
                melody_output.send(mido.Message("note_on", note=60, velocity=tick_count % 96 + 10))
            elif tick_count % 12 == 0:
                melody_output.send(mido.Message("note_off", note=60))
        elif message.type == "start":
            tick_count = 0
Ejemplo n.º 13
0
def test_set_play():
    set = live.Set()
    set.time = 0.0
    set.quantization = 4

    #------------------------------------------------------------------------
    # Play with reset
    #------------------------------------------------------------------------
    set.play(reset = True)
    time.sleep(0.1)
    set.stop()
    assert set.time > 0.0

    #------------------------------------------------------------------------
    # Play without reset
    #------------------------------------------------------------------------
    t0 = set.time
    set.play(reset = False)
    time.sleep(0.1)
    set.stop()
    assert set.time > t0
    def __init__(self, simulate):
        Observer.__init__(self)
        self.simulate = simulate
        self.app = QApplication([])
        self.appState = AppState(self.app)
        self.cameraState = CameraState.NOTHING
        self.lastCameraState = None
        self.actionFactory = ActionFactory(self.simulate)
        self.timerFactory = TimerFactory(self.simulate)
        self.frameTimer = MagicClass('FrameTimer') if self.simulate else None
        self.videoCapture = cv2.VideoCapture(0)
        self.frame = None
        self.mockFrame = cv2.imread('cat.jpg')
        self.videoStream = VideoStream(
            self.videoCapture) if not self.simulate else MockVideoStream(
                'VideoStream', self.mockFrame)
        self.link = LinkToPy.LinkInterface(
            '/Applications/Carabiner') if not self.simulate else MockLink()
        self.abletonSet = live.Set() if not self.simulate else MockSet()
        self.ableton = Ableton(self.link, self.abletonSet, self.simulate)
        self.ableton.setBpm(SoftwareEngineerPerformance.DEFAULT_BPM)
        self.ableton.start()
        self.timeline = Timeline(
            self.ableton) if not self.simulate else MockTimeline(self.ableton)
        try:
            self.lightboard = DmxLightboard('/dev/cu.usbserial-6A3MRKF6')
        except Exception as e:
            self.lightboard = Lightboard()
            print(str(e))
        self.lightboard.addFixture(
            'spot1',
            ChauvetOvationE910FC(dmx=self.lightboard, startChannel=4)
            if not self.simulate else MagicClass('spot1'))
        self.lightboard.addFixture(
            'spot2',
            ChauvetOvationE910FC(dmx=self.lightboard, startChannel=61)
            if not self.simulate else MagicClass('spot2'))
        self.lightboard.addFixture('par38', [
            Par38(self.lightboard, channel)
            if not self.simulate else MagicClass('Par38.%d' % channel)
            for channel in [221, 226, 11, 16, 31, 96, 91, 86, 46, 71]
        ])
        self.lightboard.addFixture('par64', [
            Par64(self.lightboard, channel)
            if not self.simulate else MagicClass('Par64.%d' % channel)
            for channel in [121, 126, 131, 136, 116, 111, 101, 139, 142]
        ])
        self.spot1 = self.lightboard.getFixture('spot1')
        self.spot2 = self.lightboard.getFixture('spot2')
        self.par38 = self.lightboard.getFixture('par38')
        self.par64 = self.lightboard.getFixture('par64')
        self.videoArchive = VideoArchive(
        ) if not self.simulate else MockVideoArchive('VideoArchive',
                                                     self.mockFrame)
        self.videoArchive.append(
            '/Users/admin/Dropbox/Software Engineer/C0002-empty.mp4')
        self.videoArchive.append(
            '/Users/admin/Dropbox/Software Engineer/C0003-se1.mov')
        self.videoArchive.append(
            '/Users/admin/Dropbox/Software Engineer/C0004-se2.mp4')
        self.videoArchive.append(
            '/Users/admin/Dropbox/Software Engineer/C0005-sandals.mp4')
        self.videoArchive.append(
            '/Users/admin/Dropbox/Software Engineer/C0006-tracksuit.mp4')
        self.videoArchive.append(
            '/Users/admin/Dropbox/Software Engineer/C0007-underwear.mp4')
        self.appWindow = AppWindow()
        self.observe('appTimerUpdate', self.update)
        self.observe('startPerformance', self.startPerformance)
        self.observe('stopPerformance', self.stopPerformance)
        self.observe('scanAbletonSet', self.scanAbletonSet)
        self.observe('saveAbletonSet', self.saveAbletonSet)
        self.observe('quit', self.quit)
        self.appWindow.showFullScreen()

        if simulate:
            self.appWindow.frame = self.mockFrame
            self.startPerformance()
            while not self.timeline.isEmpty():
                self.appWindow.update()
            exit(0)

        self.app.exit(self.app.exec_())
Ejemplo n.º 15
0
 def connect(self):
     self.set = live.Set()
     self.set.scan(scan_clip_names = True, scan_devices = True)
Ejemplo n.º 16
0
Archivo: set.py Proyecto: kant/4bars
 def get_set_reference(self):
     self.set = live.Set()
Ejemplo n.º 17
0
def main():
    live_set = live.Set()
    live_set.scan(scan_clip_names=True, scan_devices=True)
    drums = Drums(live_set)
    drums.set_base(0.2)
Ejemplo n.º 18
0
def test_set_currently_open():
    set = live.Set()
    assert set.currently_open().endswith("Tests.als")
Ejemplo n.º 19
0
def group():
    set = live.Set()
    set.scan(scan_devices=True)
    set.groups[0].stop()
    time.sleep(0.1)
    return set.groups[0]
Ejemplo n.º 20
0
def test_set_connected():
    set = live.Set()
    assert set.is_connected
Ejemplo n.º 21
0
def test_set_master_pan():
    set = live.Set()
    set.master_pan = 0.1
    assert set.master_pan == pytest.approx(0.1)
Ejemplo n.º 22
0
def test_get_master_pan():
    set = live.Set()
    assert set.master_pan == pytest.approx(0.0)
Ejemplo n.º 23
0
def test_set_master_volume():
    set = live.Set()
    set.master_volume = 0.5
    assert set.master_volume == pytest.approx(0.5)
Ejemplo n.º 24
0
def test_get_master_volume():
    set = live.Set()
    assert set.master_volume == pytest.approx(0.85)
Ejemplo n.º 25
0
def test_set_num_scenes():
    set = live.Set()
    assert set.num_scenes == 8
Ejemplo n.º 26
0
def test_set_tempo(tempo):
    set = live.Set()
    set.tempo = tempo
    assert tempo == set.tempo
Ejemplo n.º 27
0
        user_name = data['username']
        sid = request.sid

        user = User(sid, user_name)
        users[sid] = user

        userDict = {
            'uuid': str(user.uuid),
            'userName': user.name,
            'sid': user.sid
        }
        emit(
            'on_connect', {
                'msg': 'Connected',
                'user': userDict,
                'tracks': [str(track) for track in set.tracks]
            })
        emit('user_joined', {'user': userDict})


socketio.on_namespace(MyNamespace('/test'))

if __name__ == '__main__':
    set = live.Set(address=("localhost", 9000))
    set.scan(scan_clip_names=True, scan_devices=True)
    track = set.tracks[0]
    print("Track name %s" % track.name)
    socketio.run(
        app, host='0.0.0.0', port=80,
        debug=False)  #os.environ.get('PORT', 80), debug=True) # debug=True)
Ejemplo n.º 28
0
def test_set_quantization(quantization):
    set = live.Set()
    set.quantization = quantization
    assert quantization == set.quantization
Ejemplo n.º 29
0
import argparse
import live
import time


if __name__ == "__main__":

    set = live.Set()
    set.scan()
    print(set.tracks)

    while True:
        print(live.query("/live/track/info", 0))
        print('-----------------------')
        time.sleep(0.1)
Ejemplo n.º 30
0
def test_set_num_tracks():
    set = live.Set()
    assert set.num_tracks == 6