|
Roughometer
0.2
|
#include <stdio.h>#include <stdlib.h>#include <math.h>#include "m_pd.h"
Data Structures | |
| struct | _roughometer |
| struct | proxy |
Macros | |
| #define | MAX_INSTRUMENTS 20 |
| Max. number of streams. More... | |
| #define | MAX_PARTIALS 20 |
| Max. number of spectra components. More... | |
| #define | SCALE_CONSTANT 100 |
| A scale constant to express the roughness in manageable values. More... | |
| #define | DEFAULT_THRESHOLD 0.001 |
| Default amplitude threshold for incoming streams. More... | |
| #define | min(a, b) |
| Returns the minimum of the two arguments. More... | |
| #define | max(a, b) |
| Returns the maximum of the two arguments. More... | |
Typedefs | |
| typedef struct _roughometer | t_roughometer |
| typedef struct proxy | t_proxy |
| Auxiliary structure to allow dynamic number of inlets. More... | |
Functions | |
| t_float | S (t_float f) |
| Calculate S. More... | |
| t_float | dissonance (t_roughometer *x, t_float a1, t_float a2, t_float f1, t_float f2) |
| Calculates auditory roughness of a dyad using the model proposed by Vassilakis. More... | |
| t_float | d_Calculation (t_roughometer *x) |
| Calculates the complex roughness of the ensemble. More... | |
| void | roughometer_initMatrix (t_roughometer *x) |
| Initializes the frequency and amplitude matrices as well as the solution, partial solution, and last pitch vector. More... | |
| void | setCounters (t_roughometer *x, t_int value) |
| Sets the counters of processed income to the value indicated by the parameter 'value. More... | |
| void | roughometer_bang (t_roughometer *x) |
| Process a request for roughness calculation. More... | |
| void | roughometer_setOffset (t_roughometer *x, t_floatarg f) |
| Sets the minimum amplitude value to be considered for the Roughness calculation. More... | |
| t_int | areAllComponentsIn (t_roughometer *x) |
| Counts how many streams have been completed (in terms of the number of partials analyzed). More... | |
| static void | roughometer_value (t_proxy *p, t_symbol *s, int argc, t_atom *argv) |
| Update the frequency and amplitude values for each instrument. More... | |
| void * | roughometer_new (t_floatarg n) |
| Instantiate the object. More... | |
| void | roughometer_setup (void) |
| setup the object More... | |
Variables | |
| static t_class * | roughometer_class |
| static t_class * | proxy_class |
| #define DEFAULT_THRESHOLD 0.001 |
Default amplitude threshold for incoming streams.
| #define max | ( | a, | |
| b | |||
| ) |
Returns the maximum of the two arguments.
| #define MAX_INSTRUMENTS 20 |
Max. number of streams.
| #define MAX_PARTIALS 20 |
Max. number of spectra components.
| #define min | ( | a, | |
| b | |||
| ) |
Returns the minimum of the two arguments.
| #define SCALE_CONSTANT 100 |
A scale constant to express the roughness in manageable values.
| typedef struct _roughometer t_roughometer |
| t_int areAllComponentsIn | ( | t_roughometer * | x | ) |
Counts how many streams have been completed (in terms of the number of partials analyzed).
and returns 0 or 1 if there are some incomplete or not respectevly.
| x | a pointer to the inner structure of the object |
not all the components have been written
they're all in.
| t_float d_Calculation | ( | t_roughometer * | x | ) |
Calculates the complex roughness of the ensemble.
One difference between the model proposed by Vassilakis is that only the dissonance produced by components belonging to different signals count. In other words, the intrinsic dissonance is not considered because it is wanted to preserve the timbre of the signal. Also, by doing it the number of iterations is reduced. This function is the kernel of the minimization, since it takes the current values of the vicinity in cents for the stream where an onset was detected and calculates
where
are the number of streams, number of partials,
if
onsetting stream, or
otherwise
| x | A pointer to the inner structure of the object. |
| t_float dissonance | ( | t_roughometer * | x, |
| t_float | a1, | ||
| t_float | a2, | ||
| t_float | f1, | ||
| t_float | f2 | ||
| ) |
Calculates auditory roughness of a dyad using the model proposed by Vassilakis.
Vassilakis models assumes that for a dyad
and
,
. There's an error in his thesis about this (p. 197). The SRA model is better.
See also Sethares' "Adaptive tunings for musical scales."
This method calculates
where
Components with frequencies beyond the default boundaries (amp <=threshold, 20Hz < f < 20kHz) don't contribute in the result.
| *x | A pointer to the data structure of the class |
| a1 | The amplitude of the first spectral component |
| a2 | The amplitude of the second spectral component |
| f1 | The frequency of the first spectral component |
| f2 | The frequency of the second spectral component |
| void roughometer_bang | ( | t_roughometer * | x | ) |
Process a request for roughness calculation.
| x | A pointer to the inner structure of the object |
< set the flag to read the components
< reset the counters
| void roughometer_initMatrix | ( | t_roughometer * | x | ) |
Initializes the frequency and amplitude matrices as well as the solution, partial solution, and last pitch vector.
| x | A pointer to the inner structure of the object |
| void* roughometer_new | ( | t_floatarg | n | ) |
Instantiate the object.
| n | number of spectra |
| c | vicinity in cents |
| void roughometer_setOffset | ( | t_roughometer * | x, |
| t_floatarg | f | ||
| ) |
Sets the minimum amplitude value to be considered for the Roughness calculation.
When working with soundfiles or captured audio, there is a noise that can distort the roughness calculation. This can be compensated by adjusting the threshold.
| x | a pointer to the inner structure of the object |
| f | the new threshold in part per thousand |
| void roughometer_setup | ( | void | ) |
setup the object
|
static |
Update the frequency and amplitude values for each instrument.
The list of arguments consists of the following elements: inlet_id, partial_id, frequency, amplitude, cos, sin or inlet_id, partial_id, frequency, amplitude, flag depending on the argument of sigmund~ (peaks or tracks, peaks are preferred). inlet_id corresponds to the number of the instrument.
| p | the inlet that is calling the method |
| argc | the number of elements in the list of arguments |
| argv | the list of arguments |
the frequency component
the frequency value
the amplitude value
clear the flag
do the minimization
| t_float S | ( | t_float | f | ) |
| void setCounters | ( | t_roughometer * | x, |
| t_int | value | ||
| ) |
Sets the counters of processed income to the value indicated by the parameter 'value.
'
| x | a pointer to the inner structure of the object |
| value | the new value for the counters |
|
static |
|
static |
1.8.10