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

IO module #346

Merged
merged 31 commits into from
Apr 5, 2018
Merged

IO module #346

merged 31 commits into from
Apr 5, 2018

Conversation

superbock
Copy link
Collaborator

@superbock superbock commented Dec 7, 2017

Changes proposed in this pull request

This PR moves all IO functionality into a separate module. This pull request supersedes #313.

  • a new io module is created which bundles all feature loading/writing functionality which was split among the different feature.x and evaluation.y modules,
  • madmom.io.audio constitutes the functionality of audio.ffmpeg and all the loading functions from audio.signal,
  • write functions do not return any data, only write it to file
  • evaluation class expect annotations and detections, file handling moved to evaluate script
  • writing of MIREX output formats moved to programs

When merged, this PR fixes #306, fixes #302 and fixes #192.

Remaining TODOs before this pull request can be merged

  • write_notes_midi should go into io.midi
  • check which load_chords function to use
  • unify loading of events/onsets/beats EDIT: ~will be~~ was addressed in a separate PR, see issue Unify behaviour of load functions. #338
  • refactor tests after the final structure is defined
  • move load_key to io
  • handling of MIREX output formats should maybe go into a separate io.mirex module EDIT: since this is only relevant for notes and tempo we'll leave it where it is with a distinct name it is cleaner to move MIREX output formatting directly into the programs
  • move filter_downbeats to io-module or rewrite as write_downbeats?
  • load/write tempo has lots of additional logic which probably shouldn't be there EDIT: moved to a separate issue loading/writing tempo has lots of logic included #356
  • expand_notes() was moved to utils, not sure if this is a good place

@superbock superbock force-pushed the io_module branch 6 times, most recently from a8489f2 to d27c6b6 Compare December 21, 2017 13:18
@superbock superbock force-pushed the io_module branch 2 times, most recently from a6a2cd8 to 7c445f9 Compare February 13, 2018 07:56
@superbock superbock mentioned this pull request Feb 13, 2018
@superbock superbock force-pushed the io_module branch 6 times, most recently from 04029c2 to 8288e19 Compare February 13, 2018 11:42
@superbock superbock requested a review from fdlm March 4, 2018 10:41
@superbock superbock changed the title [WIP] IO module IO module Mar 4, 2018
raise LoadAudioFileError(error)
warnings.warn(load_audio_file.__doc__)
from ..io.audio import load_wave_file
return load_wave_file(*args, **kwargs)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be load_audio_file

Copy link
Contributor

@fdlm fdlm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's a huge and important one. I have some minor comments that can be addressed easily, I think. I can take care of anything chord/key related.

@@ -75,7 +77,7 @@ def main():
# save the deep chroma vectors to a file
out_processor = ActivationsProcessor(mode='w', **vars(args))
else:
# load conditional random field
# regocgnise chords with a conditional random field and output them
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recognise...

Chords in `CHORD_ANN_DTYPE` format

"""
# TODO: Join consecutive labels of identical chords
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this TODO is obsolete. merge() does this.

SEGMENT_DTYPE = [('start', np.float), ('end', np.float), ('label', object)]


def _open_file(fn):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is probably unnecessary. It can be replaced with open_file, I guess.

@@ -51,20 +63,13 @@ class TestLoadKeyFunction(unittest.TestCase):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests should be moved to test_io.



# loading function
class TestLoadOnsetsFunction(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should also go to test_io, no?

@@ -40,30 +41,32 @@ def _compare_labels(test_case, labels, reference_labels):
test_case.assertTrue((labels['label'] == reference_labels['label']).all())


class TestLoadSegmentsFunction(unittest.TestCase):
def test_read_segments_from_file(self):
class TestLoadChordsFunction(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These things should also be moved to test_io...

@superbock superbock force-pushed the io_module branch 2 times, most recently from fcc1825 to ddfe586 Compare April 5, 2018 11:04
Copy link
Contributor

@fdlm fdlm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a final remark, otherwise great!

from .midi import load_midi, write_midi
from ..utils import suppress_warnings, string_types

if sys.version_info[0] < 3:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that _open_file is gone, this can be removed as well (sorry, did not mention this in the previous comment)

@superbock superbock merged commit 9dd454c into master Apr 5, 2018
@superbock superbock deleted the io_module branch April 5, 2018 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants