Пример #1
0
def quick_mode():
    '''
        Uses three short audio files for train and test data
        Should be used for testing that the system runs all the way through
        whithout crashing and not for estimating the strength of the features
        Outputs:
            List of medleydb tracks holding training data
            List of medleydb tracks holding test data
    '''
    train = [
        mdb.MultiTrack('MusicDelta_Reggae'),
        mdb.MultiTrack('MusicDelta_Rockabilly')
    ]
    test = [mdb.MultiTrack('MusicDelta_Shadows')]
    return train, test
    def test_two(self):
        mtrack = mdb.MultiTrack('ArcadeFire_BlackMirror')
        stem_indices = [2, 7]
        (actual_annotations, actual_annot_activity,
         actual_indices) = CMD.get_orig_stem_info(mtrack, stem_indices)

        expected_annotations = {
            4: {
                'tags': ['multif0', 'bass'],
                'times': [0.058049887],
                'freqs': [0.0]
            },
            6: {
                'tags': ['multif0', 'vocal', 'melody'],
                'times': [26.790022676],
                'freqs': [162.773]
            }
        }
        expected_annot_activity = {4: None, 6: None}
        expected_indices = [3, 4, 6]

        self.assertEqual(expected_annotations.keys(),
                         actual_annotations.keys())
        for k in actual_annotations.keys():
            self.assertEqual(expected_annotations[k]['tags'],
                             actual_annotations[k]['tags'])
            self.assertEqual(expected_annotations[k]['times'][0],
                             actual_annotations[k]['times'][0])
            self.assertEqual(expected_annotations[k]['freqs'][0],
                             actual_annotations[k]['freqs'][0])

        self.assertEqual(expected_annot_activity, actual_annot_activity)
        self.assertEqual(expected_indices, actual_indices)
    def test_one(self):
        mtrack = mdb.MultiTrack('AcDc_BackInBlack')
        stem_indices = [2, 4]
        (actual_annotations, actual_annot_activity,
         actual_indices) = CMD.get_orig_stem_info(mtrack, stem_indices)

        expected_annotations = {
            3: {
                'tags': ['multif0', 'bass'],
                'times': [5.294149660],
                'freqs': [85.2297]
            },
            6: {
                'tags': ['multif0', 'vocal', 'melody'],
                'times': [25.094965986],
                'freqs': [689.325]
            }
        }
        expected_annot_activity = {3: None, 6: None}
        expected_indices = [3, 5, 6]

        self.assertEqual(expected_annotations.keys(),
                         actual_annotations.keys())
        for k in actual_annotations.keys():
            self.assertEqual(expected_annotations[k]['tags'],
                             actual_annotations[k]['tags'])
            self.assertEqual(expected_annotations[k]['times'][0],
                             actual_annotations[k]['times'][0])
            self.assertEqual(expected_annotations[k]['freqs'][0],
                             actual_annotations[k]['freqs'][0])

        self.assertEqual(expected_annot_activity, actual_annot_activity)
        self.assertEqual(expected_indices, actual_indices)
    def test_one(self):
        replace_path = os.path.join(
            "/Users/rabitt/Dropbox/piano_guitar_resynth", "vocalists_replace")
        mtrack = mdb.MultiTrack('AHa_TakeOnMe')
        (actual_annotations, actual_altindices,
         actual_indicies) = CMD.get_replace_info(mtrack, replace_path)

        expected_annotations = {
            2: {
                'tags': ['multif0', 'vocal', 'melody'],
                'times': [11.104943311],
                'freqs': [150.758]
            }
        }
        expected_altindices = {
            2: os.path.join(replace_path, 'AHa_TakeOnMe_STEM_02_replace.wav')
        }
        expected_indices = [2]

        self.assertEqual(expected_annotations.keys(),
                         actual_annotations.keys())
        for k in actual_annotations.keys():
            self.assertEqual(expected_annotations[k]['tags'],
                             actual_annotations[k]['tags'])
            self.assertEqual(expected_annotations[k]['times'][0],
                             actual_annotations[k]['times'][0])
            self.assertEqual(expected_annotations[k]['freqs'][0],
                             actual_annotations[k]['freqs'][0])

        self.assertEqual(expected_altindices, actual_altindices)
        self.assertEqual(expected_indices, actual_indicies)
    def test_four(self):
        mtrack = mdb.MultiTrack("TablaBreakbeatScience_Animoog")
        save_dir = 'data'
        actual = CMD.get_fullmix_annotations(mtrack, save_dir)
        expected = {
            mtrack.mix_path: {
                'vocal': None,
                'bass': None,
                'melody': None
            }
        }

        self.assertEqual(sorted(expected.keys()), sorted(actual.keys()))
        files = []
        for key in actual.keys():
            self.assertEqual(sorted(expected[key].keys()),
                             sorted(actual[key].keys()))
            for subkey in actual[key].keys():
                if actual[key][subkey] is not None:
                    self.assertEqual(expected[key][subkey],
                                     actual[key][subkey])
                    self.assertTrue(os.path.exists(actual[key][subkey]))
                    files.append(actual[key][subkey])
                else:
                    self.assertEqual(expected[key][subkey],
                                     actual[key][subkey])

        for fpath in list(set(files)):
            os.remove(fpath)
    def test_two(self):
        resynth_path = '/Users/rabitt/Dropbox/piano_guitar_resynth/resynth'
        mtrack = mdb.MultiTrack('Adele_SomeoneLikeYou')
        (actual_annotations, actual_altindices, actual_indicies_guitar,
         actual_indices_piano) = CMD.get_resynth_info(mtrack, resynth_path,
                                                      [2])

        expected_annotations = {
            1: {
                'tags': ['multif0', 'piano'],
                'times': [0.83591836734693881],
                'freqs': [164.81377845643496]
            }
        }
        expected_altindices = {
            1:
            os.path.join(resynth_path,
                         'Adele_SomeoneLikeYou_STEM_01_resynth.wav')
        }
        expected_indices_guitar = []
        expected_indices_piano = [1]

        self.assertEqual(expected_annotations.keys(),
                         actual_annotations.keys())
        for k in actual_annotations.keys():
            self.assertEqual(expected_annotations[k]['tags'],
                             actual_annotations[k]['tags'])
            self.assertEqual(expected_annotations[k]['times'][0],
                             actual_annotations[k]['times'][0])
            self.assertEqual(expected_annotations[k]['freqs'][0],
                             actual_annotations[k]['freqs'][0])

        self.assertEqual(expected_altindices, actual_altindices)
        self.assertEqual(expected_indices_guitar, actual_indicies_guitar)
        self.assertEqual(expected_indices_piano, actual_indices_piano)
    def test_two(self):
        mtrack = mdb.MultiTrack("AcDc_BackInBlack")
        save_dir = 'data'
        actual = CMD.get_fullmix_annotations(mtrack, save_dir)
        expected = {
            mtrack.mix_path: {
                'vocal': 'data/AcDc_BackInBlack_MIX_vocal.txt',
                'bass': 'data/AcDc_BackInBlack_MIX_bass.txt'
            }
        }

        self.assertEqual(sorted(expected.keys()), sorted(actual.keys()))
        files = []
        for key in actual.keys():
            self.assertEqual(sorted(expected[key].keys()),
                             sorted(actual[key].keys()))
            for subkey in actual[key].keys():
                if actual[key][subkey] is not None:
                    self.assertEqual(expected[key][subkey],
                                     actual[key][subkey])
                    self.assertTrue(os.path.exists(actual[key][subkey]))
                    files.append(actual[key][subkey])
                else:
                    self.assertEqual(expected[key][subkey],
                                     actual[key][subkey])

        for fpath in list(set(files)):
            os.remove(fpath)
    def test_three(self):
        mtrack = mdb.MultiTrack("MusicDelta_BebopJazz")
        save_dir = 'data'
        actual = CMD.get_fullmix_annotations(mtrack, save_dir)
        expected = {
            mtrack.mix_path: {
                'vocal': None,
                'bass': 'data/MusicDelta_BebopJazz_MIX_bass.txt',
                'melody': 'data/MusicDelta_BebopJazz_MIX_melody.txt'
            }
        }

        self.assertEqual(sorted(expected.keys()), sorted(actual.keys()))
        files = []
        for key in actual.keys():
            self.assertEqual(sorted(expected[key].keys()),
                             sorted(actual[key].keys()))
            for subkey in actual[key].keys():
                if actual[key][subkey] is not None:
                    self.assertEqual(expected[key][subkey],
                                     actual[key][subkey])
                    self.assertTrue(os.path.exists(actual[key][subkey]))
                    files.append(actual[key][subkey])
                else:
                    self.assertEqual(expected[key][subkey],
                                     actual[key][subkey])

        for fpath in list(set(files)):
            os.remove(fpath)
