def get_dataflow(cls, params, samplerate): nboct = decimal.Decimal(params["CQTNbOctaves"]) original_fs = samplerate original_step = int(params["stepSize"]) samplerate = decimal.Decimal(samplerate) minFreq = decimal.Decimal(params["CQTMinFreq"]) * (2 ** (nboct - 1)) bandwidth = decimal.Decimal("0.95") # create dataflow df = DataFlow() signal_node = None # decimate until first octave to analyse nbdecim = 0 while (bandwidth * samplerate / 8) > minFreq: s = df.createNode("Decimate2", {}) if signal_node: df.link(signal_node, "", s, "") signal_node = s samplerate = samplerate / 2 nbdecim = nbdecim + 1 # check stepsize is OK with decimation # stepSize = int(params['stepSize']) # if (stepSize % (2**(nbdecim+nboct-1)))!=0: # stepSize = stepSize - stepSize % (2**(nbdecim+nboct-1)) # print 'WARNING: adjust stepSize to %i to make it compatible with successive decimation'%stepSize # compute octave CQT parameters Q = 2 / (2 ** (1.0 / int(params["CQTBinsPerOctave"])) - 1) fftLen = Q * float(samplerate / minFreq) fftLen = pow(2, math.ceil(math.log(fftLen) / math.log(2))) # current_stepSize = stepSize / (2**nbdecim) oct_params = { "CQTBinsPerOctave": params["CQTBinsPerOctave"], "CQTAlign": params["CQTAlign"], "CQTMinFreq": "%s" % str(minFreq / samplerate), "CQTMaxFreq": "%s" % str(2 * minFreq / samplerate - decimal.Decimal("1e-14")), } # for each octave, analysis, concatenate and decimation concat_node = df.createNode("Concatenate", {}) for oct in range(nboct, 0, -1): frames = df.createNode( "AdvancedFrameTokenizer", {"blockSize": "%i" % fftLen, "outStepSize": "%i" % original_step, "outSampleRate": "%f" % original_fs}, ) if signal_node: df.link(signal_node, "", frames, "") cspec = df.createNode("FFT", {"FFTLength": "%i" % fftLen, "FFTWindow": "None"}) df.link(frames, "", cspec, "") oct_cq = df.createNode("CQT", oct_params) df.link(cspec, "", oct_cq, "") df.link(oct_cq, "", concat_node, "%i" % (oct - 1)) if oct == 1: # no more octave to analyze, no need to decimate any more break # decimation for next actave analysis s = df.createNode("Decimate2", {}) if signal_node: df.link(signal_node, "", s, "") signal_node = s # current_stepSize = current_stepSize / 2 minFreq = minFreq / 2 return df
def get_dataflow(cls, params, samplerate): nboct = decimal.Decimal(params['CQTNbOctaves']) original_fs = samplerate original_step = int(params['stepSize']) samplerate = decimal.Decimal(samplerate) minFreq = decimal.Decimal(params['CQTMinFreq']) * (2 ** (nboct - 1)) bandwidth = decimal.Decimal('0.95') # create dataflow df = DataFlow() signal_node = None # decimate until first octave to analyse nbdecim = 0 while ((bandwidth * samplerate / 8) > minFreq): s = df.createNode('Decimate2', {}) if signal_node: df.link(signal_node, '', s, '') signal_node = s samplerate = samplerate / 2 nbdecim = nbdecim + 1 # check stepsize is OK with decimation # stepSize = int(params['stepSize']) # if (stepSize % (2**(nbdecim+nboct-1)))!=0: # stepSize = stepSize - stepSize % (2**(nbdecim+nboct-1)) # print 'WARNING: adjust stepSize to %i to make it compatible with successive decimation'%stepSize # compute octave CQT parameters Q = 2 / (2 ** (1.0 / int(params['CQTBinsPerOctave'])) - 1) fftLen = Q * float(samplerate / minFreq) fftLen = pow(2, math.ceil(math.log(fftLen) / math.log(2))) # current_stepSize = stepSize / (2**nbdecim) oct_params = {'CQTBinsPerOctave': params['CQTBinsPerOctave'], 'CQTAlign': params['CQTAlign'], 'CQTMinFreq': '%s' % str(minFreq / samplerate), 'CQTMaxFreq': '%s' % str(2 * minFreq / samplerate - decimal.Decimal('1e-14'))} # for each octave, analysis, concatenate and decimation concat_node = df.createNode('Concatenate', {}) for oct in range(nboct, 0, -1): frames = df.createNode('AdvancedFrameTokenizer', {'blockSize': '%i' % fftLen, 'outStepSize': '%i' % original_step, 'outSampleRate': '%f' % original_fs}) if signal_node: df.link(signal_node, '', frames, '') cspec = df.createNode( 'FFT', {'FFTLength': '%i' % fftLen, 'FFTWindow': 'None'}) df.link(frames, '', cspec, '') oct_cq = df.createNode('CQT', oct_params) df.link(cspec, '', oct_cq, '') df.link(oct_cq, '', concat_node, '%i' % (oct - 1)) if (oct == 1): # no more octave to analyze, no need to decimate any more break # decimation for next actave analysis s = df.createNode('Decimate2', {}) if signal_node: df.link(signal_node, '', s, '') signal_node = s # current_stepSize = current_stepSize / 2 minFreq = minFreq / 2 return df
def get_dataflow(cls, params, samplerate): nboct = decimal.Decimal(params['CQTNbOctaves']) original_fs = samplerate original_step = int(params['stepSize']) samplerate = decimal.Decimal(samplerate) minFreq = decimal.Decimal(params['CQTMinFreq']) * (2 ** (nboct - 1)) bandwidth = decimal.Decimal('0.95') # create dataflow df = DataFlow() signal_node = None # decimate until first octave to analyse nbdecim = 0 while ((bandwidth * samplerate / 8) > minFreq): s = df.createNode('Decimate2', {}) if signal_node: df.link(signal_node, '', s, '') signal_node = s samplerate = samplerate / 2 nbdecim = nbdecim + 1 # check stepsize is OK with decimation # stepSize = int(params['stepSize']) # if (stepSize % (2**(nbdecim+nboct-1)))!=0: # stepSize = stepSize - stepSize % (2**(nbdecim+nboct-1)) # print('WARNING: adjust stepSize to %i to make it compatible with successive decimation'%stepSize) # compute octave CQT parameters Q = 2 / (2 ** (1.0 / int(params['CQTBinsPerOctave'])) - 1) fftLen = Q * float(samplerate / minFreq) fftLen = pow(2, math.ceil(math.log(fftLen) / math.log(2))) # current_stepSize = stepSize / (2**nbdecim) oct_params = {'CQTBinsPerOctave': params['CQTBinsPerOctave'], 'CQTAlign': params['CQTAlign'], 'CQTMinFreq': '%s' % str(minFreq / samplerate), 'CQTMaxFreq': '%s' % str(2 * minFreq / samplerate - decimal.Decimal('1e-14'))} # for each octave, analysis, concatenate and decimation concat_node = df.createNode('Concatenate', {}) for oct in range(int(nboct), 0, -1): frames = df.createNode('AdvancedFrameTokenizer', {'blockSize': '%i' % fftLen, 'outStepSize': '%i' % original_step, 'outSampleRate': '%f' % original_fs}) if signal_node: df.link(signal_node, '', frames, '') cspec = df.createNode( 'FFT', {'FFTLength': '%i' % fftLen, 'FFTWindow': 'None'}) df.link(frames, '', cspec, '') oct_cq = df.createNode('CQT', oct_params) df.link(cspec, '', oct_cq, '') df.link(oct_cq, '', concat_node, '%i' % (oct - 1)) if (oct == 1): # no more octave to analyze, no need to decimate any more break # decimation for next actave analysis s = df.createNode('Decimate2', {}) if signal_node: df.link(signal_node, '', s, '') signal_node = s # current_stepSize = current_stepSize / 2 minFreq = minFreq / 2 return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode('SlopeIntegrator', params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode('Derivate', params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode('FrameTokenizer', params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode("SimpleThresholdClassification", params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode("DilationFilter", params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode("SimpleNoiseGate", params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode('SimpleThresholdClassification', params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode('AccumulateSameValues', params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode('WindowConvolution', params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode('DilationFilter', params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode("WindowConvolution", params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode("AccumulateSameValues", params) return df
def get_dataflow(cls, params, samplerate): df = DataFlow() df.createNode("HistogramIntegrator", params) return df