Browse Source

change extension from tar to tembro to prevent accidental unpack by users

master
Nils 2 years ago
parent
commit
659da3a121
  1. 11
      engine/api.py
  2. 5
      engine/instrument.py
  3. 14
      engine/main.py
  4. BIN
      engine/resources/000 - Default.tembro

11
engine/api.py

@ -74,8 +74,9 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
def _instrumentListMetadata(self):
"""All libraries with all instruments as meta-data dicts. Hirarchy.
A dict of dicts.
Will be sent once on program start. Does not wait until actual samples are loaded
but as soon as all data is parsed."""
Will be sent when instruments got parsed. At least once on program start and maybe
on a rescan of the sample dir.
"""
export = session.data.exportMetadata()
for func in self.instrumentListMetadata:
func(export)
@ -159,8 +160,8 @@ def startEngine(nsmClient, additionalData):
callbacks.instrumentMidiNoteOnActivity.append(_checkForKeySwitch)
callbacks._instrumentListMetadata() #Relatively quick. Happens only after a reload of the sample dir.
#One round of status updates for all instruments. Still no samples loaded, but we saved the status of each with our own data.
callbacks._instrumentListMetadata() #The big "build the database" callback
for instrument in session.data.allInstr():
callbacks._instrumentStatusChanged(*instrument.idKey)
@ -198,7 +199,7 @@ def rescanSampleDirectory(newBaseSamplePath):
session.data.parseAndLoadInstrumentLibraries(newBaseSamplePath, session.data.instrumentMidiNoteOnActivity, session.data.instrumentMidiNoteOffActivity)
callbacks._rescanSampleDir() #instructs the GUI to forget all cached data and start fresh.
callbacks._instrumentListMetadata() #Relatively quick. Happens only after a reload of the sample dir.
callbacks._instrumentListMetadata() #The big "build the database" callback
#One round of status updates for all instruments. Still no samples loaded, but we saved the status of each with our own data.
for instrument in session.data.allInstr():

5
engine/instrument.py

@ -146,8 +146,8 @@ class Instrument(object):
return result
def exportMetadata(self)->dict:
"""This gets called before the samples are loaded.
Only static data, that does not get changed during runtime, is included here.
"""
This is the big update that sends everything to build a GUI database
Please note that we don't add the default variant here. It is only important for the
external world to know what the current variant is. Which is handled by self.exportStatus()
@ -165,6 +165,7 @@ class Instrument(object):
result["defaultVariantWithoutSfzExtension"] = self.metadata["defaultVariant"].rstrip(".sfz") #str
result["tags"] = self.metadata["tags"].split(",") # list of str
result["instrumentsInLibraryCount"] = self.instrumentsInLibraryCount # int
result["status"] = self.exportStatus() #a dict
#Optional Tags.
result["group"] = self.metadata["group"] if "group" in self.metadata else "" #str

14
engine/main.py

@ -96,7 +96,7 @@ class Data(TemplateData):
if firstRun: #in case of re-scan we don't need to do this a second time. The default lib cannot be updated through the download manager and will always be present.
s = pathlib.Path(PATHS["share"])
defaultLibraryPath = s.joinpath("000 - Default.tar")
defaultLibraryPath = s.joinpath("000 - Default.tembro")
logger.info(f"Loading Default Instrument Library from {defaultLibraryPath}. This message must only appear once in the log.")
defaultLib = Library(parentData=self, tarFilePath=defaultLibraryPath) #If this fails we let the program crash. The default samples must exist and be accessible.
self.libraries[defaultLib.id] = defaultLib
@ -111,8 +111,8 @@ class Data(TemplateData):
checkForDuplicateLibraryFiles = set() #lib ids. only one lib with the same id is allowed.
for f in basePath.glob('*.tar'):
if f.is_file() and f.suffix == ".tar":
for f in basePath.glob('*.tembro'):
if f.is_file() and f.suffix == ".tembro":
#First load the library (this is .ini parsing, not sample loading, so it is cheap) and create a library object
#It will not create jack ports
try:
@ -164,7 +164,7 @@ class Data(TemplateData):
logger.info(f"Finished removing deleted libraries.")
if not self.libraries:
#TODO: Is this still valid with the guaranteed 000 - Default.tar?
#TODO: Is this still valid with the guaranteed 000 - Default.tembro?
logger.error("There were no sample libraries to parse! This is correct on an empty run, since you still need to choose a sample directory.")
self.instrumentMidiNoteOnActivity = instrumentMidiNoteOnActivity # the api will inject a callback function here which takes (libId, instrId) as parameter to indicate midi noteOn activity for non-critical information like a GUI LED blinking or checking for new keyswitch states. The instruments individiual midiprocessor will call this as a parent-call.
@ -199,7 +199,7 @@ class Data(TemplateData):
self.auditioner = Auditioner(self)
def exportMetadata(self)->dict:
"""Data we sent in callbacks. This is the initial 'build-the-instrument-database' function.
"""Data we sent in callbacks. This is the 'build-the-instrument-database' function.
Each first level dict contains another dict with instruments, but also a special key
"library" that holds the metadata for the lib itself.
"""
@ -298,7 +298,7 @@ class Data(TemplateData):
instObj.mixerLevel = instrSerialized["mixerLevel"]
class Library(object):
"""Open a .tar library and extract information without actually loading any samples.
"""Open a .tar / .tembro library and extract information without actually loading any samples.
This is for GUI data etc.
You get all metadata from this.
@ -314,7 +314,7 @@ class Library(object):
def __init__(self, parentData, tarFilePath):
self.parentData = parentData
self.tarFilePath = tarFilePath #pathlib.Path()
if not tarFilePath.suffix == ".tar":
if not tarFilePath.suffix == ".tembro":
raise RuntimeError(f"Wrong file {tarFilePath}")
self.instruments = {} # instrId : Instrument()

BIN
engine/resources/000 - Default.tar → engine/resources/000 - Default.tembro

Binary file not shown.
Loading…
Cancel
Save