Пример #9
0
def main():
    full_list = (
        TRACK_LIST_EXTRA + TRACK_LIST_V2 + TRACK_LIST_V1 + TRACK_LIST_BACH10
    )
    for track_id in full_list:
        print(track_id)
        try:
            mtrack = medleydb.MultiTrack(track_id)
            if mtrack.has_bleed:
                continue

            for stem in mtrack.stems.values():

                if not isinstance(stem.f0_type, list):
                    f0_type = [stem.f0_type]
                else:
                    f0_type = stem.f0_type

                if 'm' in f0_type and not os.path.exists(stem.pitch_pyin_path):
                    download.download_stem(mtrack, stem.stem_idx)

                    get_pyin_annotation(mtrack, stem.stem_idx, raw_id=None)

                    download.purge_downloaded_files()
        except:
            print("Something failed...")
Пример #10
0
def main():
    full_list = (TRACK_LIST_EXTRA + TRACK_LIST_V2 + TRACK_LIST_V1 +
                 TRACK_LIST_BACH10)
    for track_id in full_list:
        print(track_id)
        try:
            mtrack = medleydb.MultiTrack(track_id)
            if mtrack.has_bleed or os.path.exists(
                    mtrack.activation_conf_fpath):
                continue

            for stem in mtrack.stems.values():
                print(stem.stem_idx)
                download.download_stem(mtrack, stem.stem_idx)
                ensure_samplerate(stem.audio_path)

            activations, index_list = compute_activation_confidence(mtrack)
            write_activations_to_csv(mtrack,
                                     activations,
                                     index_list,
                                     debug=True)

            download.purge_downloaded_files()
        except:
            print("Something failed...")
