Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/io/sink_sndfile.c

    r5fc6e81 re406835  
    4949  uint_t scratch_size;
    5050  smpl_t *scratch_data;
    51   int format;
    5251};
    5352
    5453uint_t aubio_sink_sndfile_open(aubio_sink_sndfile_t *s);
    55 
    56 uint_t aubio_str_extension_matches(const char_t *ext,
    57     const char_t *pattern);
    58 const char_t *aubio_str_get_extension(const char_t *filename);
    5954
    6055aubio_sink_sndfile_t * new_aubio_sink_sndfile(const char_t * path, uint_t samplerate) {
     
    7267  s->samplerate = 0;
    7368  s->channels = 0;
    74 
    75   aubio_sink_sndfile_preset_format(s, aubio_str_get_extension(path));
    7669
    7770  // zero samplerate given. do not open yet
     
    119112  if (s->samplerate != 0 /* && s->channels != 0 */) {
    120113    return aubio_sink_sndfile_open(s);
    121   }
    122   return AUBIO_OK;
    123 }
    124 
    125 uint_t aubio_sink_sndfile_preset_format(aubio_sink_sndfile_t *s,
    126     const char_t *fmt)
    127 {
    128   if (aubio_str_extension_matches(fmt, "wav")) {
    129     s->format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
    130   } else if (aubio_str_extension_matches(fmt, "aiff")) {
    131     s->format = SF_FORMAT_AIFF | SF_FORMAT_PCM_16;
    132   } else if (aubio_str_extension_matches(fmt, "flac")) {
    133     s->format = SF_FORMAT_FLAC | SF_FORMAT_PCM_16;
    134   } else if (aubio_str_extension_matches(fmt, "ogg")) {
    135     s->format = SF_FORMAT_OGG | SF_FORMAT_VORBIS;
    136   } else if (atoi(fmt) > 0x010000) {
    137     s->format = atoi(fmt);
    138   } else {
    139     s->format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
    140     if (fmt && strnlen(fmt, PATH_MAX))  {
    141       AUBIO_WRN("sink_sndfile: could not guess format %s for %s,"
    142           " using default (wav)\n", fmt, s->path);
    143       return AUBIO_FAIL;
    144     }
    145114  }
    146115  return AUBIO_OK;
     
    163132  sfinfo.samplerate = s->samplerate;
    164133  sfinfo.channels   = s->channels;
    165   sfinfo.format     = s->format;
     134  sfinfo.format     = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
    166135
    167136  /* try creating the file */
Note: See TracChangeset for help on using the changeset viewer.