Ejemplo n.º 1
0
 def __init__(self,
              fmin=65,
              fmax=2100,
              unique_filters=True,
              models=None,
              **kwargs):
     from ..models import CHROMA_DNN
     from ..audio.signal import SignalProcessor, FramedSignalProcessor
     from ..audio.stft import ShortTimeFourierTransformProcessor
     from ..audio.spectrogram import LogarithmicFilteredSpectrogramProcessor
     from madmom.ml.nn import NeuralNetworkEnsemble
     # signal pre-processing
     sig = SignalProcessor(num_channels=1, sample_rate=44100)
     frames = FramedSignalProcessor(frame_size=8192, fps=10)
     stft = ShortTimeFourierTransformProcessor()  # caching FFT window
     spec = LogarithmicFilteredSpectrogramProcessor(
         num_bands=24, fmin=fmin, fmax=fmax, unique_filters=unique_filters)
     # split the spectrogram into overlapping frames
     spec_signal = SignalProcessor(sample_rate=10)
     spec_frames = FramedSignalProcessor(frame_size=15, hop_size=1, fps=10)
     # predict chroma bins with a DNN
     nn = NeuralNetworkEnsemble.load(models or CHROMA_DNN, **kwargs)
     # instantiate a SequentialProcessor
     super(DeepChromaProcessor, self).__init__([
         sig, frames, stft, spec, spec_signal, spec_frames, _dcp_flatten, nn
     ])
Ejemplo n.º 2
0
def Do():
    nn = NeuralNetworkEnsemble.load(DOWNBEATS_BLSTM)

    assert len(nn.processors) == 2
    assert type(nn.processors[0]) == madmom.processors.ParallelProcessor
    assert nn.processors[1] == madmom.ml.nn.average_predictions

    # 8个相同的网络
    pp = nn.processors[0]
    # for p in pp.processors:
    #     print(p)

    # 每个网络是个三层双向网络
    network = pp.processors[0]
    assert type(network) == madmom.ml.nn.NeuralNetwork

    BiLayers = network.layers
    print('biLayers size', len(BiLayers))
    PrintLayerParam(BiLayers[0])
    PrintLayerParam(BiLayers[1])
    PrintLayerParam(BiLayers[2])
    PrintFwdLayer(BiLayers[3])
    print(type(BiLayers))
    # print(BiLayers[3])  # a feedForwardLayer
    # BiLayers.pop()
    # return

    layer = BiLayers[0]
    assert type(layer) == madmom.ml.nn.layers.BidirectionalLayer

    lstmLayer = layer.fwd_layer
    assert type(lstmLayer) == madmom.ml.nn.layers.LSTMLayer

    # Test1(lstmLayer.input_gate)
    # Test2(lstmLayer)
    # Test3(lstmLayer)
    # Test4(layer)
    Test5(network)

    # GateParameter(lstmLayer.cell)
    # GateParameter(lstmLayer.input_gate)
    # GateParameter(lstmLayer.forget_gate)
    # GateParameter(lstmLayer.output_gate)

    print(type(lstmLayer.cell.activation_fn))

    print(lstmLayer.cell.activation_fn.__name__)
    # print(lstmLayer.cell.activation_fn == )
    print(lstmLayer.input_gate.activation_fn)
    print(lstmLayer.activation_fn)
Ejemplo n.º 3
0
    def __init__(self, fmin=65, fmax=2100, unique_filters=True, models=None,
                 **kwargs):
        from ..models import CHROMA_DNN
        from ..audio.signal import SignalProcessor, FramedSignalProcessor
        from ..audio.spectrogram import LogarithmicFilteredSpectrogramProcessor
        from madmom.ml.nn import NeuralNetworkEnsemble

        sig = SignalProcessor(num_channels=1, sample_rate=44100)
        frames = FramedSignalProcessor(frame_size=8192, fps=10)
        spec = LogarithmicFilteredSpectrogramProcessor(
            num_bands=24, fmin=fmin, fmax=fmax, unique_filters=unique_filters)
        spec_frames = FramedSignalProcessor(frame_size=15, hop_size=1)

        nn = NeuralNetworkEnsemble.load(models or CHROMA_DNN, **kwargs)

        super(DeepChromaProcessor, self).__init__([
            sig, frames, spec, spec_frames, _dcp_flatten, nn
        ])