Пример #11
0
def main(args):
    """Run pyin on a medleydb stem or raw track.
    """
    mtrack = medleydb.MultiTrack(args.track_id)
    stem_id = args.stem_id
    raw_id = args.raw_id

    get_pyin_annotation(mtrack, stem_id, raw_id)
 def test_empty(self):
     stem_annot_activity = {}
     mtrack = mdb.MultiTrack("MusicDelta_BebopJazz")
     save_dir = ""
     actual = CMD.generate_filtered_stems(stem_annot_activity, mtrack,
                                          save_dir)
     expected = {}
     self.assertEqual(expected, actual)
    def test_one(self):
        mtrack = mdb.MultiTrack("AHa_TakeOnMe")
        mix_path = 'data/test_mix.wav'
        mix_path_noguitar = 'data/test_mix_noguitar.wav'
        mix_path_nosynth = 'data/test_mix_nosynth.wav'
        stem_indices = [1, 2, 3, 4, 5, 6]
        stem_indices_guitar = [4]
        stem_indices_piano = [1, 3, 6]
        resynth_path = '/Users/rabitt/Dropbox/piano_guitar_resynth/resynth'
        replace_path = os.path.join('/Users/rabitt/Dropbox',
                                    'piano_guitar_resynth/vocalists_replace')
        altfiles = {
            1: os.path.join(resynth_path, "AHa_TakeOnMe_STEM_01_resynth.wav"),
            2: os.path.join(replace_path, "AHa_TakeOnMe_STEM_02_replace.wav"),
            3: os.path.join(resynth_path, "AHa_TakeOnMe_STEM_03_resynth.wav"),
            4: os.path.join(resynth_path, "AHa_TakeOnMe_STEM_04_resynth.wav"),
            6: os.path.join(resynth_path, "AHa_TakeOnMe_STEM_06_resynth.wav")
        }
        (actual_mix, actual_mix_noguitar,
         actual_mix_nosynth) = CMD.create_mixes(mtrack, mix_path,
                                                mix_path_noguitar,
                                                mix_path_nosynth, stem_indices,
                                                stem_indices_guitar,
                                                stem_indices_piano, altfiles)
        expected_mix = sorted([
            os.path.join(resynth_path, "AHa_TakeOnMe_STEM_01_resynth.wav"),
            os.path.join(replace_path, "AHa_TakeOnMe_STEM_02_replace.wav"),
            os.path.join(resynth_path, "AHa_TakeOnMe_STEM_03_resynth.wav"),
            os.path.join(resynth_path, "AHa_TakeOnMe_STEM_04_resynth.wav"),
            os.path.join(mdb.MEDLEYDB_PATH, 'Audio', 'AHa_TakeOnMe',
                         'AHa_TakeOnMe_STEMS', "AHa_TakeOnMe_STEM_05.wav"),
            os.path.join(resynth_path, "AHa_TakeOnMe_STEM_06_resynth.wav")
        ])
        expected_mix_noguitar = sorted([
            os.path.join(resynth_path, "AHa_TakeOnMe_STEM_01_resynth.wav"),
            os.path.join(replace_path, "AHa_TakeOnMe_STEM_02_replace.wav"),
            os.path.join(resynth_path, "AHa_TakeOnMe_STEM_03_resynth.wav"),
            os.path.join(mdb.MEDLEYDB_PATH, 'Audio', 'AHa_TakeOnMe',
                         'AHa_TakeOnMe_STEMS', "AHa_TakeOnMe_STEM_05.wav"),
            os.path.join(resynth_path, "AHa_TakeOnMe_STEM_06_resynth.wav")
        ])
        expected_mix_nosynth = sorted([
            os.path.join(replace_path, "AHa_TakeOnMe_STEM_02_replace.wav"),
            os.path.join(mdb.MEDLEYDB_PATH, 'Audio', 'AHa_TakeOnMe',
                         'AHa_TakeOnMe_STEMS', "AHa_TakeOnMe_STEM_05.wav"),
        ])

        self.assertEqual(expected_mix, sorted(actual_mix))
        self.assertEqual(expected_mix_noguitar, sorted(actual_mix_noguitar))
        self.assertEqual(expected_mix_nosynth, sorted(actual_mix_nosynth))

        self.assertTrue(os.path.exists(mix_path))
        os.remove(mix_path)
        self.assertTrue(os.path.exists(mix_path_noguitar))
        os.remove(mix_path_noguitar)
        self.assertTrue(os.path.exists(mix_path_nosynth))
        os.remove(mix_path_nosynth)
 def test_nonempty_list_two(self):
     mtrack = mdb.MultiTrack("MusicDelta_BebopJazz")
     stem_idx = [3, 4, 5]
     stem_list = [mtrack.stems[s] for s in stem_idx]
     actual_times, actual_freqs = CMD.get_annotation_mono(mtrack, stem_list)
     expected_times = None
     expected_freqs = None
     self.assertEqual(expected_times, actual_times)
     self.assertEqual(expected_freqs, actual_freqs)
 def test_nonempty_list_one(self):
     mtrack = mdb.MultiTrack("MusicDelta_BebopJazz")
     stem_idx = [4, 5]
     stem_list = [mtrack.stems[s] for s in stem_idx]
     actual_times, actual_freqs = CMD.get_annotation_mono(mtrack, stem_list)
     expected_times = [0.39473922900000002]
     expected_freqs = [193.88999999999999]
     self.assertEqual(expected_times[0], actual_times[0])
     self.assertEqual(expected_freqs[0], actual_freqs[0])
