Changeset 31a09d2 for python/tests


Ignore:
Timestamp:
Jul 10, 2015, 2:26:27 AM (9 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
9c8c8a6
Parents:
665b711
Message:

ext/py-musicutils.c: add silence_detection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_musicutils.py

    r665b711 r31a09d2  
    66from math import pi
    77
    8 from aubio import window, level_lin, db_spl
     8from aubio import window, level_lin, db_spl, silence_detection
    99
    1010from aubio import fvec
     
    7676        assert_equal(db_spl(-ones(1024, dtype="float32")), 0.)
    7777
     78class aubio_silence_detection(TestCase):
     79    def test_accept_fvec(self):
     80        silence_detection(fvec(1024), -70.)
     81
     82    def test_fail_not_fvec(self):
     83        try:
     84            silence_detection("default", -70)
     85        except ValueError, e:
     86            pass
     87        else:
     88            self.fail('non-number input phase does not raise a TypeError')
     89
     90    def test_zeros_is_one(self):
     91        from math import isinf
     92        assert silence_detection(fvec(1024), -70) == 1
     93
     94    def test_minus_ones_is_zero(self):
     95        from numpy import ones
     96        assert silence_detection(ones(1024, dtype="float32"), -70) == 0
     97
    7898if __name__ == '__main__':
    7999    from unittest import main
Note: See TracChangeset for help on using the changeset viewer.