Ejemplo n.º 4
0
 def __init__(self, fmin=65, fmax=2100, unique_filters=True, models=None,
              **kwargs):
     from ..models import CHROMA_DNN
     from ..audio.signal import SignalProcessor, FramedSignalProcessor
     from ..audio.stft import ShortTimeFourierTransformProcessor
     from ..audio.spectrogram import LogarithmicFilteredSpectrogramProcessor
     from madmom.ml.nn import NeuralNetworkEnsemble
     # signal pre-processing
     sig = SignalProcessor(num_channels=1, sample_rate=44100)
     frames = FramedSignalProcessor(frame_size=8192, fps=10)
     stft = ShortTimeFourierTransformProcessor()  # caching FFT window
     spec = LogarithmicFilteredSpectrogramProcessor(
         num_bands=24, fmin=fmin, fmax=fmax, unique_filters=unique_filters)
     # split the spectrogram into overlapping frames
     spec_signal = SignalProcessor(sample_rate=10)
     spec_frames = FramedSignalProcessor(frame_size=15, hop_size=1, fps=10)
     # predict chroma bins with a DNN
     nn = NeuralNetworkEnsemble.load(models or CHROMA_DNN, **kwargs)
     # instantiate a SequentialProcessor
     super(DeepChromaProcessor, self).__init__([
         sig, frames, stft, spec, spec_signal, spec_frames, _dcp_flatten, nn
     ])
Ejemplo n.º 5
0
def build_cnn(madmom_processor_filename):
    from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
    from madmom.audio.stft import ShortTimeFourierTransformProcessor
    from madmom.audio.spectrogram import (FilteredSpectrogramProcessor,
                                          LogarithmicSpectrogramProcessor)

    from madmom.ml.nn import NeuralNetworkEnsemble
    # define pre-processing chain
    sig = SignalProcessor(num_channels=1, sample_rate=44100)
    frames = FramedSignalProcessor(frame_size=4096, hop_size=441 * 2)
    stft = ShortTimeFourierTransformProcessor()  # caching FFT window
    filt = FilteredSpectrogramProcessor(num_bands=24, fmin=30, fmax=10000)

    # this is the money param! it was not whitelisted in 'canonicalize_audio_options'!
    spec = LogarithmicSpectrogramProcessor(add=1)
    # pre-processes everything sequentially
    pre_processor = SequentialProcessor([
        sig, frames, stft, filt, spec, _cnn_pad
    ])
    # process the pre-processed signal with a NN
    nn = NeuralNetworkEnsemble.load([madmom_processor_filename])
    return madmom.processors.SequentialProcessor([pre_processor, nn])
    def __init__(self, sr=44100, **kwargs):
        from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
        from madmom.audio.stft import ShortTimeFourierTransformProcessor
        from madmom.audio.spectrogram import (FilteredSpectrogramProcessor,
                                              LogarithmicSpectrogramProcessor)
        from madmom.ml.nn import NeuralNetworkEnsemble
        sr_ratio = 44100 / sr
        # define pre-processing chain
        sig = SignalProcessor(num_channels=1, sample_rate=sr)
        frames = FramedSignalProcessor(frame_size=4096 // sr_ratio,
                                       fps=50 // sr_ratio)
        stft = ShortTimeFourierTransformProcessor()  # caching FFT window
        filt = FilteredSpectrogramProcessor(num_bands=24, fmin=30, fmax=10000)
        spec = LogarithmicSpectrogramProcessor(add=1)
        # pre-processes everything sequentially
        pre_processor = SequentialProcessor(
            (sig, frames, stft, filt, spec, _cnn_pad))
        # process the pre-processed signal with a NN
        nn = NeuralNetworkEnsemble.load(VIENNA_MODEL_PATH)
        # instantiate a SequentialProcessor
        super().__init__((pre_processor, nn))

        self.adsr = ADSRMaestro()