Пример #16
0
def main(args):
    """Main function to create melody annotations for a multitrack.
    """
    mtrack = medleydb.MultiTrack(args.track_id)
    melody1 = create_melody1_annotation(mtrack)
    melody2 = create_melody2_annotation(mtrack)
    melody3 = create_melody3_annotation(mtrack)
    if args.write_output:
        write_melodies_to_csv(mtrack, melody1, melody2, melody3)
Пример #17
0
def main(args):
    """Main function. Computes the activation confidence annotation for a given
    multitrack id.
    """
    mtrack = medleydb.MultiTrack(args.track_id)
    if os.path.exists(mtrack.activation_conf_fpath):
        return True

    activations, index_list = compute_activation_confidence(mtrack)
    write_activations_to_csv(mtrack, activations, index_list)
 def test_nonempty_two(self):
     stem_annot_activity = {1: None, 2: np.ones((2 * 44100, ))}
     mtrack = mdb.MultiTrack("MusicDelta_Reggae")
     save_dir = 'data'
     actual = CMD.generate_filtered_stems(stem_annot_activity, mtrack,
                                          save_dir)
     expected = {2: 'data/MusicDelta_Reggae_STEM_2_alt.wav'}
     self.assertEqual(expected, actual)
     self.assertTrue(
         os.path.exists('data/MusicDelta_Reggae_STEM_2_alt.wav'))
     os.remove('data/MusicDelta_Reggae_STEM_2_alt.wav')
