def test_read_features_wrong_fun(): my_file_struct = FileStruct("01_-_Come_Together.wav") my_file_struct.features_file = os.path.join( "fixtures", "01_-_Come_Together.json") mfcc = MFCC(my_file_struct, FeatureTypes.est_beatsync, sr=22050) mfcc.ref_power = np.mean mfcc.read_features()
def test_registry(): """All the features should be in the features register.""" assert(CQT.get_id() in msaf.base.features_registry.keys()) assert(PCP.get_id() in msaf.base.features_registry.keys()) assert(Tonnetz.get_id() in msaf.base.features_registry.keys()) assert(MFCC.get_id() in msaf.base.features_registry.keys()) assert(Tempogram.get_id() in msaf.base.features_registry.keys())
def test_change_global_paramaters(): """The features should be correctly updated if global parameters updated.""" feat_type = FeatureTypes.framesync CQT(file_struct, feat_type, sr=11025).features assert (os.path.isfile(file_struct.features_file)) with open(file_struct.features_file) as f: data = json.load(f) assert(CQT.get_id() in data.keys()) # These should have disappeared, since we now have new global parameters assert(MFCC.get_id() not in data.keys()) assert(Tonnetz.get_id() not in data.keys()) assert(Tempogram.get_id() not in data.keys()) assert(PCP.get_id() not in data.keys()) assert("framesync" in data[CQT.get_id()].keys()) assert("est_beatsync" in data[CQT.get_id()].keys()) assert("ann_beatsync" in data[CQT.get_id()].keys())
def test_change_local_cqt_paramaters(): """The features should be correctly updated if parameters of CQT are updated.""" feat_type = FeatureTypes.framesync CQT(file_struct, feat_type, n_bins=70).features assert (os.path.isfile(file_struct.features_file)) with open(file_struct.features_file) as f: data = json.load(f) assert(CQT.get_id() in data.keys()) # These should be here from previous tests assert(MFCC.get_id() in data.keys()) assert(Tonnetz.get_id() in data.keys()) assert(Tempogram.get_id() in data.keys()) assert(PCP.get_id() in data.keys()) assert("framesync" in data[CQT.get_id()].keys()) assert("est_beatsync" in data[CQT.get_id()].keys()) assert("ann_beatsync" in data[CQT.get_id()].keys())
def test_wrong_ref_power_mfcc(): """Test for wrong parameters for ref_power of the mfcc.""" MFCC(file_struct, FeatureTypes.framesync, ref_power="caca")