5 /* Convert to gain value from dB. Returns AF_OK if of and AF_ERROR if
7 int af_from_dB(int n
, float* in
, float* out
, float k
, float mi
, float ma
)
18 out
[i
]=pow(10.0,clamp(in
[i
],mi
,ma
)/k
);
23 /* Convert from gain value to dB. Returns AF_OK if of and AF_ERROR if
25 int af_to_dB(int n
, float* in
, float* out
, float k
)
36 out
[i
]=k
*log10(in
[i
]);
41 /* Convert from ms to sample time */
42 int af_from_ms(int n
, float* in
, int* out
, int rate
, float mi
, float ma
)
50 out
[i
]=(int)((float)rate
* clamp(in
[i
],mi
,ma
)/1000.0);
55 /* Convert from sample time to ms */
56 int af_to_ms(int n
, int* in
, float* out
, int rate
)
60 if(!in
|| !out
|| !rate
)
64 out
[i
]=1000.0 * (float)in
[i
]/((float)rate
);
69 /* Helper function for testing the output format */
70 int af_test_output(struct af_instance_s
* af
, af_data_t
* out
)
72 if((af
->data
->format
!= out
->format
) ||
73 (af
->data
->bps
!= out
->bps
) ||
74 (af
->data
->rate
!= out
->rate
) ||
75 (af
->data
->nch
!= out
->nch
)){
76 memcpy(out
,af
->data
,sizeof(af_data_t
));
82 /* Soft clipping, the sound of a dream, thanks to Jon Wattes
83 post to Musicdsp.org */
84 float af_softclip(float a
)
88 else if (a
<= -M_PI
/2)