Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the way the spectrogram differences are stacked. #82

Merged
merged 2 commits into from
Feb 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions bin/BeatDetector
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ from __future__ import absolute_import, division, print_function

import glob
import argparse
import numpy as np

from madmom import MODELS_PATH

from madmom.processors import IOProcessor, io_arguments
from madmom.audio.signal import SignalProcessor
from madmom.processors import (SequentialProcessor, ParallelProcessor,
IOProcessor, io_arguments)
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor,
StackedSpectrogramProcessor)
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.beats import BeatDetectionProcessor
Expand Down Expand Up @@ -84,7 +84,7 @@ def main():
args.num_channels = 1
args.sample_rate = 44100
args.fps = 100
args.frame_size = [1024, 2048, 4096]
args.frame_sizes = [1024, 2048, 4096]
args.num_bands = 3
args.fmin = 30
args.fmax = 17000
Expand All @@ -94,6 +94,7 @@ def main():
args.add = 1
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
MODELS_PATH)

Expand All @@ -108,16 +109,22 @@ def main():
else:
# define processing chain
sig = SignalProcessor(**vars(args))
# we need to define how specs and diffs should be stacked
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
stack = StackedSpectrogramProcessor(spectrogram=spec, difference=diff,
**vars(args))
# multi-resolution spec & diff
multi = []
for args.frame_size in args.frame_sizes:
frames = FramedSignalProcessor(**vars(args))
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
# wrap each frame size with spec and diff in a SequentialProcessor
multi.append(SequentialProcessor((frames, spec, diff)))
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
avg = average_predictions
# sequentially process everything
in_processor = [sig, stack, rnn, avg]
in_processor = [sig, multi, stack, rnn, avg]

# output processor
if args.save:
Expand Down
30 changes: 19 additions & 11 deletions bin/BeatTracker
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ from __future__ import absolute_import, division, print_function

import glob
import argparse
import numpy as np

from madmom import MODELS_PATH
from madmom.processors import IOProcessor, io_arguments
from madmom.audio.signal import SignalProcessor
from madmom.processors import (SequentialProcessor, ParallelProcessor,
IOProcessor, io_arguments)
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor,
StackedSpectrogramProcessor)
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.beats import BeatTrackingProcessor
Expand Down Expand Up @@ -82,7 +83,7 @@ def main():
args.num_channels = 1
args.sample_rate = 44100
args.fps = 100
args.frame_size = [1024, 2048, 4096]
args.frame_sizes = [1024, 2048, 4096]
args.num_bands = 3
args.fmin = 30
args.fmax = 17000
Expand All @@ -92,6 +93,7 @@ def main():
args.add = 1
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
MODELS_PATH)

Expand All @@ -106,16 +108,22 @@ def main():
else:
# define processing chain
sig = SignalProcessor(**vars(args))
# we need to define how specs and diffs should be stacked
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
stack = StackedSpectrogramProcessor(spectrogram=spec, difference=diff,
**vars(args))
# multi-resolution spec & diff
multi = []
for args.frame_size in args.frame_sizes:
frames = FramedSignalProcessor(**vars(args))
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
# wrap each frame size with spec and diff in a SequentialProcessor
multi.append(SequentialProcessor((frames, spec, diff)))
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
avg = average_predictions
# sequentially process everything
in_processor = [sig, stack, rnn, avg]
in_processor = [sig, multi, stack, rnn, avg]

# output processor
if args.save:
Expand Down
32 changes: 20 additions & 12 deletions bin/CRFBeatDetector
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ from __future__ import absolute_import, division, print_function

import glob
import argparse
import numpy as np

from madmom import MODELS_PATH
from madmom.processors import IOProcessor, io_arguments
from madmom.audio.signal import SignalProcessor
from madmom.processors import (SequentialProcessor, ParallelProcessor,
IOProcessor, io_arguments)
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor,
StackedSpectrogramProcessor)
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.beats import CRFBeatDetectionProcessor
Expand Down Expand Up @@ -85,7 +86,7 @@ def main():
args.num_channels = 1
args.sample_rate = 44100
args.fps = 100
args.frame_size = [1024, 2048, 4096]
args.frame_sizes = [1024, 2048, 4096]
args.num_bands = 3
args.fmin = 30
args.fmax = 17000
Expand All @@ -95,6 +96,7 @@ def main():
args.add = 1
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
MODELS_PATH)

Expand All @@ -109,16 +111,22 @@ def main():
else:
# define processing chain
sig = SignalProcessor(**vars(args))
# we need to define how specs and diffs should be stacked
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
stack = StackedSpectrogramProcessor(spectrogram=spec, difference=diff,
**vars(args))
# process everything with a RNN and average the predictions
# multi-resolution spec & diff
multi = []
for args.frame_size in args.frame_sizes:
frames = FramedSignalProcessor(**vars(args))
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
# wrap each frame size with spec and diff in a SequentialProcessor
multi.append(SequentialProcessor((frames, spec, diff)))
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
avg = average_predictions
# sequentially process everything
in_processor = [sig, stack, rnn, avg]
in_processor = [sig, multi, stack, rnn, avg]

# output processor
if args.save:
Expand Down
32 changes: 20 additions & 12 deletions bin/DBNBeatTracker
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ from __future__ import absolute_import, division, print_function

import glob
import argparse
import numpy as np

