source: src/io/ioutils.c @ 25d58dc

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5sampler
Last change on this file since 25d58dc was 33d0242, checked in by Paul Brossier <piem@piem.org>, 8 years ago

src/aubio_priv.h: move include config.h here

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[cf19b8a]1/*
2  Copyright (C) 2016 Paul Brossier <piem@aubio.org>
3
4  This file is part of aubio.
5
6  aubio is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10
11  aubio is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#include "aubio_priv.h"
22
23uint_t
24aubio_io_validate_samplerate(const char_t *kind, const char_t *path, uint_t samplerate)
25{
26  if ((sint_t)(samplerate) <= 0) {
27    AUBIO_ERR("%s: failed creating %s, samplerate should be positive, not %d\n",
28        kind, path, samplerate);
29    return AUBIO_FAIL;
30  }
31  if ((sint_t)samplerate > AUBIO_MAX_SAMPLERATE) {
32    AUBIO_ERR("%s: failed creating %s, samplerate %dHz is too large\n",
33        kind, path, samplerate);
34    return AUBIO_FAIL;
35  }
36  return AUBIO_OK;
37}
38
39uint_t
40aubio_io_validate_channels(const char_t *kind, const char_t *path, uint_t channels)
41{
42  if ((sint_t)(channels) <= 0) {
43    AUBIO_ERR("sink_%s: failed creating %s, channels should be positive, not %d\n",
44        kind, path, channels);
45    return AUBIO_FAIL;
46  }
47  if (channels > AUBIO_MAX_CHANNELS) {
48    AUBIO_ERR("sink_%s: failed creating %s, too many channels (%d but %d available)\n",
49        kind, path, channels, AUBIO_MAX_CHANNELS);
50    return AUBIO_FAIL;
51  }
52  return AUBIO_OK;
53}
Note: See TracBrowser for help on using the repository browser.