Пример #19
0
 def __init__(self,
              baseDir=DATASET_BASE_DIRS['MedleyDB'],
              sr=44100,
              transform=None):
     super(MedleyDB_vocal_Dataset, self).__init__(baseDir, sr, transform)
     pathPairs = []
     for pathPair in self.pathPairs:
         title = pathPair.title
         if not mdb.MultiTrack(title).is_instrumental:
             pathPairs.append(pathPair)
     self.pathPairs = pathPairs
    def test_one(self):
        mtrack = mdb.MultiTrack("AHa_TakeOnMe")
        resynth_path = '/Users/rabitt/Dropbox/piano_guitar_resynth/resynth'
        replace_path = os.path.join('/Users/rabitt/Dropbox',
                                    'piano_guitar_resynth/vocalists_replace')
        save_dir = 'data'
        actual = CMD.create_complete_resynth_mix(mtrack, resynth_path,
                                                 replace_path, save_dir)
        expected = {
            "data/AHa_TakeOnMe_MIX_complete_resynth.wav": {
                'multif0': "data/AHa_TakeOnMe_multif0_annotation.txt",
                'guitar': "data/AHa_TakeOnMe_guitar_annotation.txt",
                'piano': None,
                'vocal': "data/AHa_TakeOnMe_vocal_annotation.txt",
                'melody': "data/AHa_TakeOnMe_melody_annotation.txt",
                'bass': None
            },
            "data/AHa_TakeOnMe_MIX_complete_noguitar.wav": {
                'multif0': "data/AHa_TakeOnMe_multif0_noguitar_annotation.txt",
                'guitar': None,
                'piano': None,
                'vocal': "data/AHa_TakeOnMe_vocal_annotation.txt",
                'melody': "data/AHa_TakeOnMe_melody_annotation.txt",
                'bass': None
            },
            "data/AHa_TakeOnMe_MIX_complete_nosynth.wav": {
                'multif0': "data/AHa_TakeOnMe_multif0_nosynth_annotation.txt",
                'guitar': None,
                'piano': None,
                'vocal': "data/AHa_TakeOnMe_vocal_annotation.txt",
                'melody': "data/AHa_TakeOnMe_melody_annotation.txt",
                'bass': None
            }
        }

        self.assertEqual(sorted(expected.keys()), sorted(actual.keys()))
        files = []
        for key in actual.keys():
            self.assertEqual(sorted(expected[key].keys()),
                             sorted(actual[key].keys()))
            self.assertTrue(os.path.exists(key))
            os.remove(key)
            for subkey in actual[key].keys():
                if actual[key][subkey] is not None:
                    self.assertEqual(expected[key][subkey],
                                     actual[key][subkey])
                    self.assertTrue(os.path.exists(actual[key][subkey]))
                    files.append(actual[key][subkey])
                else:
                    self.assertEqual(expected[key][subkey],
                                     actual[key][subkey])

        for fpath in list(set(files)):
            os.remove(fpath)
    def test_one(self):
        mtrack = mdb.MultiTrack('AHa_TakeOnMe')
        save_dir = 'data'
        resynth_path = '/Users/rabitt/Dropbox/piano_guitar_resynth/resynth'
        replace_path = os.path.join('/Users/rabitt/Dropbox',
                                    'piano_guitar_resynth/vocalists_replace')
        actual = CMD.get_all_audio_annot_pairs(mtrack, save_dir, resynth_path,
                                               replace_path)

        expected = 'data/AHa_TakeOnMe_training_pairs.json'
        self.assertEqual(expected, actual)
        self.assertTrue(os.path.exists(actual))
