def _loadInstrumentPlugins(self): from InstrumentLoader import InstrumentLoader searchDirs = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask|NSLocalDomainMask|NSNetworkDomainMask, True) appName = u"Scotty" searchDirs = [ os.path.join(baseDir, appName, u"Instruments") for baseDir in searchDirs ] searchDirs.append(os.path.join(ModuleBundle.builtInPlugInsPath(), u"Instruments")) InstrumentLoader.loadInstrumentsInSearchPaths(searchDirs)
def _loadInstrumentPlugins(self): from InstrumentLoader import InstrumentLoader searchDirs = [ u'~/Library/Application Support/Substance Instruments', u'~/.substance/instruments', u'/Library/Application Support/Substance Instruments', u'/usr/local/share/substance/instruments', u'/usr/share/substance/instruments', u'/Network/Library/Application Support/Substance Instruments', ] searchDirs = [ os.path.expanduser(searchDir) for searchDir in searchDirs ] InstrumentLoader.loadInstrumentsInSearchPaths(searchDirs)
def _loadInstrumentPlugins(self): from InstrumentLoader import InstrumentLoader searchDirs = [ u'~/Library/Application Support/WILD Instruments', u'~/.wild/instruments', u'/Library/Application Support/WILD Instruments', u'/usr/local/share/wild/instruments', u'/usr/share/wild/instruments', u'/Network/Library/Application Support/WILD Instruments', ] searchDirs = [ os.path.expanduser(searchDir) for searchDir in searchDirs ] for searchDir in searchDirs: print "Searching in searchDir", searchDir if os.path.exists(searchDir): pluginPaths = [ os.path.join(searchDir, f) for f in os.listdir(searchDir) if f.endswith(u'.instrument') ] for pluginPath in pluginPaths: try: InstrumentLoader.loadInstrumentFromBundlePath(pluginPath) except Exception, e: # FIXME: Should probably alert user pluginName = os.path.basename(pluginPath) print u"Could not load plugin: %s: %s: %s" % (pluginName, e.__class__.__name__, e)
# | # V # # ******** Fully connected layer # | # V # # ABC Per-instrument classification neurons (outputs) # # We vary the following parameters to find the best accuracy. # - MFCC computation time intervals: 5ms, 10ms, 20ms, 25ms (matching various of the intervals in papers above) # - MFCC intervals in a sliding window presented to the neural network: 3, 4, 5 # (i.e. 15ms up to 125ms when multiplied by the time intervals). # - Training batch size instruments = InstrumentLoader(samplesDirPath, []) Log("Max, min MFCC rows across all instruments: ", instruments.maxMfccRows, instruments.minMfccRows) Log("Number of instruments by length in MFCC rows:") for k, v in sorted(instruments.mfccLenToSamplesMap.items()): suffix = '' if len(v) == 1: suffix = '(' + os.path.basename(v[0].wavPath) + ')' Log(" ", k, ": ", len(v), suffix) if instruments.minWavHz < wavMinAllowedHz: print( "ERROR: One or more wav files found with rate in Hz less than configured minimum. Min found:", instruments.minWavHz, " allowed min:", wavMinAllowedHz) exit(1)
import keras.models from KerasTensorFlowAnalyzer import KerasTensorFlowAnalyzer import MfccComparisonAnalyzer import os from SoundStreamAnalyzer import SoundStreamAnalyzer import sys if len(sys.argv) < 5: print('Usage:') print(' <wav-file-path> <instruments-folder-path> <model-file-path> <model-params-json-path>') exit(1) wavFilePath = sys.argv[1] instrumentsFolderPath = sys.argv[2] modelFilePath = sys.argv[3] modelParamsPath = sys.argv[4] trainedModel = keras.models.load_model(modelFilePath) # See SoundModelParams.py f = open(modelParamsPath) modelParams = json.load(f) orderedResultInstrumentLabels = modelParams["instruments"] print("Ordered labels:", orderedResultInstrumentLabels) instruments = InstrumentLoader(instrumentsFolderPath, orderedResultInstrumentLabels) analyzers = [ KerasTensorFlowAnalyzer(trainedModel, modelParams) ] + list(MfccComparisonAnalyzer.constructFromInstruments(instruments)) analyzer = SoundStreamAnalyzer(wavFilePath, instruments, analyzers, 0.9) analyzer.getMatches()