Browse Source

update template

master
Nils 4 years ago
parent
commit
d49c430954
  1. 2
      template/engine/duration.py
  2. 4
      template/engine/sequencer.py
  3. 4
      template/engine/session.py
  4. 2
      template/qtgui/mainwindow.py
  5. 17
      template/qtgui/nsmclient.py

2
template/engine/duration.py

@ -48,7 +48,7 @@ D512 = int(D256 / 2)
D1024 = int(D512 / 2) # set this to a number with many factors, like 210. According to http://homes.sice.indiana.edu/donbyrd/CMNExtremes.htm this is the real world limit.
if not int(D1024) == D1024:
logger.error(f"Warning: Lowest duration D0124 has decimal places: {D0124} but should be a plain integer. Your D4 value: {D4} has not enough 2^n factors. ")
logger.error(f"Warning: Lowest duration D0124 has decimal places: {D1024} but should be a plain integer. Your D4 value: {D4} has not enough 2^n factors. ")
D2 = D4 *2
D1 = D2 *2

4
template/engine/sequencer.py

@ -272,7 +272,7 @@ class _Subtrack(object):
cbox.Document.get_song().update_playback()
def recreateThroughUndo(self):
assert self.calfboxSubTrack is None, calfboxSubTrack
assert self.calfboxSubTrack is None, self.calfboxSubTrack
self.calfboxSubTrack = cbox.Document.get_song().add_track()
for pattern, position, length in self._cachedPatterns:
self.calfboxSubTrack.add_clip(position, 0, length, pattern) #pos, offset, length, pattern.
@ -378,7 +378,7 @@ class SequencerInterface(_Interface): #Basically the midi part of a track.
in the past which deleted the midi output but not the cbox-midi
data it generated and held"""
#Recreate Calfbox Midi Data
assert self.calfboxTrack is None, calfboxTrack
assert self.calfboxTrack is None, self.calfboxTrack
self.calfboxTrack = cbox.Document.get_song().add_track()
self.calfboxTrack.set_name(self.name) #only cosmetic and cbox internal. Useful for debugging, not used in jack.
for pattern, position, length in self._cachedPatterns:

4
template/engine/session.py

@ -133,10 +133,10 @@ class Session(object):
logger.info("Loading file complete")
return Data.instanceFromSerializedData(parentSession=self, serializedData=result)
else:
warn(f"""{absoluteJsonFilePath} was saved with {result["version"]} but we need {METADATA["version"]}""")
logger.warning(f"""{absoluteJsonFilePath} was saved with {result["version"]} but we need {METADATA["version"]}""")
sysexit()
else:
warn(f"""Error. {absoluteJsonFilePath} not loaded. Not a sane {METADATA["name"]} file in json format""")
logger.warning(f"""Error. {absoluteJsonFilePath} not loaded. Not a sane {METADATA["name"]} file in json format""")
sysexit()

2
template/qtgui/mainwindow.py

@ -217,7 +217,7 @@ class MainWindow(QtWidgets.QMainWindow):
#Decide here if you want only files, only directories, both etc.
if os.path.isfile(filePath) and filePath.lower().endswith(".sf2"):
#linkedPath = self.nsmClient.importResource(filePath)
print ("received drop", linkedPath)
print ("received drop")

17
template/qtgui/nsmclient.py

@ -276,8 +276,8 @@ class NSMClient(object):
elif loggingLevel == "error" or loggingLevel == 40:
logging.basicConfig(level=logging.ERROR) #production
else:
raise ValueError("Unknown logging level: {}. Choose 'info' or 'error'".format(loggingLevel))
logging.warning("Unknown logging level: {}. Choose 'info' or 'error'".format(loggingLevel))
logging.basicConfig(level=logging.INFO) #development
#given parameters,
self.prettyName = prettyName #keep this consistent! Settle for one name.
@ -303,7 +303,6 @@ class NSMClient(object):
#self.discardReactions = set(["/nsm/client/session_is_loaded"])
self.discardReactions = set()
#Networking and Init
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #internet, udp
self.sock.bind(('', 0)) #pick a free port on localhost.
@ -324,7 +323,9 @@ class NSMClient(object):
self.ourClientId = None # the "file extension" of ourClientNameUnderNSM
self.isVisible = None #set in announceGuiVisibility
self.saveStatus = True # true is clean. false means we need saving.
self.announceOurselves()
assert self.serverFeatures, self.serverFeatures
assert self.sessionName, self.sessionName
assert self.ourPath, self.ourPath
@ -336,6 +337,8 @@ class NSMClient(object):
#We assume we are save at startup.
self.announceSaveStatus(isClean = True)
logger.info("NSMClient client init complete. Going into listening mode.")
def reactToMessage(self):
"""This is the main loop message. It is added to the clients event loop."""
@ -418,6 +421,8 @@ class NSMClient(object):
else:
return ""
logger.info("Sending our NSM-announce message")
announce = _OutgoingMessage("/nsm/server/announce")
announce.add_arg(self.prettyName) #s:application_name
announce.add_arg(buildClientFeaturesString()) #s:capabilities
@ -458,7 +463,7 @@ class NSMClient(object):
replyToOpen.add_arg("{} is opened or created".format(self.prettyName))
self.sock.sendto(replyToOpen.build(), self.nsmOSCUrl)
else:
raise ValueError("Unexpected message path after announce".format((msg.oscpath, msg.params)))
raise ValueError("Unexpected message path after announce: {}".format((msg.oscpath, msg.params)))
def announceGuiVisibility(self, isVisible):
message = "/nsm/client/gui_is_shown" if isVisible else "/nsm/client/gui_is_hidden"
@ -492,8 +497,10 @@ class NSMClient(object):
def _sessionIsLoadedCallback(self, msg):
if self.sessionIsLoadedCallback:
logger.info("Telling our client that the session has finished loading")
logger.info("Received 'Session is Loaded'. Our client supports it. Forwarding message...")
self.sessionIsLoadedCallback()
else:
logger.info("Received 'Session is Loaded'. Our client does not support it, which is the default. Discarding message...")
def sigtermHandler(self, signal, frame):
"""Wait for the user to quit the program

Loading…
Cancel
Save