Пример #22
0
def test_mode():
    '''
        Loads the train_test data split from memory
        Outputs:
            train: List of multitrack objects to be used for training
            test: List of multitrack objects to be used for testing
    '''
    if not os.path.isfile(train_test_name):
        make_test_data()
        print('Uh oh, you are starting to test before any validation?!')
        print('Run again if you are really sure, but consider switching modes')
        quit()

    with open(train_test_name, 'r') as file:
        tt_data = json.load(file)
        train_ids = tt_data['train']  # Do nothing with test data
        test_ids = tt_data['test']

    train = [mdb.MultiTrack(t_id) for t_id in train_ids]
    test = [mdb.MultiTrack(t_id) for t_id in test_ids]
    return train, test
    def test_one(self):
        resynth_path = '/Users/rabitt/Dropbox/piano_guitar_resynth/resynth'
        mtrack = mdb.MultiTrack('AHa_TakeOnMe')
        (actual_annotations, actual_altindices, actual_indicies_guitar,
         actual_indices_piano) = CMD.get_resynth_info(mtrack, resynth_path,
                                                      [2])

        expected_annotations = {
            1: {
                'tags': ['multif0'],
                'times': [119.4550566893424],
                'freqs': [830.60939515989025]
            },
            3: {
                'tags': ['multif0'],
                'times': [11.435827664399094],
                'freqs': [123.47082531403103]
            },
            4: {
                'tags': ['multif0', 'guitar'],
                'times': [49.458503401360545],
                'freqs': [293.66476791740757]
            },
            6: {
                'tags': ['multif0'],
                'times': [5.5495691609977325],
                'freqs': [246.94165062806206]
            }
        }
        expected_altindices = {
            1: os.path.join(resynth_path, 'AHa_TakeOnMe_STEM_01_resynth.wav'),
            3: os.path.join(resynth_path, 'AHa_TakeOnMe_STEM_03_resynth.wav'),
            4: os.path.join(resynth_path, 'AHa_TakeOnMe_STEM_04_resynth.wav'),
            6: os.path.join(resynth_path, 'AHa_TakeOnMe_STEM_06_resynth.wav')
        }
        expected_indices_guitar = [4]
        expected_indices_piano = [1, 3, 6]

        self.assertEqual(expected_annotations.keys(),
                         actual_annotations.keys())
        for k in actual_annotations.keys():
            self.assertEqual(expected_annotations[k]['tags'],
                             actual_annotations[k]['tags'])
            self.assertEqual(expected_annotations[k]['times'][0],
                             actual_annotations[k]['times'][0])
            self.assertEqual(expected_annotations[k]['freqs'][0],
                             actual_annotations[k]['freqs'][0])

        self.assertEqual(expected_altindices, actual_altindices)
        self.assertEqual(expected_indices_guitar, actual_indicies_guitar)
        self.assertEqual(expected_indices_piano, actual_indices_piano)
