Changeset 85e20fa for src


Ignore:
Timestamp:
Dec 20, 2018, 5:21:19 PM (9 months ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/timestretch, master
Children:
14a5b9a
Parents:
b2e1740
Message:

[io] add helpers to check source output sizes

Location:
src/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/io/ioutils.c

    rb2e1740 r85e20fa  
    5454
    5555uint_t
     56aubio_source_validate_input_length(const char_t *kind, const char_t *path,
     57    uint_t hop_size, uint_t read_data_length)
     58{
     59  uint_t length = hop_size;
     60  if (hop_size < read_data_length) {
     61    AUBIO_WRN("%s: partial read from %s, trying to read %d frames, but"
     62        " hop_size is %d\n", kind, path, read_data_length, hop_size);
     63  } else if (hop_size > read_data_length) {
     64    AUBIO_WRN("%s: partial read from %s, trying to read %d frames into"
     65        " a buffer of length %d\n", kind, path, hop_size, read_data_length);
     66    length = read_data_length;
     67  }
     68  return length;
     69}
     70
     71uint_t
     72aubio_source_validate_input_channels(const char_t *kind, const char_t *path,
     73    uint_t source_channels, uint_t read_data_height)
     74{
     75  uint_t channels = source_channels;
     76  if (read_data_height < source_channels) {
     77    AUBIO_WRN("%s: partial read from %s, trying to read %d channels,"
     78        " but found output of height %d\n", kind, path, source_channels,
     79        read_data_height);
     80    channels = read_data_height;
     81  } else if (read_data_height > source_channels) {
     82    // do not show a warning when trying to read into more channels than
     83    // the input source.
     84#if 0
     85    AUBIO_WRN("%s: partial read from %s, trying to read %d channels,"
     86        " but found output of height %d\n", kind, path, source_channels,
     87        read_data_height);
     88#endif
     89    channels = source_channels;
     90  }
     91  return channels;
     92}
     93
     94uint_t
    5695aubio_sink_validate_input_length(const char_t *kind, const char_t *path,
    5796    uint_t max_size, uint_t write_data_length, uint_t write)
  • src/io/ioutils.h

    rb2e1740 r85e20fa  
    5454    uint_t channels);
    5555
    56 /** validate length of input
     56/** validate length of source output
     57
     58  \param kind       the object kind to report on
     59  \param path       the path to report on
     60  \param hop_size   number of frames to be read
     61  \param read_data_length actual length of input
     62
     63  \return hop_size or the maximum number of frames that can be written
     64*/
     65uint_t
     66aubio_source_validate_input_length(const char_t *kind, const char_t *path,
     67    uint_t hop_size, uint_t read_data_length);
     68
     69/** validate height of source output
     70
     71  \param kind       the object kind to report on
     72  \param path       the path to report on
     73  \param source_channels maximum number of channels that can be written
     74  \param read_data_height actual height of input
     75
     76  \return write_data_height or the maximum number of channels
     77*/
     78uint_t
     79aubio_source_validate_input_channels(const char_t *kind, const char_t *path,
     80    uint_t source_channels, uint_t read_data_height);
     81
     82/** validate length of sink input
    5783
    5884  \param kind       the object kind to report on
    5985  \param path       the path to report on
    6086  \param max_size   maximum number of frames that can be written
    61   \param write_data_length actual length of input vector/matrix
     87  \param write_data_length actual length of input
    6288  \param write number of samples asked
    6389
     
    6894    uint_t max_size, uint_t write_data_length, uint_t write);
    6995
    70 /** validate height of input
     96/** validate height of sink input
    7197
    7298  \param kind       the object kind to report on
    7399  \param path       the path to report on
    74   \param max_size  maximum number of channels that can be written
     100  \param sink_channels maximum number of channels that can be written
    75101  \param write_data_height actual height of input matrix
    76102
Note: See TracChangeset for help on using the changeset viewer.