aubio  0.4.9
Functions
musicutils.h File Reference

various functions useful in audio signal processing More...

Go to the source code of this file.

Functions

fvec_tnew_aubio_window (char_t *window_type, uint_t size)
 create window More...
 
uint_t fvec_set_window (fvec_t *window, char_t *window_type)
 set elements of a vector to window coefficients More...
 
smpl_t aubio_unwrap2pi (smpl_t phase)
 compute the principal argument More...
 
smpl_t aubio_bintomidi (smpl_t bin, smpl_t samplerate, smpl_t fftsize)
 convert frequency bin to midi value
 
smpl_t aubio_miditobin (smpl_t midi, smpl_t samplerate, smpl_t fftsize)
 convert midi value to frequency bin
 
smpl_t aubio_bintofreq (smpl_t bin, smpl_t samplerate, smpl_t fftsize)
 convert frequency bin to frequency (Hz)
 
smpl_t aubio_freqtobin (smpl_t freq, smpl_t samplerate, smpl_t fftsize)
 convert frequency (Hz) to frequency bin
 
smpl_t aubio_hztomel (smpl_t freq)
 convert frequency (Hz) to mel More...
 
smpl_t aubio_meltohz (smpl_t mel)
 convert mel to frequency (Hz) More...
 
smpl_t aubio_hztomel_htk (smpl_t freq)
 convert frequency (Hz) to mel More...
 
smpl_t aubio_meltohz_htk (smpl_t mel)
 convert mel to frequency (Hz) More...
 
smpl_t aubio_freqtomidi (smpl_t freq)
 convert frequency (Hz) to midi value (0-128)
 
smpl_t aubio_miditofreq (smpl_t midi)
 convert midi value (0-128) to frequency (Hz)
 
void aubio_cleanup (void)
 clean up cached memory at the end of program More...
 
smpl_t aubio_zero_crossing_rate (fvec_t *v)
 zero-crossing rate (ZCR) More...
 
smpl_t aubio_level_lin (const fvec_t *v)
 compute sound level on a linear scale More...
 
smpl_t aubio_db_spl (const fvec_t *v)
 compute sound pressure level (SPL) in dB More...
 
uint_t aubio_silence_detection (const fvec_t *v, smpl_t threshold)
 check if buffer level in dB SPL is under a given threshold More...
 
smpl_t aubio_level_detection (const fvec_t *v, smpl_t threshold)
 get buffer level if level >= threshold, 1. More...
 
void fvec_clamp (fvec_t *in, smpl_t absmax)
 clamp the values of a vector within the range [-abs(max), abs(max)] More...
 

Detailed Description

various functions useful in audio signal processing

Definition in file musicutils.h.

Function Documentation

◆ aubio_cleanup()

void aubio_cleanup ( void  )

clean up cached memory at the end of program

This function should be used at the end of programs to purge all cached memory. So far it is only useful to clean FFTW's cache.

Examples:
onset/test-onset.c, pitch/test-pitch.c, spectral/test-fft.c, spectral/test-filterbank.c, spectral/test-filterbank_mel.c, spectral/test-mfcc.c, spectral/test-phasevoc.c, spectral/test-specdesc.c, spectral/test-tss.c, synth/test-sampler.c, synth/test-wavetable.c, tempo/test-tempo.c, and temporal/test-filter.c.

◆ aubio_db_spl()

smpl_t aubio_db_spl ( const fvec_t v)

compute sound pressure level (SPL) in dB

This quantity is often wrongly called 'loudness'.

This gives ten times the log10 of the average of the square amplitudes.

Parameters
vvector to compute dB SPL from
Returns
level of v in dB SPL

◆ aubio_hztomel()

smpl_t aubio_hztomel ( smpl_t  freq)

convert frequency (Hz) to mel

Parameters
freqinput frequency, in Hz
Returns
output mel

Converts a scalar from the frequency domain to the mel scale using Slaney Auditory Toolbox's implementation:

If \( f < 1000 \), \( m = 3 f / 200 \).

If \( f >= 1000 \), \( m = 1000 + 27 \frac{{ln}(f) - ln(1000))} {{ln}(6400) - ln(1000)} \)

See also

aubio_meltohz(), aubio_hztomel_htk().

◆ aubio_hztomel_htk()

smpl_t aubio_hztomel_htk ( smpl_t  freq)

convert frequency (Hz) to mel

Parameters
freqinput frequency, in Hz
Returns
output mel

