Beispiel #1
0
def parse_smc(input_dir, output_dir):
    '''Convert smc to jams'''

    # Get a list of the wavs, tags, and txts

    wav_files = find_with_extension(os.path.join(input_dir, 'SMC_MIREX_Audio'),
                                    'wav',
                                    depth=1)

    ann_files = find_with_extension(os.path.join(
        input_dir, 'SMC_MIREX_Annotations_05_08_2014'),
                                    'txt',
                                    depth=1)

    tag_files = find_with_extension(os.path.join(input_dir, 'SMC_MIREX_Tags'),
                                    'tag',
                                    depth=1)

    # Make sure everything lines up
    assert len(wav_files) == len(ann_files)
    assert len(wav_files) == len(tag_files)

    for wav, ann, tag in zip(wav_files, ann_files, tag_files):
        # Get the file metadata
        metadata = smc_file_metadata(wav)

        # Get the annotation
        beat_annotation = smc_annotation(ann)

        # Get the tags
        tag_annotation = smc_tags(tag, metadata.duration)

        jam = jams.JAMS(file_metadata=metadata)
        jam.annotations.append(beat_annotation)
        jam.annotations.append(tag_annotation)

        # Add content path to the top-level sandbox
        jam.sandbox.content_path = os.path.basename(wav)

        # Save the jam
        save_jam(output_dir, jam)
Beispiel #2
0
def parse_smc(input_dir, output_dir):
    '''Convert smc to jams'''

    # Get a list of the wavs, tags, and txts

    wav_files = find_with_extension(os.path.join(input_dir,
                                                 'SMC_MIREX_Audio'),
                                    'wav', depth=1)

    ann_files = find_with_extension(os.path.join(input_dir,
                                                 'SMC_MIREX_Annotations_05_08_2014'),
                                    'txt', depth=1)

    tag_files = find_with_extension(os.path.join(input_dir,
                                                 'SMC_MIREX_Tags'),
                                    'tag', depth=1)

    # Make sure everything lines up
    assert len(wav_files) == len(ann_files)
    assert len(wav_files) == len(tag_files)

    for wav, ann, tag in zip(wav_files, ann_files, tag_files):
        # Get the file metadata
        metadata = smc_file_metadata(wav)

        # Get the annotation
        beat_annotation = smc_annotation(ann)

        # Get the tags
        tag_annotation = smc_tags(tag, metadata.duration)

        jam = jams.JAMS(file_metadata=metadata)
        jam.annotations.append(beat_annotation)
        jam.annotations.append(tag_annotation)

        # Add content path to the top-level sandbox
        jam.sandbox.content_path = os.path.basename(wav)

        # Save the jam
        save_jam(output_dir, jam)
Beispiel #3
0
    def __test(level, sort):
        results = util.find_with_extension(root, 'txt', depth=level, sort=sort)

        eq_(sorted(results), sorted(files[:level]))
Beispiel #4
0
def test_find_with_extension(root_and_files, level, sort):
    root, files = root_and_files
    results = util.find_with_extension(root, 'txt', depth=level, sort=sort)

    assert sorted(results) == sorted(files[:level])
Beispiel #5
0
def test_find_with_extension(root_and_files, level, sort):
    root, files = root_and_files
    results = util.find_with_extension(root, 'txt', depth=level, sort=sort)

    assert sorted(results) == sorted(files[:level])