from madmom import MODELS_PATH
from madmom.processors import IOProcessor, io_arguments
from madmom.audio.signal import SignalProcessor
from madmom.processors import (SequentialProcessor, ParallelProcessor,
IOProcessor, io_arguments)
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor,
StackedSpectrogramProcessor)
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.beats import DBNBeatTrackingProcessor
Expand Down Expand Up @@ -83,7 +84,7 @@ def main():
args.num_channels = 1
args.sample_rate = 44100
args.fps = 100
args.frame_size = [1024, 2048, 4096]
args.frame_sizes = [1024, 2048, 4096]
args.num_bands = 3
args.fmin = 30
args.fmax = 17000
Expand All @@ -93,6 +94,7 @@ def main():
args.add = 1
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
MODELS_PATH)

Expand All @@ -107,16 +109,22 @@ def main():
else:
# define processing chain
sig = SignalProcessor(**vars(args))
# we need to define how specs and diffs should be stacked
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
stack = StackedSpectrogramProcessor(spectrogram=spec, difference=diff,
**vars(args))
# process everything with a RNN and average the predictions
# multi-resolution spec & diff
multi = []
for args.frame_size in args.frame_sizes:
frames = FramedSignalProcessor(**vars(args))
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
# wrap each frame size with spec and diff in a SequentialProcessor
multi.append(SequentialProcessor((frames, spec, diff)))
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
avg = average_predictions
# sequentially process everything
in_processor = [sig, stack, rnn, avg]
in_processor = [sig, multi, stack, rnn, avg]

# output processor
if args.save:
Expand Down
31 changes: 19 additions & 12 deletions bin/MMBeatTracker
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ from __future__ import absolute_import, division, print_function

import glob
import argparse
import numpy as np

from madmom import MODELS_PATH
from madmom.processors import IOProcessor, io_arguments
from madmom.audio.signal import SignalProcessor
from madmom.processors import (SequentialProcessor, ParallelProcessor,
IOProcessor, io_arguments)
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor,
StackedSpectrogramProcessor)
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor
from madmom.features import ActivationsProcessor
from madmom.features.beats import (DBNBeatTrackingProcessor,
Expand Down Expand Up @@ -87,11 +88,10 @@ def main():
# parse arguments
args = p.parse_args()

# set immutable defaults
args.num_channels = 1
args.sample_rate = 44100
args.fps = 100
args.frame_size = [1024, 2048, 4096]
args.frame_sizes = [1024, 2048, 4096]
args.num_bands = 3
args.fmin = 30
args.fmax = 17000
Expand All @@ -101,6 +101,7 @@ def main():
args.add = 1
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
MODELS_PATH)

Expand All @@ -115,11 +116,17 @@ def main():
else:
# define processing chain
sig = SignalProcessor(**vars(args))
# we need to define how specs and diffs should be stacked
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
stack = StackedSpectrogramProcessor(spectrogram=spec, difference=diff,
**vars(args))
# multi-resolution spec & diff
multi = []
for args.frame_size in args.frame_sizes:
frames = FramedSignalProcessor(**vars(args))
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
# wrap each frame size with spec and diff in a SequentialProcessor
multi.append(SequentialProcessor((frames, spec, diff)))
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and select the best predictions
rnn = RNNProcessor(**vars(args))
if args.nn_ref_files is None:
Expand All @@ -137,7 +144,7 @@ def main():
# define the selector
selector = MultiModelSelectionProcessor(num_ref_predictions)
# sequentially process everything
in_processor = [sig, stack, rnn, selector]
in_processor = [sig, multi, stack, rnn, selector]

# output processor
if args.save:
Expand Down
30 changes: 19 additions & 11 deletions bin/OnsetDetector
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ from __future__ import absolute_import, division, print_function

import glob
import argparse
import numpy as np

from madmom import MODELS_PATH
from madmom.processors import IOProcessor, io_arguments
from madmom.audio.signal import SignalProcessor
from madmom.processors import (SequentialProcessor, ParallelProcessor,
IOProcessor, io_arguments)
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor,
StackedSpectrogramProcessor)
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.onsets import PeakPickingProcessor
Expand Down Expand Up @@ -73,7 +74,7 @@ def main():
args.num_channels = 1
args.sample_rate = 44100
args.fps = 100
args.frame_size = [1024, 2048, 4096]
args.frame_sizes = [1024, 2048, 4096]
args.num_bands = 6
args.fmin = 30
args.fmax = 17000
Expand All @@ -83,6 +84,7 @@ def main():
args.add = 1
args.diff_ratio = 0.25
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/onsets/2013/onsets_brnn_[1-8].npz" %
MODELS_PATH)
args.pre_max = 1. / args.fps
Expand All @@ -99,16 +101,22 @@ def main():
else:
# define processing chain
sig = SignalProcessor(**vars(args))
# we need to define how specs and diffs should be stacked
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
stack = StackedSpectrogramProcessor(spectrogram=spec, difference=diff,
**vars(args))
# multi-resolution spec & diff
multi = []
for args.frame_size in args.frame_sizes:
frames = FramedSignalProcessor(**vars(args))
spec = LogarithmicFilteredSpectrogramProcessor(**vars(args))
diff = SpectrogramDifferenceProcessor(**vars(args))
# wrap each frame size with spec and diff in a SequentialProcessor
multi.append(SequentialProcessor((frames, spec, diff)))
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
avg = average_predictions
# sequentially process everything
in_processor = [sig, stack, rnn, avg]
in_processor = [sig, multi, stack, rnn, avg]

# output processor
if args.save:
Expand Down
Loading