Пример #1
0
def test_no_audio_no_features():
    """The features should raise a NoFileAudioError if no features nor
    audio files are found."""
    # This file doesn't exist
    no_audio_file_struct = FileStruct("fixtures/caca.mp3")
    feat_type = FeatureTypes.framesync
    CQT(no_audio_file_struct, feat_type, sr=11025).features
Пример #2
0
def test_no_audio_no_params():
    """The features should raise a NoFileAudioError if different parameters
    want to be explored and no audio file is found."""
    # This file doesn't exist
    no_audio_file_struct = FileStruct("fixtures/chirp_noaudio.mp3")
    feat_type = FeatureTypes.framesync
    CQT(no_audio_file_struct, feat_type, sr=11025).features
Пример #3
0
def test_wrong_type_frame_times():
    """Trying to use custom type for frame times."""
    my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3"))
    my_file_struct.features_file = os.path.join("features", "no_file.json")
    FeatureTypes2 = Enum('FeatureTypes',
                         'framesync1 est_beatsync ann_beatsync')
    cqt = CQT(my_file_struct, FeatureTypes2.framesync1, sr=11025)
    cqt.frame_times
Пример #4
0
def test_no_audio():
    """The features should be returned even without having an audio file if
    they have been previously been computed."""
    # This file doesn't exist
    no_audio_file_struct = FileStruct("fixtures/chirp_noaudio.mp3")
    feat_type = FeatureTypes.framesync
    CQT(no_audio_file_struct, feat_type, sr=22050).features
    assert (os.path.isfile(no_audio_file_struct.features_file))
    with open(no_audio_file_struct.features_file) as f:
        data = json.load(f)
    assert (CQT.get_id() in data.keys())
Пример #5
0
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())
Пример #6
0
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())
Пример #7
0
def test_wrong_ref_power_cqt():
    """Test for wrong parameters for ref_power of the cqt."""
    CQT(file_struct, FeatureTypes.framesync, ref_power="caca")
Пример #8
0
def test_wrong_ann_frame_times():
    """Trying to get annotated frametimes when no annotated beats are found."""
    my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3"))
    my_file_struct.features_file = os.path.join("features", "no_file.json")
    cqt = CQT(my_file_struct, FeatureTypes.ann_beatsync, sr=11025)
    cqt.frame_times
Пример #9
0
def test_ann_features():
    """Testing the annotated beat synchornized features."""
    CQT(file_struct, FeatureTypes.ann_beatsync, sr=11025).features