Changeset 4bc10e2 for src


Ignore:
Timestamp:
Oct 30, 2018, 12:57:10 PM (5 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
Children:
81abf91, 9b23815e, ed596f7
Parents:
357f81e (diff), cefa29d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into feature/earlynoteoff

Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_avcodec.c

    r357f81e r4bc10e2  
    3535// determine whether we use libavformat from ffmpeg or from libav
    3636#define FFMPEG_LIBAVFORMAT (LIBAVFORMAT_VERSION_MICRO > 99 )
    37 // max_analyze_duration2 was used from ffmpeg libavformat 55.43.100 through 57.2.100
     37// max_analyze_duration2 was used from ffmpeg libavformat 55.43.100 -> 57.2.100
    3838#define FFMPEG_LIBAVFORMAT_MAX_DUR2 FFMPEG_LIBAVFORMAT && ( \
    3939      (LIBAVFORMAT_VERSION_MAJOR == 55 && LIBAVFORMAT_VERSION_MINOR >= 43) \
     
    9393};
    9494
    95 // hack to create or re-create the context the first time _do or _do_multi is called
    96 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi);
    97 void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples);
     95// create or re-create the context when _do or _do_multi is called
     96void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s,
     97    uint_t multi);
     98// actually read a frame
     99void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s,
     100    uint_t * read_samples);
    98101
    99102uint_t aubio_source_avcodec_has_network_url(aubio_source_avcodec_t *s);
     
    112115
    113116
    114 aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path, uint_t samplerate, uint_t hop_size) {
     117aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path,
     118    uint_t samplerate, uint_t hop_size) {
    115119  aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t);
    116120  AVFormatContext *avFormatCtx = s->avFormatCtx;
     
    129133  }
    130134  if ((sint_t)samplerate < 0) {
    131     AUBIO_ERR("source_avcodec: Can not open %s with samplerate %d\n", path, samplerate);
     135    AUBIO_ERR("source_avcodec: Can not open %s with samplerate %d\n",
     136        path, samplerate);
    132137    goto beach;
    133138  }
    134139  if ((sint_t)hop_size <= 0) {
    135     AUBIO_ERR("source_avcodec: Can not open %s with hop_size %d\n", path, hop_size);
     140    AUBIO_ERR("source_avcodec: Can not open %s with hop_size %d\n",
     141        path, hop_size);
    136142    goto beach;
    137143  }
     
    173179    char errorstr[256];
    174180    av_strerror (err, errorstr, sizeof(errorstr));
    175     AUBIO_ERR("source_avcodec: Could not find stream information " "for %s (%s)\n", s->path,
    176         errorstr);
     181    AUBIO_ERR("source_avcodec: Could not find stream information "
     182        "for %s (%s)\n", s->path, errorstr);
    177183    goto beach;
    178184  }
     
    214220  avCodecCtx = avcodec_alloc_context3(codec);
    215221  if (!avCodecCtx) {
    216     AUBIO_ERR("source_avcodec: Failed to allocate the %s codec context for path %s\n",
    217         av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
     222    AUBIO_ERR("source_avcodec: Failed to allocate the %s codec context "
     223        "for path %s\n", av_get_media_type_string(AVMEDIA_TYPE_AUDIO),
     224        s->path);
    218225    goto beach;
    219226  }
     
    230237  /* Copy codec parameters from input stream to output codec context */
    231238  if ((err = avcodec_parameters_to_context(avCodecCtx, codecpar)) < 0) {
    232     AUBIO_ERR("source_avcodec: Failed to copy %s codec parameters to decoder context for %s\n",
    233        av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
     239    AUBIO_ERR("source_avcodec: Failed to copy %s codec parameters to "
     240        "decoder context for %s\n",
     241        av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
    234242    goto beach;
    235243  }
     
    239247    char errorstr[256];
    240248    av_strerror (err, errorstr, sizeof(errorstr));
    241     AUBIO_ERR("source_avcodec: Could not load codec for %s (%s)\n", s->path, errorstr);
     249    AUBIO_ERR("source_avcodec: Could not load codec for %s (%s)\n", s->path,
     250        errorstr);
    242251    goto beach;
    243252  }
     
    266275
    267276  /* allocate output for avr */
    268   s->output = (smpl_t *)av_malloc(AUBIO_AVCODEC_MAX_BUFFER_SIZE * sizeof(smpl_t));
     277  s->output = (smpl_t *)av_malloc(AUBIO_AVCODEC_MAX_BUFFER_SIZE
     278      * sizeof(smpl_t));
    269279
    270280  s->read_samples = 0;
     
    294304}
    295305
    296 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi) {
     306void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s,
     307    uint_t multi)
     308{
    297309  // create or reset resampler to/from mono/multi-channel
    298310  if ( (multi != s->multi) || (s->avr == NULL) ) {
     
    309321#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    310322
    311     av_opt_set_int(avr, "in_channel_layout",  input_layout,           0);
    312     av_opt_set_int(avr, "out_channel_layout", output_layout,          0);
    313     av_opt_set_int(avr, "in_sample_rate",     s->input_samplerate,    0);
    314     av_opt_set_int(avr, "out_sample_rate",    s->samplerate,          0);
     323    av_opt_set_int(avr, "in_channel_layout",  input_layout,              0);
     324    av_opt_set_int(avr, "out_channel_layout", output_layout,             0);
     325    av_opt_set_int(avr, "in_sample_rate",     s->input_samplerate,       0);
     326    av_opt_set_int(avr, "out_sample_rate",    s->samplerate,             0);
    315327    av_opt_set_int(avr, "in_sample_fmt",      s->avCodecCtx->sample_fmt, 0);
    316328#if HAVE_AUBIO_DOUBLE
    317     av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_DBL,      0);
    318 #else
    319     av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_FLT,      0);
     329    av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_DBL,         0);
     330#else
     331    av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_FLT,         0);
    320332#endif
    321333    // TODO: use planar?
     
    329341      char errorstr[256];
    330342      av_strerror (err, errorstr, sizeof(errorstr));
    331       AUBIO_ERR("source_avcodec: Could not open resampling context for %s (%s)\n",
    332           s->path, errorstr);
     343      AUBIO_ERR("source_avcodec: Could not open resampling context"
     344         " for %s (%s)\n", s->path, errorstr);
    333345      return;
    334346    }
     
    347359}
    348360
    349 void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples) {
     361void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s,
     362    uint_t * read_samples)
     363{
    350364  AVFormatContext *avFormatCtx = s->avFormatCtx;
    351365  AVCodecContext *avCodecCtx = s->avCodecCtx;
     
    388402      char errorstr[256];
    389403      av_strerror (err, errorstr, sizeof(errorstr));
    390       AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n", s->path, errorstr);
     404      AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n",
     405          s->path, errorstr);
    391406      s->eof = 1;
    392407      goto beach;
     
    406421  if (ret < 0) {
    407422    if (ret == AVERROR(EAGAIN)) {
    408       //AUBIO_WRN("source_avcodec: output is not available right now - user must try to send new input\n");
     423      //AUBIO_WRN("source_avcodec: output is not available right now - "
     424      //    "user must try to send new input\n");
    409425      goto beach;
    410426    } else if (ret == AVERROR_EOF) {
    411       AUBIO_WRN("source_avcodec: the decoder has been fully flushed, and there will be no more output frames\n");
     427      AUBIO_WRN("source_avcodec: the decoder has been fully flushed, "
     428          "and there will be no more output frames\n");
    412429    } else {
    413430      AUBIO_ERR("source_avcodec: decoding errors on %s\n", s->path);
     
    424441#endif
    425442  if (got_frame == 0) {
    426     AUBIO_WRN("source_avcodec: did not get a frame when reading %s\n", s->path);
     443    AUBIO_WRN("source_avcodec: did not get a frame when reading %s\n",
     444        s->path);
    427445    goto beach;
    428446  }
     
    431449  if (avFrame->channels != (sint_t)s->input_channels) {
    432450    AUBIO_WRN ("source_avcodec: trying to read from %d channel(s),"
    433         "but configured for %d; is '%s' corrupt?\n", avFrame->channels,
    434         s->input_channels, s->path);
    435     goto beach;
    436   }
     451        "but configured for %d; is '%s' corrupt?\n",
     452        avFrame->channels, s->input_channels, s->path);
     453    goto beach;
     454  }
     455#else
     456#warning "avutil < 53 is deprecated, crashes might occur on corrupt files"
    437457#endif
    438458
     
    455475#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    456476  if (out_samples <= 0) {
    457     AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n", s->path);
     477    AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n",
     478        s->path);
    458479    goto beach;
    459480  }
     
    473494}
    474495
    475 void aubio_source_avcodec_do(aubio_source_avcodec_t * s, fvec_t * read_data, uint_t * read){
     496void aubio_source_avcodec_do(aubio_source_avcodec_t * s, fvec_t * read_data,
     497    uint_t * read) {
    476498  uint_t i;
    477499  uint_t end = 0;
     
    505527}
    506528
    507 void aubio_source_avcodec_do_multi(aubio_source_avcodec_t * s, fmat_t * read_data, uint_t * read){
     529void aubio_source_avcodec_do_multi(aubio_source_avcodec_t * s,
     530    fmat_t * read_data, uint_t * read) {
    508531  uint_t i,j;
    509532  uint_t end = 0;
     
    551574
    552575uint_t aubio_source_avcodec_seek (aubio_source_avcodec_t * s, uint_t pos) {
    553   int64_t resampled_pos = (uint_t)ROUND(pos * (s->input_samplerate * 1. / s->samplerate));
     576  int64_t resampled_pos =
     577    (uint_t)ROUND(pos * (s->input_samplerate * 1. / s->samplerate));
    554578  int64_t min_ts = MAX(resampled_pos - 2000, 0);
    555579  int64_t max_ts = MIN(resampled_pos + 2000, INT64_MAX);
     
    559583    ret = AUBIO_OK;
    560584  } else {
    561     AUBIO_ERR("source_avcodec: failed seeking in %s (file not opened?)", s->path);
     585    AUBIO_ERR("source_avcodec: failed seeking in %s (file not opened?)",
     586        s->path);
    562587    return ret;
    563588  }
     
    570595      min_ts, resampled_pos, max_ts, seek_flags);
    571596  if (ret < 0) {
    572     AUBIO_ERR("source_avcodec: failed seeking to %d in file %s", pos, s->path);
     597    AUBIO_ERR("source_avcodec: failed seeking to %d in file %s",
     598        pos, s->path);
    573599  }
    574600  // reset read status
  • src/mathutils.c

    r357f81e r4bc10e2  
    523523  /* log(freq/A-2)/log(2) */
    524524  midi = freq / 6.875;
    525   midi = LOG (midi) / 0.69314718055995;
     525  midi = LOG (midi) / 0.6931471805599453;
    526526  midi *= 12;
    527527  midi -= 3;
     
    535535  if (midi > 140.) return 0.; // avoid infs
    536536  freq = (midi + 3.) / 12.;
    537   freq = EXP (freq * 0.69314718055995);
     537  freq = EXP (freq * 0.6931471805599453);
    538538  freq *= 6.875;
    539539  return freq;
  • src/spectral/filterbank_mel.h

    r357f81e r4bc10e2  
    5959
    6060  The filter coefficients are built according to Malcolm Slaney's Auditory
    61   Toolbox, available at http://engineering.purdue.edu/~malcolm/interval/1998-010/
    62   (see file mfcc.m).
     61  Toolbox, available online at the following address (see file mfcc.m):
     62
     63  https://engineering.purdue.edu/~malcolm/interval/1998-010/
    6364
    6465*/
  • src/spectral/mfcc.h

    r357f81e r4bc10e2  
    2727
    2828  The implementation follows the specifications established by Malcolm Slaney
    29   in its Auditory Toolbox, available online (see file mfcc.m).
     29  in its Auditory Toolbox, available online at the following address (see
     30  file mfcc.m):
    3031
    31   http://engineering.ecn.purdue.edu/~malcolm/interval/1998-010/
     32  https://engineering.purdue.edu/~malcolm/interval/1998-010/
    3233
    3334  \example spectral/test-mfcc.c
  • src/spectral/phasevoc.c

    r357f81e r4bc10e2  
    213213    synthold[i] += synth[i + pv->hop_s] * pv->scale;
    214214}
     215
     216uint_t aubio_pvoc_get_win(aubio_pvoc_t* pv)
     217{
     218  return pv->win_s;
     219}
     220
     221uint_t aubio_pvoc_get_hop(aubio_pvoc_t* pv)
     222{
     223  return pv->hop_s;
     224}
  • src/spectral/phasevoc.h

    r357f81e r4bc10e2  
    8989*/
    9090uint_t aubio_pvoc_get_win(aubio_pvoc_t* pv);
     91
    9192/** get hop size
    9293
  • src/synth/wavetable.c

    r357f81e r4bc10e2  
    165165  aubio_wavetable_set_amp (s, 0.);
    166166  //s->last_pos = 0;
    167   return aubio_wavetable_set_playing (s, 1);
     167  return aubio_wavetable_set_playing (s, 0);
    168168}
    169169
  • src/synth/wavetable.h

    r357f81e r4bc10e2  
    5151*/
    5252aubio_wavetable_t * new_aubio_wavetable(uint_t samplerate, uint_t hop_size);
    53 
    54 /** load source in wavetable
    55 
    56   \param o wavetable, created by new_aubio_wavetable()
    57   \param uri the uri of the source to load
    58 
    59   \return 0 if successful, non-zero otherwise
    60 
    61 */
    62 uint_t aubio_wavetable_load( aubio_wavetable_t * o, const char_t * uri );
    6353
    6454/** process wavetable function
Note: See TracChangeset for help on using the changeset viewer.