Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/38 #39

Merged
merged 18 commits into from
Sep 24, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prev & Next Track buttons On/Off logic fixed for StepSequencer classes
Removed unused imports
Formated and indented the code
Removed unused variables
Fixed layout bug for Multinote Mode Step Sequencer
  • Loading branch information
poltow committed Sep 19, 2016
commit 6c48c371f1f0a9236d99db8a0bef06732fdc5ad9
3 changes: 1 addition & 2 deletions ColorsMK2.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class Rgb:
PURPLE_PULSE = Pulse(48)
PURPLE_HALF_PULSE = Pulse(49)
PURPLE_THIRD_PULSE = Pulse(50)


CLIP_COLOR_TABLE = {
15549221: 60,
Expand Down Expand Up @@ -180,7 +179,7 @@ class Rgb:
14673637: 118,
16777215: 119
}

RGB_COLOR_TABLE = (
(0, 0),
(1, 1973790),
Expand Down
4 changes: 2 additions & 2 deletions ConfigurableButtonElement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _Framework.Skin import SkinColorMissingError
from _Framework.ButtonElement import ButtonElement, ON_VALUE, OFF_VALUE, ButtonValue
from _Framework.ButtonElement import ButtonElement, ON_VALUE, OFF_VALUE

class ConfigurableButtonElement(ButtonElement):
"""
Expand Down Expand Up @@ -80,7 +80,7 @@ def send_value(self, value, **k):
super(ConfigurableButtonElement, self).send_value(value, **k)
else:
self._draw_skin(value)

def force_next_send(self):
"""
Enforces sending the next value regardless of wether the
Expand Down
11 changes: 4 additions & 7 deletions DeviceComponent.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-

from consts import * # noqa
from _Framework.DeviceComponent import DeviceComponent as LiveDeviceComponent
from _Framework.ButtonElement import ButtonElement
from DeviceControllerStrip import DeviceControllerStrip
import time
import Live


class DeviceComponent(LiveDeviceComponent):
Expand Down Expand Up @@ -42,10 +39,10 @@ def __init__(self, control_surface = None, name = "device_component", is_enabled

self._selected_track = None

self._lock_buttons = [None for index in range(4)]
self._locked_device_bank = [0 for index in range(4)]
self._lock_button_press = [0 for index in range(4)]
self._locked_devices = [None for index in range(4)]
self._lock_buttons = [None,None,None,None]
self._locked_device_bank = [0,0,0,0]
self._lock_button_press = [0,0,0,0]
self._locked_devices = [None,None,None,None]

if top_buttons != None:
# device selection buttons
Expand Down
9 changes: 3 additions & 6 deletions DeviceControllerStrip.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-

from _Framework.ButtonSliderElement import ButtonSliderElement
from _Framework.InputControlElement import * # noqa
from consts import * # noqa
import math

SLIDER_MODE_OFF = 0
SLIDER_MODE_TOGGLE = 1
Expand Down Expand Up @@ -75,13 +72,13 @@ def _is_quantized(self):
if self._parameter_to_map_to != None:
return self._parameter_to_map_to.is_quantized
else:
return false
return False

@property
def _mode(self):
if self._parameter_to_map_to != None:
if self._is_quantized:
if self._range == 1:
if self._range == 1:
return SLIDER_MODE_TOGGLE
elif self._range<=self._num_buttons:
return SLIDER_MODE_SMALL_ENUM
Expand Down Expand Up @@ -126,7 +123,7 @@ def _update_off(self):
def _update_toggle(self):
v = ["DefaultButton.Disabled" for index in range(len(self._buttons))]
if self._value==self._max:
v[0]="Device.Toggle.On"
v[0]="Device.Toggle.On"
else:
v[0]="Device.Toggle.Off"
self._update_buttons(tuple(v))
Expand Down
13 changes: 5 additions & 8 deletions InstrumentControllerComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
from _Framework.Util import find_if
from itertools import imap
from TrackControllerComponent import TrackControllerComponent
from ScaleComponent import * # noqa
from StepSequencerComponent import StepSequencerComponent
from consts import * # noqa
from ScaleComponent import ScaleComponent,CIRCLE_OF_FIFTHS,MUSICAL_MODES,KEY_NAMES
import Settings

class InstrumentControllerComponent(CompoundComponent):
Expand Down Expand Up @@ -526,7 +524,6 @@ def _update_matrix(self):
else:
button.turn_off()

interval = self._scales._interval
pattern = self._scales.get_pattern()
max_j = self._matrix.width() - 1
a = 0
Expand Down Expand Up @@ -567,12 +564,12 @@ def _update_matrix(self):
button.set_enabled(True)
button.force_next_send()

#self._control_surface._config_button.send_value(32)
#self._control_surface._config_button.send_value(32)#Send enable flashing led config message to LP


def tuple_idx(self, tuple, obj):
for i in xrange(0, len(tuple)):
if (tuple[i] == obj):
def tuple_idx(self, target_tuple, obj):
for i in xrange(0, len(target_tuple)):
if (target_tuple[i] == obj):
return i
return(False)

8 changes: 4 additions & 4 deletions Launchpad.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import with_statement
import Live
from _Framework.ControlSurface import ControlSurface
from _Framework.InputControlElement import * # noqa
from _Framework.InputControlElement import MIDI_CC_TYPE, MIDI_NOTE_TYPE
from _Framework.ButtonElement import ButtonElement
from _Framework.ButtonMatrixElement import ButtonMatrixElement
from ConfigurableButtonElement import ConfigurableButtonElement
Expand Down Expand Up @@ -51,7 +51,7 @@ def init(self):
#self._drum_notes = (20, 30, 31, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126)
self._drum_notes = (20, 30, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126)
else:
from SkinMK1 import make_skin # @Reimport
from SkinMK1 import make_skin # @Reimport
self._skin = make_skin()
self._side_notes = (8, 24, 40, 56, 72, 88, 104, 120)
self._drum_notes = (41, 42, 43, 44, 45, 46, 47, 57, 58, 59, 60, 61, 62, 63, 73, 74, 75, 76, 77, 78, 79, 89, 90, 91, 92, 93, 94, 95, 105, 106, 107)
Expand All @@ -71,7 +71,7 @@ def init(self):
for column in range(8):
if self._mk2_rgb:
# for mk2 buttons are assigned "top to bottom"
midi_note = (81 - (10 * row)) + column
midi_note = (81 - (10 * row)) + column
else:
midi_note = row * 16 + column
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, midi_note, skin = self._skin, control_surface = self)
Expand Down Expand Up @@ -132,7 +132,7 @@ def disconnect(self):
# launchpad mk2 needs disconnect string sent
self._send_midi((240, 0, 32, 41, 2, 24, 64, 247))
if self._config_button != None:
self._config_button.send_value(32)#Send enable flashing led config message to LP
self._config_button.send_value(32)#Send enable flashing led config message to LP
self._config_button.send_value(0)
self._config_button = None
self._user_byte_write_button.send_value(0)
Expand Down
9 changes: 4 additions & 5 deletions PreciseButtonSliderElement.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

from _Framework.ButtonSliderElement import ButtonSliderElement
from _Framework.InputControlElement import * # noqa
SLIDER_MODE_SINGLE = 0
SLIDER_MODE_VOLUME = 1
SLIDER_MODE_PAN = 2
Expand All @@ -25,10 +24,10 @@ def set_mode(self, mode):
if (mode != self._mode):
self._mode = mode

def set_value_map(self, map):
assert isinstance(map, (tuple, type(None)))
assert len(map) == len(self._buttons)
self._value_map = map
def set_value_map(self, value_map):
assert isinstance(value_map, (tuple, type(None)))
assert len(value_map) == len(self._buttons)
self._value_map = value_map

def send_value(self, value):
if (not self._disabled):
Expand Down
9 changes: 4 additions & 5 deletions ScaleComponent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from _Framework.ControlSurfaceComponent import ControlSurfaceComponent
from _Framework.ToggleComponent import ToggleComponent
#from _Framework.Control import PlayableControl, ButtonControl, ToggleButtonControl, control_matrix

KEY_NAMES = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
Expand Down Expand Up @@ -206,7 +205,7 @@ def update(self):
if self._key == self._white_notes_index[col]+1:
button.set_light("Scale.Key.On")
else:
button.set_light("Scale.Key.Off")
button.set_light("Scale.Key.Off")
elif col==2:
button.set_light("Scale.RelativeScale")
elif col==6:
Expand All @@ -224,7 +223,7 @@ def update(self):
if self._key == self._white_notes_index[col]:
button.set_light("Scale.Key.On")
else:
button.set_light("Scale.Key.Off")
button.set_light("Scale.Key.Off")
else:
button.set_light("Scale.CircleOfFifths")
elif row==3:
Expand Down Expand Up @@ -274,7 +273,7 @@ def update(self):
#@matrix.pressed
def _matrix_pressed(self, value, x, y, is_momentary):
if self.is_enabled() and value>0:
#y, x = pad.coordinate
#y, x = pad.coordinate
# modes
if y == 0:
if not self.is_drumrack:
Expand Down Expand Up @@ -537,7 +536,7 @@ def _octave_and_note(self, x, y):
def note(self, x, y):
octave, note = self._octave_and_note(x, y)
index = self.base_note + 12 * octave + note
root = note == self.scale[0]
root = note == self.scale[0]
highlight = note == self.scale[2] or note == self.scale[4]
in_scale = note in self.scale
valid = index in self.valid_notes
Expand Down
73 changes: 36 additions & 37 deletions SkinMK1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from _Framework.ButtonElement import Color
from _Framework.Skin import Skin
from .ColorsMK1 import Rgb

Expand All @@ -10,7 +9,7 @@ class DefaultButton:
Off = Rgb.GREEN_THIRD
Disabled = Rgb.BLACK

class Mode: #mode buttons colour
class Mode: # mode buttons colour
class Session:
On = Rgb.AMBER
Off = Rgb.AMBER_THIRD
Expand Down Expand Up @@ -40,26 +39,26 @@ class Mixer:
Off = Rgb.AMBER_THIRD

class Session:
#scene
# scene
SceneTriggered = Rgb.AMBER_BLINK
Scene = Rgb.AMBER_THIRD
NoScene = Rgb.BLACK
#clip states
# clip states
ClipStarted = Rgb.GREEN
ClipStopped = Rgb.AMBER
ClipRecording = Rgb.RED
ClipEmpty = Rgb.BLACK
#trigs
# trigs
ClipTriggeredPlay = Rgb.GREEN_BLINK
ClipTriggeredRecord = Rgb.RED_BLINK
RecordButton = Rgb.RED_THIRD
#stop button
# stop button
StopClip = Rgb.RED
StopClipTriggered = Rgb.RED_BLINK
#Enabled = Rgb.GREEN
#Off = Rgb.GREEN_THIRD
# Enabled = Rgb.GREEN
# Off = Rgb.GREEN_THIRD

class Zooming:#session zoomin
class Zooming: # session zoomin
Selected = Rgb.AMBER
Stopped = Rgb.RED
Playing = Rgb.GREEN
Expand Down Expand Up @@ -100,7 +99,7 @@ class SendsSlider:
On = Rgb.AMBER
Off = Rgb.BLACK

class Sends:#not used yet on legacy launchpad
class Sends: # not used yet on legacy launchpad
A = Rgb.RED
AAvail = Rgb.RED_THIRD
B = Rgb.RED
Expand All @@ -118,7 +117,7 @@ class Sends:#not used yet on legacy launchpad
H = Rgb.RED
HAvail = Rgb.RED_THIRD

class Device:#device mode colours
class Device: # device mode colours
class Bank:
On = Rgb.GREEN
Off = Rgb.GREEN_THIRD
Expand Down Expand Up @@ -158,25 +157,25 @@ class Mode:
class Lock:
class ToTrack:
On = Rgb.RED
Off = Rgb.RED_THIRD
Off = Rgb.RED_THIRD
class ToClip:
On = Rgb.AMBER
On = Rgb.AMBER
Off = Rgb.AMBER_THIRD
class LoopSelector:
SelectedPlaying = Rgb.RED
Playing = Rgb.RED_THIRD
Selected = Rgb.GREEN
InLoop = Rgb.AMBER_THIRD
class Quantization:
One=Rgb.GREEN_FULL
Two=Rgb.YELLOW_FULL
Three=Rgb.AMBER_FULL
Four=Rgb.RED_FULL
class QuantizationLow:
One=Rgb.GREEN_HALF
Two=Rgb.YELLOW_HALF
Three=Rgb.AMBER_HALF
Four=Rgb.RED_HALF
One = Rgb.GREEN_FULL
Two = Rgb.YELLOW_FULL
Three = Rgb.AMBER_FULL
Four = Rgb.RED_FULL
class QuantizationLow:
One = Rgb.GREEN_HALF
Two = Rgb.YELLOW_HALF
Three = Rgb.AMBER_HALF
Four = Rgb.RED_HALF
class NoteSelector:
class Octave:
On = Rgb.GREEN
Expand All @@ -190,15 +189,15 @@ class VelocityShifted:
Velocity0 = Rgb.GREEN_THIRD
Velocity1 = Rgb.GREEN_HALF
Velocity2 = Rgb.GREEN
Velocity3 = Rgb.ORANGE_FULL
Velocity4 = Rgb.MANDARIN_FULL
Velocity3 = Rgb.ORANGE_FULL
Velocity4 = Rgb.MANDARIN_FULL
Muted = Rgb.RED_THIRD
Playing = Rgb.RED
Metronome = Rgb.YELLOW_FULL
Metronome = Rgb.YELLOW_FULL
NoteMarker = Rgb.AMBER
PageMarker = Rgb.AMBER_THIRD
CurrentPageMarker = Rgb.RED_THIRD
CurrentPageMarkerPlay = Rgb.GREEN_THIRD
CurrentPageMarker = Rgb.RED_THIRD
CurrentPageMarkerPlay = Rgb.GREEN_THIRD

class StepSequencer2:
class Pitch:
Expand Down Expand Up @@ -288,14 +287,14 @@ class Pads:
OutOfScale = Rgb.BLACK
Invalid = Rgb.BLACK

class Scale:#scale edition
class Horizontal:
On = Rgb.AMBER
Off = Rgb.AMBER_THIRD
class Scale: # scale edition
class Horizontal:
On = Rgb.AMBER
Off = Rgb.AMBER_THIRD
class AbsoluteRoot:
On = Rgb.AMBER
Off = Rgb.AMBER_THIRD
class Mode:
On = Rgb.AMBER
Off = Rgb.AMBER_THIRD
class Mode:
On = Rgb.RED
Off = Rgb.RED_THIRD
class Key:
Expand All @@ -313,11 +312,11 @@ class QuickScale:
On = Rgb.AMBER
Off = Rgb.AMBER_THIRD

class QuickScale:#quick scale on top of instrument mode
class QuickScale: # quick scale on top of instrument mode
class Modus:
On = Rgb.AMBER
Off = Rgb.AMBER_THIRD
class Major: # quick scale while in major mode
class Major: # quick scale while in major mode
class Key:
On = Rgb.AMBER
Off = Rgb.AMBER_THIRD
Expand All @@ -341,4 +340,4 @@ class Key:


def make_skin():
return Skin(Colors)
return Skin(Colors)
Loading