Changes in / [eaaba62:bd1fa89]


Ignore:
Files:
15 added
11 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • doc/web.cfg

    reaaba62 rbd1fa89  
    715715                         ../src/pitch/pitchfcomb.h \
    716716                         ../src/tempo/beattracking.h \
     717                         ../src/utils/hist.h \
    717718                         ../src/utils/scale.h \
    718719                         ../src/utils.h
  • python/demos/demo_specdesc.py

    reaaba62 rbd1fa89  
    2222pv = pvoc(win_s, hop_s)
    2323
    24 methods = ['default', 'energy', 'hfc', 'complex', 'phase', 'specdiff', 'kl', 'mkl',
    25     'specflux', 'centroid', 'spread', 'skewness', 'kurtosis', 'slope', 'decrease',
    26     'rolloff', ]
     24methods = ['default', 'energy', 'hfc', 'complex', 'phase', 'specdiff', 'kl',
     25        'mkl', 'specflux', 'centroid', 'slope', 'rolloff', 'spread', 'skewness',
     26        'kurtosis', 'decrease',]
    2727
    2828all_descs = {}
     
    4040    samples, read = s()
    4141    fftgrain = pv(samples)
    42     print "%f" % ( total_frames / float(samplerate) ),
     42    #print "%f" % ( total_frames / float(samplerate) ),
    4343    for method in methods:
    4444        specdesc_val = o[method](fftgrain)[0]
    4545        all_descs[method] = hstack ( [all_descs[method], specdesc_val] )
    46         print "%f" % specdesc_val,
    47     print
     46        #print "%f" % specdesc_val,
     47    #print
    4848    total_frames += read
    4949    if read < hop_s: break
     
    5353    import matplotlib.pyplot as plt
    5454    from demo_waveform_plot import get_waveform_plot
     55    from demo_waveform_plot import set_xlabels_sample2time
    5556    fig = plt.figure()
    5657    plt.rc('lines',linewidth='.8')
    5758    wave = plt.axes([0.1, 0.75, 0.8, 0.19])
    58     get_waveform_plot(filename, samplerate, ax = wave )
     59    get_waveform_plot(filename, samplerate, block_size = hop_s, ax = wave )
    5960    wave.yaxis.set_visible(False)
    6061    wave.xaxis.set_visible(False)
     
    7475                horizontalalignment='right', verticalalignment='bottom',
    7576                )
    76     if all_desc_times[-1] / float(samplerate) > 60:
    77         plt.xlabel('time (mm:ss)')
    78         ax.set_xticklabels([ "%02d:%02d" % (t/float(samplerate)/60, (t/float(samplerate))%60) for t in ax.get_xticks()[:-1]], rotation = 50)
    79     else:
    80         plt.xlabel('time (ss.mm)')
    81         ax.set_xticklabels([ "%02d.%02d" % (t/float(samplerate), 100*((t/float(samplerate))%1) ) for t in ax.get_xticks()[:-1]], rotation = 50)
     77    set_xlabels_sample2time(ax, all_desc_times[-1], samplerate)
    8278    #plt.ylabel('spectral descriptor value')
    8379    ax.xaxis.set_visible(True)
  • python/demos/demo_waveform_plot.py

    reaaba62 rbd1fa89  
    55from numpy import zeros, hstack
    66
    7 def get_waveform_plot(filename, samplerate = 0, ax = None):
     7def get_waveform_plot(filename, samplerate = 0, block_size = 4096, ax = None):
    88    import matplotlib.pyplot as plt
    99    if not ax:
    1010        fig = plt.figure()
    1111        ax = fig.add_subplot(111)
    12     hop_s = 4096 # block size
     12    hop_s = block_size
    1313
    1414    allsamples_max = zeros(0,)
    15     downsample = 2**3  # to plot n samples / hop_s
     15    downsample = 2**4  # to plot n samples / hop_s
    1616
    1717    a = source(filename, samplerate, hop_s)            # source file
     
    2626        total_frames += read
    2727        if read < hop_s: break
    28     print samples.reshape(hop_s/downsample, downsample).shape
    29 
    3028    allsamples_max = (allsamples_max > 0) * allsamples_max
    3129    allsamples_max_times = [ ( float (t) / downsample ) * hop_s for t in range(len(allsamples_max)) ]
     
    3533    ax.axis(xmin = allsamples_max_times[0], xmax = allsamples_max_times[-1])
    3634
    37     if allsamples_max_times[-1] / float(samplerate) > 60:
     35    set_xlabels_sample2time(ax, allsamples_max_times[-1], samplerate)
     36    return ax
     37
     38def set_xlabels_sample2time(ax, latest_sample, samplerate):
     39    ax.axis(xmin = 0, xmax = latest_sample)
     40    if latest_sample / float(samplerate) > 60:
    3841        ax.set_xlabel('time (mm:ss)')
    3942        ax.set_xticklabels([ "%02d:%02d" % (t/float(samplerate)/60, (t/float(samplerate))%60) for t in ax.get_xticks()[:-1]], rotation = 50)
     
    4144        ax.set_xlabel('time (ss.mm)')
    4245        ax.set_xticklabels([ "%02d.%02d" % (t/float(samplerate), 100*((t/float(samplerate))%1) ) for t in ax.get_xticks()[:-1]], rotation = 50)
     46
     47
    4348if __name__ == '__main__':
    4449    import matplotlib.pyplot as plt
  • python/ext/aubio-types.h

    reaaba62 rbd1fa89  
    1 #include "Python.h"
     1#include <Python.h>
    22#include <structmember.h>
    33
  • python/lib/aubio/__init__.py

    reaaba62 rbd1fa89  
     1#! /usr/bin/env python
     2
    13import numpy
    24from _aubio import *
     
    46
    57class fvec(numpy.ndarray):
    6 
     8    " a simple numpy array holding a vector of float32 "
    79    def __new__(self, length = 1024, **kwargs):
     10        self.length = length
    811        if type(length) == type([]):
    912            return numpy.array(length, dtype='float32', **kwargs)
  • python/tests/test_phasevoc.py

    reaaba62 rbd1fa89  
    88class aubio_pvoc_test_case(TestCase):
    99
    10   def test_members(self):
     10  def test_members_automatic_sizes_default(self):
    1111    f = pvoc()
    1212    assert_equal ([f.win_s, f.hop_s], [1024, 512])
     13
     14  def test_members_automatic_sizes_not_null(self):
    1315    f = pvoc(2048, 128)
    1416    assert_equal ([f.win_s, f.hop_s], [2048, 128])
  • python/tests/test_source.py

    reaaba62 rbd1fa89  
    5555    def test_wrong_hop_size(self):
    5656        for p in list_of_sounds:
    57             f = source(p, 0, -1)
    58             print f.hop_size
     57            try:
     58                f = source(p, 0, -1)
     59            except Exception, e:
     60                print e
     61            else:
     62                self.fail('does not fail with wrong hop_size %d' % f.hop_size)
    5963
    6064    def test_zero_hop_size(self):
  • src/io/source.h

    reaaba62 rbd1fa89  
    2626  Media source to read blocks of consecutive audio samples from file
    2727
     28  To write to file, use ::aubio_sink_t.
     29
    2830  \example io/test-source.c
     31  \example io/test-source_multi.c
    2932
    3033*/
  • src/io/source_apple_audio.c

    reaaba62 rbd1fa89  
    5252extern CFURLRef getURLFromPath(const char * path);
    5353
     54uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, char_t * path);
     55
    5456aubio_source_apple_audio_t * new_aubio_source_apple_audio(char_t * path, uint_t samplerate, uint_t block_size)
    5557{
    5658  aubio_source_apple_audio_t * s = AUBIO_NEW(aubio_source_apple_audio_t);
    5759
    58   s->path = path;
    5960  s->block_size = block_size;
    60 
     61  s->samplerate = samplerate;
     62
     63  if ( aubio_source_apple_audio_open ( s, path ) ) {
     64    goto beach;
     65  }
     66  return s;
     67
     68beach:
     69  AUBIO_FREE(s);
     70  return NULL;
     71}
     72
     73uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, char_t * path)
     74{
    6175  OSStatus err = noErr;
    6276  UInt32 propSize;
     77  s->path = path;
    6378
    6479  // open the resource url
     
    7792  if (err) { AUBIO_ERROR("error in ExtAudioFileGetProperty, %d\n", (int)err); goto beach;}
    7893
    79   if (samplerate == 0) {
    80     samplerate = fileFormat.mSampleRate;
     94  if (s->samplerate == 0) {
     95    s->samplerate = fileFormat.mSampleRate;
    8196    //AUBIO_DBG("sampling rate set to 0, automagically adjusting to %d\n", samplerate);
    8297  }
    83   s->samplerate = samplerate;
     98
    8499  s->source_samplerate = fileFormat.mSampleRate;
    85100  s->channels = fileFormat.mChannelsPerFrame;
     
    124139
    125140  // compute the size of the segments needed to read the input file
    126   UInt32 samples = s->block_size * clientFormat.mChannelsPerFrame;
    127   Float64 rateRatio = clientFormat.mSampleRate / fileFormat.mSampleRate;
     141  UInt32 samples = s->block_size * s->channels;
     142  Float64 rateRatio = s->samplerate / s->source_samplerate;
    128143  uint_t segmentSize= (uint_t)(samples * rateRatio + .5);
    129144  if (rateRatio < 1.) {
    130145    segmentSize = (uint_t)(samples / rateRatio + .5);
    131146  } else if (rateRatio > 1.) {
    132     AUBIO_WRN("up-sampling %s from %0.2fHz to %0.2fHz\n", s->path, fileFormat.mSampleRate, clientFormat.mSampleRate);
     147    AUBIO_WRN("up-sampling %s from %0dHz to %0dHz\n", s->path, s->source_samplerate, s->samplerate);
    133148  } else {
    134149    assert ( segmentSize == samples );
     
    137152
    138153  // allocate the AudioBufferList
    139   if (createAubioBufferList(&s->bufferList, s->channels, segmentSize)) err = -1;
    140 
    141   return s;
    142  
    143 beach:
    144   AUBIO_FREE(s);
    145   return NULL;
     154  if (createAubioBufferList(&s->bufferList, s->channels, segmentSize)) {
     155    AUBIO_ERR("source_apple_audio: failed creating bufferList\n");
     156    goto beach;
     157  }
     158
     159beach:
     160  return err;
    146161}
    147162
     
    205220}
    206221
    207 void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){
     222uint_t aubio_source_apple_audio_close (aubio_source_apple_audio_t *s)
     223{
    208224  OSStatus err = noErr;
    209   if (!s || !s->audioFile) { return; }
     225  if (!s || !s->audioFile) { return 1; }
    210226  err = ExtAudioFileDispose(s->audioFile);
    211227  if (err) AUBIO_ERROR("error in ExtAudioFileDispose, %d\n", (int)err);
    212228  s->audioFile = NULL;
     229  return err;
     230}
     231
     232void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){
     233  aubio_source_apple_audio_close (s);
    213234  freeAudioBufferList(&s->bufferList);
    214235  AUBIO_FREE(s);
     
    217238
    218239uint_t aubio_source_apple_audio_seek (aubio_source_apple_audio_t * s, uint_t pos) {
     240  if (1) {
     241    AudioBufferList *bufferList = &s->bufferList;
     242    UInt32 samples = s->block_size * s->channels;
     243    Float64 rateRatio = s->samplerate / s->source_samplerate;
     244    uint_t segmentSize= (uint_t)(samples * rateRatio + .5);
     245    bufferList->mBuffers[0].mDataByteSize = segmentSize * sizeof(short);
     246  }
    219247  SInt64 resampled_pos = (SInt64)ROUND( pos * s->source_samplerate * 1. / s->samplerate );
    220248  OSStatus err = ExtAudioFileSeek(s->audioFile, resampled_pos);
  • src/io/utils_apple_audio.c

    reaaba62 rbd1fa89  
    55// ExtAudioFileRef, AudioStreamBasicDescription, AudioBufferList, ...
    66#include <AudioToolbox/AudioToolbox.h>
     7#include "aubio_priv.h"
    78
    89int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize);
     
    1314  bufferList->mNumberBuffers = 1;
    1415  bufferList->mBuffers[0].mNumberChannels = channels;
    15   bufferList->mBuffers[0].mData = (short *)malloc(segmentSize * sizeof(short));
     16  bufferList->mBuffers[0].mData = AUBIO_ARRAY(short, segmentSize);
    1617  bufferList->mBuffers[0].mDataByteSize = segmentSize * sizeof(short);
    1718  return 0;
     
    2324  for (i = 0; i < bufferList->mNumberBuffers; i++) {
    2425    if (bufferList->mBuffers[i].mData) {
    25       free (bufferList->mBuffers[i].mData);
     26      AUBIO_FREE(bufferList->mBuffers[i].mData);
    2627      bufferList->mBuffers[i].mData = NULL;
    2728    }
  • src/pitch/pitchyinfft.h

    reaaba62 rbd1fa89  
    2828  function is tapered, the selection of the period is simplified.
    2929 
    30   Paul Brossier, ``Automatic annotation of musical audio for interactive
    31   systems'', Chapter 3, Pitch Analysis, PhD thesis, Centre for Digital music,
    32   Queen Mary University of London, London, UK, 2006.
     30  Paul Brossier, [Automatic annotation of musical audio for interactive
     31  systems](http://aubio.org/phd/), Chapter 3, Pitch Analysis, PhD thesis,
     32  Centre for Digital music, Queen Mary University of London, London, UK, 2006.
    3333
    3434  \example pitch/test-pitchyinfft.c
  • src/tempo/tempo.h

    reaaba62 rbd1fa89  
    1919*/
    2020
    21 /** \file 
    22  
     21/** \file
     22
    2323  Tempo detection object
    2424
     
    4040typedef struct _aubio_tempo_t aubio_tempo_t;
    4141
    42 /** create tempo detection object */
    43 aubio_tempo_t * new_aubio_tempo (char_t * method,
     42/** create tempo detection object
     43
     44  \param buf_size length of FFT
     45  \param hop_size number of frames between two consecutive runs
     46  \param samplerate sampling rate of the signal to analyze
     47
     48  \return newly created ::aubio_tempo_t if successful, `NULL` otherwise
     49
     50*/
     51aubio_tempo_t * new_aubio_tempo (char_t * method,
    4452    uint_t buf_size, uint_t hop_size, uint_t samplerate);
    4553
    46 /** execute tempo detection */
     54/** execute tempo detection
     55
     56  \param o beat tracking object
     57  \param input new samples
     58  \param tempo output beats
     59
     60*/
    4761void aubio_tempo_do (aubio_tempo_t *o, fvec_t * input, fvec_t * tempo);
    4862
    49 /** set tempo detection silence threshold  */
     63/** set tempo detection silence threshold
     64
     65  \param o beat tracking object
     66  \param threshold new silence threshold, in dB
     67
     68  \return `0` if successful, non-zero otherwise
     69
     70*/
    5071uint_t aubio_tempo_set_silence(aubio_tempo_t * o, smpl_t silence);
    5172
    52 /** set tempo detection peak picking threshold  */
     73/** set tempo detection peak picking threshold
     74
     75  \param o beat tracking object
     76  \param threshold new threshold
     77
     78  \return `0` if successful, non-zero otherwise
     79
     80*/
    5381uint_t aubio_tempo_set_threshold(aubio_tempo_t * o, smpl_t threshold);
    5482
    5583/** get current tempo
    5684
    57   \param bt beat tracking object
     85  \param o beat tracking object
    5886
    59   Returns the currently observed tempo, or 0 if no consistent value is found
     87  \return the currently observed tempo, or `0` if no consistent value is found
    6088
    6189*/
    62 smpl_t aubio_tempo_get_bpm(aubio_tempo_t * bt);
     90smpl_t aubio_tempo_get_bpm(aubio_tempo_t * o);
    6391
    6492/** get current tempo confidence
    6593
    66   \param bt beat tracking object
     94  \param o beat tracking object
    6795
    68   Returns the confidence with which the tempo has been observed, 0 if no
     96  \return confidence with which the tempo has been observed, `0` if no
    6997  consistent value is found.
    7098
    7199*/
    72 smpl_t aubio_tempo_get_confidence(aubio_tempo_t * bt);
     100smpl_t aubio_tempo_get_confidence(aubio_tempo_t * o);
    73101
    74 /** delete tempo detection object */
     102/** delete tempo detection object
     103
     104  \param o beat tracking object
     105
     106*/
    75107void del_aubio_tempo(aubio_tempo_t * o);
    76108
  • tests/src/io/test-source_multi.c

    reaaba62 rbd1fa89  
    4444    n_frames / hop_size, source_path);
    4545
     46  del_fmat (mat);
    4647  del_aubio_source (s);
    4748beach:
    48   del_fmat (mat);
    4949
    5050  return err;
Note: See TracChangeset for help on using the changeset viewer.