forked from CPJKU/madmom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DCChordRecognition
executable file
·89 lines (65 loc) · 2.76 KB
/
DCChordRecognition
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python
# encoding: utf-8
"""
Deep Chroma based Chord Recognizer
"""
from __future__ import absolute_import, division, print_function
import argparse
from madmom.audio import DeepChromaProcessor
from madmom.features import (ActivationsProcessor,
DeepChromaChordRecognitionProcessor)
from madmom.io import write_chords
from madmom.processors import IOProcessor, io_arguments
def main():
"""DCChordRecognition"""
p = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter, description='''
The DCChordRecognition program recognises major and minor chords in an
audio file by first extracting chroma vectors according to the method
described in
Filip Korzeniowski and Gerhard Widmer,
"Feature Learning for Chord Recognition: The Deep Chroma Extractor",
Proceedings of the 17th International Society for Music Information
Retrieval Conference (ISMIR), 2016,
and then decoding the most likely chord sequence using a linear-chain
Conditional Random Field.
This program can be run in 'single' file mode to process a single audio
file and write the recognised chords to STDOUT or the given output file.
$ DCChordRecogniser single INFILE [-o OUTFILE]
The program can also be run in 'batch' mode to process multiple audio
files and save the chords to files with the given suffix.
$ DCChordRecogniser batch [-o OUTPUT_DIR] [-s OUTPUT_SUFFIX] FILES
If no output directory is given, the program writes the files with the
extracted chords to the same location as the audio files.
The 'pickle' mode can be used to store the used parameters to be able to
exactly reproduce experiments.
'''
)
# version
p.add_argument('--version', action='version',
version='DCChordRecogniser.2016')
io_arguments(p, output_suffix='.chords.txt')
ActivationsProcessor.add_arguments(p)
args = p.parse_args()
# set immutable arguments
args.fps = 10
if args.verbose:
print(args)
# input processor
if args.load:
# load deep chroma vectors from a file
in_processor = ActivationsProcessor(mode='r', **vars(args))
else:
in_processor = DeepChromaProcessor(**vars(args))
# output processor
if args.save:
# save the deep chroma vectors to a file
out_processor = ActivationsProcessor(mode='w', **vars(args))
else:
# recognise chords with a conditional random field and output them
chord_processor = DeepChromaChordRecognitionProcessor(**vars(args))
out_processor = [chord_processor, write_chords]
processor = IOProcessor(in_processor, out_processor)
args.func(processor, **vars(args))
if __name__ == '__main__':
main()