Changeset 88432a9 for python/tests


Ignore:
Timestamp:
Jan 12, 2014, 2:59:49 AM (11 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:
bc24e9c
Parents:
3f9e8e5
Message:

python/lib/aubio/slicing.py: rewrite slicing loop from aubiocut, add some tests

Location:
python/tests
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/utils.py

    r3f9e8e5 r88432a9  
    1919    f.close()
    2020    return yaml_data
     21
     22def count_samples_in_file(file_path):
     23    from aubio import source
     24    hopsize = 256
     25    s = source(file_path, 0, hopsize)
     26    total_frames = 0
     27    while True:
     28        samples, read = s()
     29        total_frames += read
     30        if read < hopsize: break
     31    return total_frames
     32
     33def count_samples_in_directory(samples_dir):
     34    import os
     35    total_frames = 0
     36    for f in os.walk(samples_dir):
     37        if len(f[2]):
     38            for each in f[2]:
     39                file_path = os.path.join(f[0], each)
     40                if file_path:
     41                    total_frames += count_samples_in_file(file_path)
     42    return total_frames
Note: See TracChangeset for help on using the changeset viewer.