Пример #24
0
def validation_mode():
    '''
        Creates a random split of the training data into train/test
        Inputs:
            Float ranging from 0 to 1 referring to how to split data up
        Outputs:
            train: List of multitrack objects to be used for training
            test: List of multitrack objects to be used for validation
    '''
    # If we do not have a train/test set yet - create it!
    if not os.path.isfile(train_test_name):
        make_test_data()

    with open(train_test_name, 'r') as file:
        tt_data = json.load(file)

    melody_ids = tt_data['train']  # Do nothing with test data
    splits = mdb.utils.artist_conditional_split(trackid_list=melody_ids,
                                                test_size=train_validate_split,
                                                num_splits=1)

    train = [mdb.MultiTrack(t_id) for t_id in splits[0]['train']]
    test = [mdb.MultiTrack(t_id) for t_id in splits[0]['test']]
    return train, test
    def test_three(self):
        mtrack = mdb.MultiTrack('ArcadeFire_BlackMirror')
        resynth_path = '/Users/rabitt/Dropbox/piano_guitar_resynth/resynth'
        stem_indices = []
        (actual_annotations, actual_altindices, actual_indicies_guitar,
         actual_indices_piano) = CMD.get_resynth_info(mtrack, resynth_path,
                                                      stem_indices)

        expected_annotations = {
            2: {
                'tags': ['multif0', 'guitar'],
                'times': [10.832108843537416],
                'freqs': [116.54094037952248]
            },
            7: {
                'tags': ['multif0', 'guitar'],
                'times': [11.122358276643991],
                'freqs': [116.54094037952248]
            }
        }
        expected_altindices = {
            2:
            os.path.join(resynth_path,
                         'ArcadeFire_BlackMirror_STEM_02_resynth.wav'),
            7:
            os.path.join(resynth_path,
                         'ArcadeFire_BlackMirror_STEM_07_resynth.wav')
        }
        expected_indices_guitar = [2, 7]
        expected_indices_piano = []

        self.assertEqual(expected_annotations.keys(),
                         actual_annotations.keys())
        for k in actual_annotations.keys():
            self.assertEqual(expected_annotations[k]['tags'],
                             actual_annotations[k]['tags'])
            self.assertEqual(expected_annotations[k]['times'][0],
                             actual_annotations[k]['times'][0])
            self.assertEqual(expected_annotations[k]['freqs'][0],
                             actual_annotations[k]['freqs'][0])

        self.assertEqual(expected_altindices, actual_altindices)
        self.assertEqual(expected_indices_guitar, actual_indicies_guitar)
        self.assertEqual(expected_indices_piano, actual_indices_piano)
    def test_three(self):
        mtrack = mdb.MultiTrack('MusicDelta_BebopJazz')
        stem_indices = [3]
        (actual_annotations, actual_annot_activity,
         actual_indices) = CMD.get_orig_stem_info(mtrack, stem_indices)

        expected_annotations = {
            2: {
                'tags': ['multif0', 'bass'],
                'times': [0.632743764],
                'freqs': [86.5701]
            },
            4: {
                'tags': ['multif0', 'melody'],
                'times': [0.429569160],
                'freqs': [190.852]
            },
            5: {
                'tags': ['multif0', 'melody'],
                'times': [0.400544217],
                'freqs': [380.532]
            }
        }
        expected_annot_activity = {2: None, 4: [0.5], 5: [0.5]}
        expected_indices = [1, 2, 4, 5]

        self.assertEqual(expected_annotations.keys(),
                         actual_annotations.keys())
        for k in actual_annotations.keys():
            self.assertEqual(expected_annotations[k]['tags'],
                             actual_annotations[k]['tags'])
            self.assertEqual(expected_annotations[k]['times'][0],
                             actual_annotations[k]['times'][0])
            self.assertEqual(expected_annotations[k]['freqs'][0],
                             actual_annotations[k]['freqs'][0])

        self.assertEqual(expected_annot_activity[2], actual_annot_activity[2])
        self.assertEqual(expected_annot_activity[4][0],
                         actual_annot_activity[4][0])
        self.assertEqual(expected_annot_activity[5][0],
                         actual_annot_activity[5][0])
        self.assertEqual(expected_indices, actual_indices)
    def test_two(self):
        mtrack = mdb.MultiTrack('ArcadeFire_BlackMirror')
        replace_path = os.path.join(
            "/Users/rabitt/Dropbox/piano_guitar_resynth", "vocalists_replace")
        (actual_annotations, actual_altindices,
         actual_indicies) = CMD.get_replace_info(mtrack, replace_path)

        expected_annotations = {}
        expected_altindices = {}
        expected_indices = []

        self.assertEqual(expected_annotations.keys(),
                         actual_annotations.keys())
        for k in actual_annotations.keys():
            self.assertEqual(expected_annotations[k]['tags'],
                             actual_annotations[k]['tags'])
            self.assertEqual(expected_annotations[k]['times'][0],
                             actual_annotations[k]['times'][0])
            self.assertEqual(expected_annotations[k]['freqs'][0],
                             actual_annotations[k]['freqs'][0])

        self.assertEqual(expected_altindices, actual_altindices)
        self.assertEqual(expected_indices, actual_indicies)
 def test_one(self):
     mtrack = mdb.MultiTrack("AHa_TakeOnMe")
     save_dir = 'data'
     actual = CMD.get_fullmix_annotations(mtrack, save_dir)
     expected = {mtrack.mix_path: {}}
     self.assertEqual(expected, actual)