Browse Source

Update default instrument and more error checks

master
Nils 6 months ago
parent
commit
4e681b9ef9
  1. 6
      engine/instrument.py
  2. 8
      engine/main.py
  3. BIN
      engine/resources/000 - Default.tembro

6
engine/instrument.py

@ -205,8 +205,12 @@ class Instrument(object):
The function will do nothing when the instrument is not enabled.
"""
if not variantSfzFileName: #Can happen if there is an accidental empty entry in the library.ini
logger.error(f"{self.name} with id key {self.idKey} tried to load empty sfz variant. Probably a library.ini typo.")
return
if not self.enabled:
raise RuntimeError(f"{self.name} tried to load variant {variantSfzFileName} but was not yet enabled")
raise RuntimeError(f"{self.name} with id key {self.idKey} tried to load variant {variantSfzFileName} but was not yet enabled")
if not variantSfzFileName in self.variants:
raise ValueError("Variant not in list: {} {}".format(variantSfzFileName, self.variants))

8
engine/main.py

@ -110,7 +110,10 @@ class Data(TemplateData):
checkForDuplicateLibraryFiles = set() #lib ids. only one lib with the same id is allowed.
for f in basePath.glob('*.tembro'):
if f.is_file() and f.suffix == ".tembro":
if f.is_file() and "000 - Default" in f.name:
logger.warning(f"Found Default instrument id=000 in sample directory. We already have that included. Skipping.")
elif 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:
@ -284,6 +287,9 @@ class Data(TemplateData):
for libSerialized in serializedData["libraries"]:
libObj = self.libraries[libSerialized["id"]]
for instrSerialized in libSerialized["instruments"]:
if not instrSerialized["id"] in libObj.instruments:
logger.error(f"ID {libSerialized['id']}-{instrSerialized['id']} is in the save file but could not be found in the actual instruments. Tembro never removes production instruments. This may be a development oversight and is by definition harmless.")
continue #skip
instObj = libObj.instruments[instrSerialized["id"]]
instObj.startVariantSfzFilename = instrSerialized["currentVariant"]
if instrSerialized["currentVariant"]:

BIN
engine/resources/000 - Default.tembro

Binary file not shown.
Loading…
Cancel
Save