1c72fcc34Sopenharmony_ci#define ST2095_MAX_PEAK -9.5    // dB
2c72fcc34Sopenharmony_ci#define ST2095_HPFC     10.0    // Highpass filter cutoff in Hz
3c72fcc34Sopenharmony_ci#define ST2095_LPFC     22400.0 // Lowpass filter cutoff in Hz
4c72fcc34Sopenharmony_ci
5c72fcc34Sopenharmony_citypedef struct
6c72fcc34Sopenharmony_ci{
7c72fcc34Sopenharmony_ci  float maxAmp;
8c72fcc34Sopenharmony_ci  int samplesPerPeriod;
9c72fcc34Sopenharmony_ci  int randStep;
10c72fcc34Sopenharmony_ci  int randMax;
11c72fcc34Sopenharmony_ci  int seed;
12c72fcc34Sopenharmony_ci  float scaleFactor;
13c72fcc34Sopenharmony_ci  float w0t;
14c72fcc34Sopenharmony_ci  float k;
15c72fcc34Sopenharmony_ci  float k2;
16c72fcc34Sopenharmony_ci  float LpFc;
17c72fcc34Sopenharmony_ci  // biquad coefficients
18c72fcc34Sopenharmony_ci  float hp1_a1, hp1_a2;
19c72fcc34Sopenharmony_ci  float hp1_b0, hp1_b1, hp1_b2;
20c72fcc34Sopenharmony_ci  float hp2_a1, hp2_a2;
21c72fcc34Sopenharmony_ci  float hp2_b0, hp2_b1, hp2_b2;
22c72fcc34Sopenharmony_ci  float lp1_a1, lp1_a2;
23c72fcc34Sopenharmony_ci  float lp1_b0, lp1_b1, lp1_b2;
24c72fcc34Sopenharmony_ci  float lp2_a1, lp2_a2;
25c72fcc34Sopenharmony_ci  float lp2_b0, lp2_b1, lp2_b2;
26c72fcc34Sopenharmony_ci  // delay-line variables for bandpass filter
27c72fcc34Sopenharmony_ci  float hp1w1, hp1w2;
28c72fcc34Sopenharmony_ci  float hp2w1, hp2w2;
29c72fcc34Sopenharmony_ci  float lp1w1, lp1w2;
30c72fcc34Sopenharmony_ci  float lp2w1, lp2w2;
31c72fcc34Sopenharmony_ci  // delay-line variables for pink filter network
32c72fcc34Sopenharmony_ci  float lp1, lp2, lp3, lp4, lp5, lp6;
33c72fcc34Sopenharmony_ci  // statistics accumulator
34c72fcc34Sopenharmony_ci  float accum;
35c72fcc34Sopenharmony_ci} st2095_noise_t;
36c72fcc34Sopenharmony_ci
37c72fcc34Sopenharmony_civoid initialize_st2095_noise( st2095_noise_t *st2095, int sample_rate );
38c72fcc34Sopenharmony_cifloat generate_st2095_noise_sample( st2095_noise_t *st2095 );
39c72fcc34Sopenharmony_ci
40c72fcc34Sopenharmony_civoid reset_st2095_noise_measurement( st2095_noise_t *st2095 );
41c72fcc34Sopenharmony_cifloat compute_st2095_noise_measurement( st2095_noise_t *st2095, int period );
42