def test_read_ann_beats_old_jams(): """Trying to read an old jams file.""" my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3")) my_file_struct.ref_file = os.path.join("fixtures", "old_jams.jams") pcp = PCP(my_file_struct, FeatureTypes.ann_beatsync, sr=11025) times, frames = pcp.read_ann_beats() assert times is None assert frames is None
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_frame_times(): my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3")) pcp = PCP(my_file_struct, FeatureTypes.ann_beatsync, sr=11025) pcp.feat_types = "wrong" pcp.frame_times
def test_frame_times_no_annotations(): """Checking frame times when there are no beat annotations.""" my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3")) my_file_struct.ref_file = os.path.join("fixtures", "old_jams.jams") pcp = PCP(my_file_struct, FeatureTypes.ann_beatsync, sr=11025) pcp.frame_times
def test_frame_times_framesync(): """Checking frame times of framesync type of features""" my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3")) pcp = PCP(my_file_struct, FeatureTypes.framesync, sr=11025) times = pcp.frame_times assert(isinstance(times, np.ndarray))
def test_frame_times_old_jams(): """Trying to use invalid jams file.""" my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3")) my_file_struct.ref_file = os.path.join("fixtures", "old_jams.jams") pcp = PCP(my_file_struct, FeatureTypes.ann_beatsync, sr=11025) pcp.frame_times