Changes in / [eaaba62:bd1fa89]
- Files:
-
- 15 added
- 11 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/web.cfg
reaaba62 rbd1fa89 715 715 ../src/pitch/pitchfcomb.h \ 716 716 ../src/tempo/beattracking.h \ 717 ../src/utils/hist.h \ 717 718 ../src/utils/scale.h \ 718 719 ../src/utils.h -
python/demos/demo_specdesc.py
reaaba62 rbd1fa89 22 22 pv = pvoc(win_s, hop_s) 23 23 24 methods = ['default', 'energy', 'hfc', 'complex', 'phase', 'specdiff', 'kl', 'mkl',25 'specflux', 'centroid', 'spread', 'skewness', 'kurtosis', 'slope', 'decrease',26 'rolloff',]24 methods = ['default', 'energy', 'hfc', 'complex', 'phase', 'specdiff', 'kl', 25 'mkl', 'specflux', 'centroid', 'slope', 'rolloff', 'spread', 'skewness', 26 'kurtosis', 'decrease',] 27 27 28 28 all_descs = {} … … 40 40 samples, read = s() 41 41 fftgrain = pv(samples) 42 print "%f" % ( total_frames / float(samplerate) ),42 #print "%f" % ( total_frames / float(samplerate) ), 43 43 for method in methods: 44 44 specdesc_val = o[method](fftgrain)[0] 45 45 all_descs[method] = hstack ( [all_descs[method], specdesc_val] ) 46 print "%f" % specdesc_val,47 print46 #print "%f" % specdesc_val, 47 #print 48 48 total_frames += read 49 49 if read < hop_s: break … … 53 53 import matplotlib.pyplot as plt 54 54 from demo_waveform_plot import get_waveform_plot 55 from demo_waveform_plot import set_xlabels_sample2time 55 56 fig = plt.figure() 56 57 plt.rc('lines',linewidth='.8') 57 58 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 ) 59 60 wave.yaxis.set_visible(False) 60 61 wave.xaxis.set_visible(False) … … 74 75 horizontalalignment='right', verticalalignment='bottom', 75 76 ) 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) 82 78 #plt.ylabel('spectral descriptor value') 83 79 ax.xaxis.set_visible(True) -
python/demos/demo_waveform_plot.py
reaaba62 rbd1fa89 5 5 from numpy import zeros, hstack 6 6 7 def get_waveform_plot(filename, samplerate = 0, ax = None):7 def get_waveform_plot(filename, samplerate = 0, block_size = 4096, ax = None): 8 8 import matplotlib.pyplot as plt 9 9 if not ax: 10 10 fig = plt.figure() 11 11 ax = fig.add_subplot(111) 12 hop_s = 4096 # blocksize12 hop_s = block_size 13 13 14 14 allsamples_max = zeros(0,) 15 downsample = 2** 3# to plot n samples / hop_s15 downsample = 2**4 # to plot n samples / hop_s 16 16 17 17 a = source(filename, samplerate, hop_s) # source file … … 26 26 total_frames += read 27 27 if read < hop_s: break 28 print samples.reshape(hop_s/downsample, downsample).shape29 30 28 allsamples_max = (allsamples_max > 0) * allsamples_max 31 29 allsamples_max_times = [ ( float (t) / downsample ) * hop_s for t in range(len(allsamples_max)) ] … … 35 33 ax.axis(xmin = allsamples_max_times[0], xmax = allsamples_max_times[-1]) 36 34 37 if allsamples_max_times[-1] / float(samplerate) > 60: 35 set_xlabels_sample2time(ax, allsamples_max_times[-1], samplerate) 36 return ax 37 38 def set_xlabels_sample2time(ax, latest_sample, samplerate): 39 ax.axis(xmin = 0, xmax = latest_sample) 40 if latest_sample / float(samplerate) > 60: 38 41 ax.set_xlabel('time (mm:ss)') 39 42 ax.set_xticklabels([ "%02d:%02d" % (t/float(samplerate)/60, (t/float(samplerate))%60) for t in ax.get_xticks()[:-1]], rotation = 50) … … 41 44 ax.set_xlabel('time (ss.mm)') 42 45 ax.set_xticklabels([ "%02d.%02d" % (t/float(samplerate), 100*((t/float(samplerate))%1) ) for t in ax.get_xticks()[:-1]], rotation = 50) 46 47 43 48 if __name__ == '__main__': 44 49 import matplotlib.pyplot as plt -
python/ext/aubio-types.h
reaaba62 rbd1fa89 1 #include "Python.h"1 #include <Python.h> 2 2 #include <structmember.h> 3 3 -
python/lib/aubio/__init__.py
reaaba62 rbd1fa89 1 #! /usr/bin/env python 2 1 3 import numpy 2 4 from _aubio import * … … 4 6 5 7 class fvec(numpy.ndarray): 6 8 " a simple numpy array holding a vector of float32 " 7 9 def __new__(self, length = 1024, **kwargs): 10 self.length = length 8 11 if type(length) == type([]): 9 12 return numpy.array(length, dtype='float32', **kwargs) -
python/tests/test_phasevoc.py
reaaba62 rbd1fa89 8 8 class aubio_pvoc_test_case(TestCase): 9 9 10 def test_members (self):10 def test_members_automatic_sizes_default(self): 11 11 f = pvoc() 12 12 assert_equal ([f.win_s, f.hop_s], [1024, 512]) 13 14 def test_members_automatic_sizes_not_null(self): 13 15 f = pvoc(2048, 128) 14 16 assert_equal ([f.win_s, f.hop_s], [2048, 128]) -
python/tests/test_source.py
reaaba62 rbd1fa89 55 55 def test_wrong_hop_size(self): 56 56 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) 59 63 60 64 def test_zero_hop_size(self): -
src/io/source.h
reaaba62 rbd1fa89 26 26 Media source to read blocks of consecutive audio samples from file 27 27 28 To write to file, use ::aubio_sink_t. 29 28 30 \example io/test-source.c 31 \example io/test-source_multi.c 29 32 30 33 */ -
src/io/source_apple_audio.c
reaaba62 rbd1fa89 52 52 extern CFURLRef getURLFromPath(const char * path); 53 53 54 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, char_t * path); 55 54 56 aubio_source_apple_audio_t * new_aubio_source_apple_audio(char_t * path, uint_t samplerate, uint_t block_size) 55 57 { 56 58 aubio_source_apple_audio_t * s = AUBIO_NEW(aubio_source_apple_audio_t); 57 59 58 s->path = path;59 60 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 68 beach: 69 AUBIO_FREE(s); 70 return NULL; 71 } 72 73 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, char_t * path) 74 { 61 75 OSStatus err = noErr; 62 76 UInt32 propSize; 77 s->path = path; 63 78 64 79 // open the resource url … … 77 92 if (err) { AUBIO_ERROR("error in ExtAudioFileGetProperty, %d\n", (int)err); goto beach;} 78 93 79 if (s amplerate == 0) {80 s amplerate = fileFormat.mSampleRate;94 if (s->samplerate == 0) { 95 s->samplerate = fileFormat.mSampleRate; 81 96 //AUBIO_DBG("sampling rate set to 0, automagically adjusting to %d\n", samplerate); 82 97 } 83 s->samplerate = samplerate; 98 84 99 s->source_samplerate = fileFormat.mSampleRate; 85 100 s->channels = fileFormat.mChannelsPerFrame; … … 124 139 125 140 // 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; 128 143 uint_t segmentSize= (uint_t)(samples * rateRatio + .5); 129 144 if (rateRatio < 1.) { 130 145 segmentSize = (uint_t)(samples / rateRatio + .5); 131 146 } 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); 133 148 } else { 134 149 assert ( segmentSize == samples ); … … 137 152 138 153 // 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 159 beach: 160 return err; 146 161 } 147 162 … … 205 220 } 206 221 207 void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){ 222 uint_t aubio_source_apple_audio_close (aubio_source_apple_audio_t *s) 223 { 208 224 OSStatus err = noErr; 209 if (!s || !s->audioFile) { return ; }225 if (!s || !s->audioFile) { return 1; } 210 226 err = ExtAudioFileDispose(s->audioFile); 211 227 if (err) AUBIO_ERROR("error in ExtAudioFileDispose, %d\n", (int)err); 212 228 s->audioFile = NULL; 229 return err; 230 } 231 232 void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){ 233 aubio_source_apple_audio_close (s); 213 234 freeAudioBufferList(&s->bufferList); 214 235 AUBIO_FREE(s); … … 217 238 218 239 uint_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 } 219 247 SInt64 resampled_pos = (SInt64)ROUND( pos * s->source_samplerate * 1. / s->samplerate ); 220 248 OSStatus err = ExtAudioFileSeek(s->audioFile, resampled_pos); -
src/io/utils_apple_audio.c
reaaba62 rbd1fa89 5 5 // ExtAudioFileRef, AudioStreamBasicDescription, AudioBufferList, ... 6 6 #include <AudioToolbox/AudioToolbox.h> 7 #include "aubio_priv.h" 7 8 8 9 int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize); … … 13 14 bufferList->mNumberBuffers = 1; 14 15 bufferList->mBuffers[0].mNumberChannels = channels; 15 bufferList->mBuffers[0].mData = (short *)malloc(segmentSize * sizeof(short));16 bufferList->mBuffers[0].mData = AUBIO_ARRAY(short, segmentSize); 16 17 bufferList->mBuffers[0].mDataByteSize = segmentSize * sizeof(short); 17 18 return 0; … … 23 24 for (i = 0; i < bufferList->mNumberBuffers; i++) { 24 25 if (bufferList->mBuffers[i].mData) { 25 free(bufferList->mBuffers[i].mData);26 AUBIO_FREE(bufferList->mBuffers[i].mData); 26 27 bufferList->mBuffers[i].mData = NULL; 27 28 } -
src/pitch/pitchyinfft.h
reaaba62 rbd1fa89 28 28 function is tapered, the selection of the period is simplified. 29 29 30 Paul Brossier, ``Automatic annotation of musical audio for interactive31 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. 33 33 34 34 \example pitch/test-pitchyinfft.c -
src/tempo/tempo.h
reaaba62 rbd1fa89 19 19 */ 20 20 21 /** \file 22 21 /** \file 22 23 23 Tempo detection object 24 24 … … 40 40 typedef struct _aubio_tempo_t aubio_tempo_t; 41 41 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 */ 51 aubio_tempo_t * new_aubio_tempo (char_t * method, 44 52 uint_t buf_size, uint_t hop_size, uint_t samplerate); 45 53 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 */ 47 61 void aubio_tempo_do (aubio_tempo_t *o, fvec_t * input, fvec_t * tempo); 48 62 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 */ 50 71 uint_t aubio_tempo_set_silence(aubio_tempo_t * o, smpl_t silence); 51 72 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 */ 53 81 uint_t aubio_tempo_set_threshold(aubio_tempo_t * o, smpl_t threshold); 54 82 55 83 /** get current tempo 56 84 57 \param btbeat tracking object85 \param o beat tracking object 58 86 59 Returns the currently observed tempo, or 0if no consistent value is found87 \return the currently observed tempo, or `0` if no consistent value is found 60 88 61 89 */ 62 smpl_t aubio_tempo_get_bpm(aubio_tempo_t * bt);90 smpl_t aubio_tempo_get_bpm(aubio_tempo_t * o); 63 91 64 92 /** get current tempo confidence 65 93 66 \param btbeat tracking object94 \param o beat tracking object 67 95 68 Returns the confidence with which the tempo has been observed, 0if no96 \return confidence with which the tempo has been observed, `0` if no 69 97 consistent value is found. 70 98 71 99 */ 72 smpl_t aubio_tempo_get_confidence(aubio_tempo_t * bt);100 smpl_t aubio_tempo_get_confidence(aubio_tempo_t * o); 73 101 74 /** delete tempo detection object */ 102 /** delete tempo detection object 103 104 \param o beat tracking object 105 106 */ 75 107 void del_aubio_tempo(aubio_tempo_t * o); 76 108 -
tests/src/io/test-source_multi.c
reaaba62 rbd1fa89 44 44 n_frames / hop_size, source_path); 45 45 46 del_fmat (mat); 46 47 del_aubio_source (s); 47 48 beach: 48 del_fmat (mat);49 49 50 50 return err;
Note: See TracChangeset
for help on using the changeset viewer.