Browse Source

adjust to new lss lib

master
Nils 2 years ago
parent
commit
f68fe71c9e
  1. 1
      configure
  2. 4
      engine/api.py
  3. 40
      engine/ccsubtrack.py
  4. 2
      engine/config.py
  5. 4
      engine/items.py

1
configure

@ -1,6 +1,5 @@
#!/bin/bash
program=laborejo
cboxconfigure="--without-fluidsynth --without-libsmf"
version=2.0.2
. template/configure.template #. is the posix compatible version of source

4
engine/api.py

@ -27,10 +27,8 @@ import random
random.seed()
from typing import Iterable, Callable, Tuple
#Third Party Modules
from calfbox import cbox
#Template Modules
from template.calfbox import cbox
import template.engine.api #we need direct access to the module to inject data in the provided structures. but we also need the functions directly. next line:
from template.engine.api import *
from template.engine.duration import DB, DL, D1, D2, D4, D8, D16, D32, D64, D128, D256, D512, D1024, D_DEFAULT, D_STACCATO, D_TENUTO, D_TIE

40
engine/ccsubtrack.py

@ -24,10 +24,8 @@ import logging; logger = logging.getLogger(__name__); logger.info("import")
#Standard Library Modules
from weakref import WeakValueDictionary, WeakSet
#Third Party Modules
from calfbox import cbox
#Template Modules
from template.calfbox import cbox
import template.engine.duration as duration
from template.engine.duration import D1, D4, D1024
from template.helper import pairwise
@ -160,8 +158,8 @@ class GraphBlock(object):
@duration.setter
def duration(self, newValue):
"""Keep the mutable list at all cost"""
if newValue <= 0:
if newValue <= 0:
raise ValueError("duration must be > 1")
listId = id(self._duration)
self._duration.pop() #don't replace the data structure, keep the mutable list alive.
@ -269,7 +267,7 @@ class GraphBlock(object):
for itemTickPosition, item in self.data.items(): #deep copy
copy = item.copy()
newData[itemTickPosition] = copy
newData[itemTickPosition] = copy
return newData, linkedContentBlocks, self._duration[:] #mutable. the api uses the list directly as well because we want to undo/restore the old original list, which may be content linked.
@ -285,8 +283,8 @@ class GraphBlock(object):
ordered = sorted(blocksInTrack, key = lambda block: self.parentGraphTrack.blocks.index(block))
return ordered
def insert(self, graphItem, tickPositionRelativeToBlockStart):
self.data[tickPositionRelativeToBlockStart] = graphItem
def insert(self, graphItem, tickPositionRelativeToBlockStart):
self.data[tickPositionRelativeToBlockStart] = graphItem
return True #cannot fail, for now. the api still waits for a positive return code
def find(self, graphItem):
@ -372,7 +370,7 @@ class GraphTrackCC(object):
def _secondInit(self, parentTrack):
"""see Score._secondInit"""
self.parentTrack = parentTrack
self.parentTrack = parentTrack
@classmethod
def instanceFromSerializedData(cls, serializedObject, parentTrack):
@ -509,7 +507,7 @@ class GraphTrackCC(object):
elif not self.blocks.index(firstBlock) + 1 == self.blocks.index(secondBlock): #all first blocks must be followed directly by a content link of the second block. linkedContentBlocksInScore() returns a blocklist in order so we can compare.
logger.info("CC Block merge aborted: not all content link blocks-pairs are next to each other")
return False
#Test complete without exit. All blocks can be paired up.
block.deleteHiddenItems()
@ -521,11 +519,11 @@ class GraphTrackCC(object):
for pos, item in nextBlock.data.items():
assert not pos + block.duration in block.data #this includes pos==0, if not deleted above.
block.data[pos + block.duration] = item
newFirstBlockDuration = block.duration+nextBlock.duration
newFirstBlockDuration = block.duration+nextBlock.duration
for firstBlock, secondBlock in zip(block.linkedContentBlocksInScore(), nextBlock.linkedContentBlocksInScore()):
firstBlock._duration = [newFirstBlockDuration,] #Duration is content linked. if we use the setter it will create the wrong sum. Force the new duration instead.
self.deleteBlock(secondBlock)
self.deleteBlock(secondBlock)
return startDurationToReturnForUndo
@ -637,7 +635,7 @@ class GraphTrackCC(object):
result.append(exportDictItem)
typeString = "interpolated" #The next items in userItemAndInterpolatedItemsPositions are interpolated items. Reset once we leave the local forLoop.
#numbers from 0-15 which represent the midi channels all CCs are sent to. Only replaced by a new tuple by the user directly.
#numbers from 0-15 which represent the midi channels all CCs are sent to. Only replaced by a new tuple by the user directly.
if self.parentTrack.ccChannels:
for channel in self.parentTrack.ccChannels:
blob = cbox.Pattern.serialize_event(exportDictItem["position"], 0xB0 + channel, self.cc, ccValue) #position, status byte+channel, controller number, controller value #TODO use channel of the parent note track at that moment in time.
@ -648,11 +646,11 @@ class GraphTrackCC(object):
#Prepare data for the next block.
sumOfBlocksDurationsWithoutCurrent += block.duration #the naming is only true until the last iteration. Then all blocks, even the current one, are in the sum and can be used below.
sumOfBlockDurations = sumOfBlocksDurationsWithoutCurrent #Choose the correct name. Explicit is better than implicit.
#if sumOfBlockDurations > 0:
self.parentTrack.sequencerInterface.setSubtrack(key=self.cc, blobs=[(patternBlob, 0, sumOfBlockDurations),]) #(bytes-blob, position, length)
self.parentTrack.sequencerInterface.setSubtrack(key=self.cc, blobs=[(patternBlob, 0, sumOfBlockDurations),]) #(bytes-blob, position, length)
return result
def staticGraphBlocksRepresentation(self):
@ -689,8 +687,8 @@ class GraphTrackCC(object):
#TODO: A bit wasteful. Optimisation? Did really a content linked block change?
result = set()
for block in self.blocks:
for linkedBlock in block.linkedContentBlocks:
result.add(linkedBlock.parentGraphTrack)
assert result #at least this very track
assert len(result) <= len(self.parentTrack.parentData.tracks) #For now we assume that blocks cannot be linked across CCs. This can be removed after we tested it for a while and the time comes for cross-CC links
for linkedBlock in block.linkedContentBlocks:
result.add(linkedBlock.parentGraphTrack)
assert result #at least this very track
assert len(result) <= len(self.parentTrack.parentData.tracks) #For now we assume that blocks cannot be linked across CCs. This can be removed after we tested it for a while and the time comes for cross-CC links
return result

2
engine/config.py

@ -58,6 +58,4 @@ maximum fine control to get exactly the music you want!
""" + "\n" + """
Working in Laborejo is very fast and efficient by using a combination of midi input and typing.""",
"dependencies" : "\n".join("* "+dep for dep in ("Lilypond >= 2.19 (optional)", )),
}

4
engine/items.py

@ -25,10 +25,8 @@ from fractions import Fraction
from weakref import WeakSet, WeakValueDictionary
from warnings import warn
#Third Party Modules
from calfbox import cbox
#Template Modules
from template.calfbox import cbox
import template.engine.pitch as pitchmath
import template.engine.duration as duration
from template.engine.duration import DM, DB, DL, D1, D2, D4, D8, D16, D32, D64, D128, D256, D512, D1024, D_DEFAULT, D_STACCATO, D_TENUTO, D_TIE

Loading…
Cancel
Save