Converts a scalar from the frequency domain to the mel scale, using the equation defined by O'Shaughnessy, as implemented in the HTK speech recognition toolkit:

\( m = 1127 + ln(1 + \frac{f}{700}) \)

See also

aubio_meltohz_htk(), aubio_hztomel().

References

Douglas O'Shaughnessy (1987). Speech communication: human and machine. Addison-Wesley. p. 150. ISBN 978-0-201-16520-3.

HTK Speech Recognition Toolkit: http://htk.eng.cam.ac.uk/

◆ aubio_level_detection()

smpl_t aubio_level_detection ( const fvec_t v,
smpl_t  threshold 
)

get buffer level if level >= threshold, 1.

otherwise

Parameters
vvector to get level from
thresholdthreshold in dB SPL
Returns
level in dB SPL if level >= threshold, 1. otherwise

◆ aubio_level_lin()

smpl_t aubio_level_lin ( const fvec_t v)

compute sound level on a linear scale

This gives the average of the square amplitudes.

Parameters
vvector to compute level from
Returns
level of v
Examples:
examples/aubiopitch.c.

◆ aubio_meltohz()

smpl_t aubio_meltohz ( smpl_t  mel)

convert mel to frequency (Hz)

Parameters
melinput mel
Returns
output frequency, in Hz

Converts a scalar from the mel scale to the frequency domain using Slaney Auditory Toolbox's implementation:

If \( f < 1000 \), \( f = 200 m/3 \).

If \( f \geq 1000 \), \( f = 1000 + \left(\frac{6400}{1000}\right) ^{\frac{m - 1000}{27}} \)

See also

aubio_hztomel(), aubio_meltohz_htk().

References

Malcolm Slaney, Auditory Toolbox Version 2, Technical Report #1998-010 https://engineering.purdue.edu/~malcolm/interval/1998-010/

◆ aubio_meltohz_htk()

smpl_t aubio_meltohz_htk ( smpl_t  mel)

convert mel to frequency (Hz)

Parameters
melinput mel
Returns
output frequency, in Hz

Converts a scalar from the mel scale to the frequency domain, using the equation defined by O'Shaughnessy, as implemented in the HTK speech recognition toolkit:

\( f = 700 * {e}^\left(\frac{f}{1127} - 1\right) \)

See also

aubio_hztomel_htk(), aubio_meltohz().

◆ aubio_silence_detection()

uint_t aubio_silence_detection ( const fvec_t v,
smpl_t  threshold 
)

check if buffer level in dB SPL is under a given threshold

Parameters
vvector to get level from
thresholdthreshold in dB SPL
Returns
0 if level is under the given threshold, 1 otherwise
Examples:
examples/aubiotrack.c.

◆ aubio_unwrap2pi()

smpl_t aubio_unwrap2pi ( smpl_t  phase)

compute the principal argument

This function maps the input phase to its corresponding value wrapped in the range \( [-\pi, \pi] \).

Parameters
phaseunwrapped phase to map to the unit circle
Returns
equivalent phase wrapped to the unit circle

◆ aubio_zero_crossing_rate()

smpl_t aubio_zero_crossing_rate ( fvec_t v)

zero-crossing rate (ZCR)

The zero-crossing rate is the number of times a signal changes sign, divided by the length of this signal.

Parameters
vvector to compute ZCR from
Returns
zero-crossing rate of v

◆ fvec_clamp()

void fvec_clamp ( fvec_t in,
smpl_t  absmax 
)

clamp the values of a vector within the range [-abs(max), abs(max)]

Parameters
invector to clamp
absmaxmaximum value over which input vector elements should be clamped

◆ fvec_set_window()

uint_t fvec_set_window ( fvec_t window,
char_t window_type 
)

set elements of a vector to window coefficients

Parameters
windowexsting fvec_t to use
window_typetype of the window to create

List of available window types: "rectangle", "hamming", "hanning", "hanningz", "blackman", "blackman_harris", "gaussian", "welch", "parzen", "default".

"default" is equivalent to "hanningz".

References:

  • Window function on Wikipedia
  • Amalia de Götzen, Nicolas Bernardini, and Daniel Arfib. Traditional (?) implementations of a phase vocoder: the tricks of the trade. In Proceedings of the International Conference on Digital Audio Effects (DAFx-00), pages 37–44, Uni- versity of Verona, Italy, 2000. (pdf)

◆ new_aubio_window()

fvec_t* new_aubio_window ( char_t window_type,
uint_t  size 
)

create window

Parameters
window_typetype of the window to create
sizelength of the window to create (see fvec_set_window())