| @@ -30,7 +30,15 @@ extern "C" { · 29 unmodified lines |
| 30 | 30 | |
| 31 | 31 | //============================================================================== |
| 32 | 32 | |
| 33 | | − /* tAllpass: Schroeder allpass. Comb-filter with feedforward and feedback. */ |
| 33 | + /*! |
| 34 | + @defgroup tallpass tAllpass |
| 35 | + @ingroup filters |
| 36 | + @brief Schroeder allpass. Comb-filter with feedforward and feedback. |
| 37 | + @{ |
| 38 | + */ |
| 39 | + |
| 40 | + /*! @} */ |
| 41 | + |
| 34 | 42 | typedef struct _tAllpass |
| 35 | 43 | { |
| 36 | 44 | tMempool mempool; |
| @@ -55,7 +63,15 @@ extern "C" { · 18 unmodified lines |
| 55 | 63 | |
| 56 | 64 | //============================================================================== |
| 57 | 65 | |
| 58 | | − /* tOnePole: OnePole filter, reimplemented from STK (Cook and Scavone). */ |
| 66 | + /*! |
| 67 | + @defgroup tonepole tOnePole |
| 68 | + @ingroup filters |
| 69 | + @brief OnePole filter, reimplemented from STK (Cook and Scavone). |
| 70 | + @{ |
| 71 | + */ |
| 72 | + |
| 73 | + /*! @} */ |
| 74 | + |
| 59 | 75 | typedef struct _tOnePole |
| 60 | 76 | { |
| 61 | 77 | tMempool mempool; |
| @@ -81,7 +97,15 @@ extern "C" { · 19 unmodified lines |
| 81 | 97 | |
| 82 | 98 | //============================================================================== |
| 83 | 99 | |
| 84 | | − /* TwoPole filter, reimplemented from STK (Cook and Scavone). */ |
| 100 | + /*! |
| 101 | + @defgroup ttwopole tTwoPole |
| 102 | + @ingroup filters |
| 103 | + @brief TwoPole filter, reimplemented from STK (Cook and Scavone). |
| 104 | + @{ |
| 105 | + */ |
| 106 | + |
| 107 | + /*! @} */ |
| 108 | + |
| 85 | 109 | typedef struct _tTwoPole |
| 86 | 110 | { |
| 87 | 111 | tMempool mempool; |
| @@ -92,7 +116,7 @@ extern "C" { · 4 unmodified lines |
| 92 | 116 | |
| 93 | 117 | float radius, frequency; |
| 94 | 118 | oBool normalize; |
| 95 | | − |
| 119 | + |
| 96 | 120 | float lastOut[2]; |
| 97 | 121 | } _tTwoPole; |
| 98 | 122 | |
| @@ -112,7 +136,15 @@ extern "C" { · 13 unmodified lines |
| 112 | 136 | |
| 113 | 137 | //============================================================================== |
| 114 | 138 | |
| 115 | | − /* OneZero filter, reimplemented from STK (Cook and Scavone). */ |
| 139 | + /*! |
| 140 | + @defgroup tonezero tOneZero |
| 141 | + @ingroup filters |
| 142 | + @brief OneZero filter, reimplemented from STK (Cook and Scavone). |
| 143 | + @{ |
| 144 | + */ |
| 145 | + |
| 146 | + /*! @} */ |
| 147 | + |
| 116 | 148 | typedef struct _tOneZero |
| 117 | 149 | { |
| 118 | 150 | tMempool mempool; |
| @@ -137,7 +169,15 @@ extern "C" { · 18 unmodified lines |
| 137 | 169 | |
| 138 | 170 | //============================================================================== |
| 139 | 171 | |
| 140 | | − /* TwoZero filter, reimplemented from STK (Cook and Scavone). */ |
| 172 | + /*! |
| 173 | + @defgroup ttwozero tTwoZero |
| 174 | + @ingroup filters |
| 175 | + @brief TwoZero filter, reimplemented from STK (Cook and Scavone). |
| 176 | + @{ |
| 177 | + */ |
| 178 | + |
| 179 | + /*! @} */ |
| 180 | + |
| 141 | 181 | typedef struct _tTwoZero |
| 142 | 182 | { |
| 143 | 183 | tMempool mempool; |
| @@ -166,7 +206,15 @@ extern "C" { · 22 unmodified lines |
| 166 | 206 | |
| 167 | 207 | //============================================================================== |
| 168 | 208 | |
| 169 | | − /* PoleZero filter, reimplemented from STK (Cook and Scavone). */ |
| 209 | + /*! |
| 210 | + @defgroup tpolezero tPoleZero |
| 211 | + @ingroup filters |
| 212 | + @brief PoleZero filter, reimplemented from STK (Cook and Scavone). |
| 213 | + @{ |
| 214 | + */ |
| 215 | + |
| 216 | + /*! @} */ |
| 217 | + |
| 170 | 218 | typedef struct _tPoleZero |
| 171 | 219 | { |
| 172 | 220 | tMempool mempool; |
| @@ -195,7 +243,15 @@ extern "C" { · 22 unmodified lines |
| 195 | 243 | |
| 196 | 244 | //============================================================================== |
| 197 | 245 | |
| 198 | | − /* BiQuad filter, reimplemented from STK (Cook and Scavone). */ |
| 246 | + /*! |
| 247 | + @defgroup tbiquad tBiQuad |
| 248 | + @ingroup filters |
| 249 | + @brief BiQuad filter, reimplemented from STK (Cook and Scavone). |
| 250 | + @{ |
| 251 | + */ |
| 252 | + |
| 253 | + /*! @} */ |
| 254 | + |
| 199 | 255 | typedef struct _tBiQuad |
| 200 | 256 | { |
| 201 | 257 | tMempool mempool; |
| @@ -230,7 +286,15 @@ extern "C" { · 28 unmodified lines |
| 230 | 286 | |
| 231 | 287 | //============================================================================== |
| 232 | 288 | |
| 233 | | −/* State Variable Filter, algorithm from Andy Simper. */ |
| 289 | + /*! |
| 290 | + @defgroup tsvf tSVF |
| 291 | + @ingroup filters |
| 292 | + @brief State Variable Filter, algorithm from Andy Simper. |
| 293 | + @{ |
| 294 | + */ |
| 295 | + |
| 296 | + /*! @} */ |
| 297 | + |
| 234 | 298 | typedef enum SVFType |
| 235 | 299 | { |
| 236 | 300 | SVFTypeHighpass = 0, |
| @@ -263,7 +327,15 @@ extern "C" { · 26 unmodified lines |
| 263 | 327 | void tSVF_setFreqAndQ (tSVF* const svff, float freq, float Q); |
| 264 | 328 | //============================================================================== |
| 265 | 329 | |
| 266 | | − /* Efficient State Variable Filter for 14-bit control input, [0, 4096). */ |
| 330 | + /*! |
| 331 | + @defgroup tefficientsvf tEfficientSVF |
| 332 | + @ingroup filters |
| 333 | + @brief Efficient State Variable Filter for 14-bit control input, [0, 4096). |
| 334 | + @{ |
| 335 | + */ |
| 336 | + |
| 337 | + /*! @} */ |
| 338 | + |
| 267 | 339 | typedef struct _tEfficientSVF |
| 268 | 340 | { |
| 269 | 341 | tMempool mempool; |
| @@ -285,7 +357,15 @@ extern "C" { · 15 unmodified lines |
| 285 | 357 | |
| 286 | 358 | //============================================================================== |
| 287 | 359 | |
| 288 | | − /* Simple Highpass filter. */ |
| 360 | + /*! |
| 361 | + @defgroup thighpass tHighpass |
| 362 | + @ingroup filters |
| 363 | + @brief Simple Highpass filter. |
| 364 | + @{ |
| 365 | + */ |
| 366 | + |
| 367 | + /*! @} */ |
| 368 | + |
| 289 | 369 | typedef struct _tHighpass |
| 290 | 370 | { |
| 291 | 371 | tMempool mempool; |
| @@ -305,7 +385,15 @@ extern "C" { · 13 unmodified lines |
| 305 | 385 | |
| 306 | 386 | //============================================================================== |
| 307 | 387 | |
| 308 | | − // Butterworth Filter |
| 388 | + /*! |
| 389 | + @defgroup tbutterworth tButterworth |
| 390 | + @ingroup filters |
| 391 | + @brief |
| 392 | + @{ |
| 393 | + */ |
| 394 | + |
| 395 | + /*! @} */ |
| 396 | + |
| 309 | 397 | #define NUM_SVF_BW 16 |
| 310 | 398 | typedef struct _tButterworth |
| 311 | 399 | { |
| @@ -334,6 +422,15 @@ extern "C" { · 22 unmodified lines |
| 334 | 422 | |
| 335 | 423 | //============================================================================== |
| 336 | 424 | |
| 425 | + /*! |
| 426 | + @defgroup tfir tFIR |
| 427 | + @ingroup filters |
| 428 | + @brief |
| 429 | + @{ |
| 430 | + */ |
| 431 | + |
| 432 | + /*! @} */ |
| 433 | + |
| 337 | 434 | typedef struct _tFIR |
| 338 | 435 | { |
| 339 | 436 | tMempool mempool; |
| @@ -349,125 +446,146 @@ extern "C" { · 9 unmodified lines |
| 349 | 446 | void tFIR_free (tFIR* const); |
| 350 | 447 | |
| 351 | 448 | float tFIR_tick (tFIR* const, float input); |
| 352 | | − |
| 449 | + |
| 353 | 450 | |
| 354 | 451 | //============================================================================== |
| 355 | 452 | |
| 356 | | − |
| 453 | + /*! |
| 454 | + @defgroup tmedianfilter tMedianFilter |
| 455 | + @ingroup filters |
| 456 | + @brief |
| 457 | + @{ |
| 458 | + */ |
| 459 | + |
| 460 | + /*! @} */ |
| 461 | + |
| 357 | 462 | typedef struct _tMedianFilter |
| 358 | 463 | { |
| 359 | 464 | tMempool mempool; |
| 360 | | − float* val; |
| 361 | | − int* age; |
| 362 | | − int m; |
| 363 | | − int size; |
| 364 | | − int middlePosition; |
| 365 | | − int last; |
| 366 | | − int pos; |
| 465 | + float* val; |
| 466 | + int* age; |
| 467 | + int m; |
| 468 | + int size; |
| 469 | + int middlePosition; |
| 470 | + int last; |
| 471 | + int pos; |
| 367 | 472 | } _tMedianFilter; |
| 368 | | − |
| 473 | + |
| 369 | 474 | typedef _tMedianFilter* tMedianFilter; |
| 370 | | − |
| 475 | + |
| 371 | 476 | void tMedianFilter_init (tMedianFilter* const, int size); |
| 372 | | − void tMedianFilter_initToPool (tMedianFilter* const, int size, tMempool* const); |
| 373 | | − void tMedianFilter_free (tMedianFilter* const); |
| 374 | | − |
| 375 | | − float tMedianFilter_tick (tMedianFilter* const, float input); |
| 376 | | − |
| 377 | | − |
| 378 | | − |
| 379 | | − |
| 380 | | − |
| 381 | | − //Vadim Zavalishin style from VA book (from implementation in RSlib posted to kvr forum) |
| 382 | | − |
| 477 | + void tMedianFilter_initToPool (tMedianFilter* const, int size, tMempool* const); |
| 478 | + void tMedianFilter_free (tMedianFilter* const); |
| 479 | + |
| 480 | + float tMedianFilter_tick (tMedianFilter* const, float input); |
| 481 | + |
| 482 | + |
| 483 | + /*! |
| 484 | + @defgroup tvzfilter tVZFilter |
| 485 | + @ingroup filters |
| 486 | + @brief |
| 487 | + @{ |
| 488 | + */ |
| 489 | + |
| 490 | + /*! @} */ |
| 491 | + |
| 492 | + //Vadim Zavalishin style from VA book (from implementation in RSlib posted to kvr forum) |
| 493 | + |
| 383 | 494 | typedef enum VZFilterType |
| 384 | 495 | { |
| 385 | | − Highpass = 0, |
| 496 | + Highpass = 0, |
| 386 | 497 | Lowpass, |
| 387 | 498 | BandpassSkirt, |
| 388 | | − BandpassPeak, |
| 389 | | − BandReject, |
| 499 | + BandpassPeak, |
| 500 | + BandReject, |
| 390 | 501 | Bell, |
| 391 | | − Lowshelf, |
| 392 | | − Highshelf, |
| 393 | | − Morph, |
| 394 | | − Bypass, |
| 395 | | − Allpass |
| 502 | + Lowshelf, |
| 503 | + Highshelf, |
| 504 | + Morph, |
| 505 | + Bypass, |
| 506 | + Allpass |
| 396 | 507 | } VZFilterType; |
| 397 | | − |
| 398 | | − |
| 399 | | − typedef struct _tVZFilter |
| 400 | | − { |
| 401 | | − tMempool mempool; |
| 402 | | − |
| 403 | | − VZFilterType type; |
| 404 | | − // state: |
| 405 | | − float s1, s2; |
| 406 | | − |
| 407 | | − // filter coefficients: |
| 408 | | − float g; // embedded integrator gain |
| 409 | | − float R2; // twice the damping coefficient (R2 == 2*R == 1/Q) |
| 410 | | − float h; // factor for feedback (== 1/(1+2*R*g+g*g)) |
| 411 | | − float cL, cB, cH; // coefficients for low-, band-, and highpass signals |
| 412 | | − |
| 413 | | − // parameters: |
| 414 | | − float fc; // characteristic frequency |
| 415 | | − float G; // gain |
| 416 | | − float invG; //1/gain |
| 417 | | − float B; // bandwidth (in octaves) |
| 418 | | − float m; // morph parameter (0...1) |
| 419 | | − |
| 420 | | − float sr; //local sampling rate of filter (may be different from leaf sr if oversampled) |
| 421 | | − float inv_sr; |
| 422 | | − } _tVZFilter; |
| 423 | | − |
| 424 | | − typedef _tVZFilter* tVZFilter; |
| 425 | | − |
| 426 | | − void tVZFilter_init (tVZFilter* const, VZFilterType type, float freq, float Q); |
| 427 | | − void tVZFilter_initToPool (tVZFilter* const, VZFilterType type, float freq, float Q, tMempool* const); |
| 428 | | − void tVZFilter_free (tVZFilter* const); |
| 429 | | − |
| 430 | | − void tVZFilter_setSampleRate (tVZFilter* const, float sampleRate); |
| 431 | | − float tVZFilter_tick (tVZFilter* const, float input); |
| 432 | | − float tVZFilter_tickEfficient (tVZFilter* const vf, float in); |
| 433 | | − void tVZFilter_calcCoeffs (tVZFilter* const); |
| 434 | | − void tVZFilter_setBandwidth (tVZFilter* const, float bandWidth); |
| 435 | | − void tVZFilter_setFreq (tVZFilter* const, float freq); |
| 436 | | − void tVZFilter_setFreqAndBandwidth (tVZFilter* const vf, float freq, float bw); |
| 437 | | − void tVZFilter_setGain (tVZFilter* const, float gain); |
| 438 | | − void tVZFilter_setType (tVZFilter* const, VZFilterType type); |
| 439 | | − float tVZFilter_BandwidthToR (tVZFilter* const vf, float B); |
| 440 | | − |
| 441 | | − |
| 442 | | − |
| 443 | | − |
| 444 | | − //diode ladder filter |
| 445 | | − typedef struct _tDiodeFilter |
| 446 | | − { |
| 447 | | − tMempool mempool; |
| 448 | | − float f; |
| 449 | | − float r; |
| 450 | | − float Vt; |
| 451 | | − float n; |
| 452 | | − float gamma; |
| 453 | | − float zi; |
| 454 | | − float g0inv; |
| 455 | | − float g1inv; |
| 456 | | − float g2inv; |
| 457 | | − float s0, s1, s2, s3; |
| 458 | | − } _tDiodeFilter; |
| 459 | | − |
| 460 | | − typedef _tDiodeFilter* tDiodeFilter; |
| 461 | | − |
| 462 | | − void tDiodeFilter_init (tDiodeFilter* const, float freq, float Q); |
| 463 | | − void tDiodeFilter_initToPool (tDiodeFilter* const, float freq, float Q, tMempool* const); |
| 464 | | − void tDiodeFilter_free (tDiodeFilter* const); |
| 465 | | − |
| 466 | | − float tDiodeFilter_tick (tDiodeFilter* const, float input); |
| 467 | | − void tDiodeFilter_setFreq (tDiodeFilter* const vf, float cutoff); |
| 468 | | − void tDiodeFilter_setQ (tDiodeFilter* const vf, float resonance); |
| 469 | | − |
| 470 | | − |
| 508 | + |
| 509 | + |
| 510 | + typedef struct _tVZFilter |
| 511 | + { |
| 512 | + tMempool mempool; |
| 513 | + |
| 514 | + VZFilterType type; |
| 515 | + // state: |
| 516 | + float s1, s2; |
| 517 | + |
| 518 | + // filter coefficients: |
| 519 | + float g; // embedded integrator gain |
| 520 | + float R2; // twice the damping coefficient (R2 == 2*R == 1/Q) |
| 521 | + float h; // factor for feedback (== 1/(1+2*R*g+g*g)) |
| 522 | + float cL, cB, cH; // coefficients for low-, band-, and highpass signals |
| 523 | + |
| 524 | + // parameters: |
| 525 | + float fc; // characteristic frequency |
| 526 | + float G; // gain |
| 527 | + float invG; //1/gain |
| 528 | + float B; // bandwidth (in octaves) |
| 529 | + float m; // morph parameter (0...1) |
| 530 | + |
| 531 | + float sr; //local sampling rate of filter (may be different from leaf sr if oversampled) |
| 532 | + float inv_sr; |
| 533 | + } _tVZFilter; |
| 534 | + |
| 535 | + typedef _tVZFilter* tVZFilter; |
| 536 | + |
| 537 | + void tVZFilter_init (tVZFilter* const, VZFilterType type, float freq, float Q); |
| 538 | + void tVZFilter_initToPool (tVZFilter* const, VZFilterType type, float freq, float Q, tMempool* const); |
| 539 | + void tVZFilter_free (tVZFilter* const); |
| 540 | + |
| 541 | + void tVZFilter_setSampleRate (tVZFilter* const, float sampleRate); |
| 542 | + float tVZFilter_tick (tVZFilter* const, float input); |
| 543 | + float tVZFilter_tickEfficient (tVZFilter* const vf, float in); |
| 544 | + void tVZFilter_calcCoeffs (tVZFilter* const); |
| 545 | + void tVZFilter_setBandwidth (tVZFilter* const, float bandWidth); |
| 546 | + void tVZFilter_setFreq (tVZFilter* const, float freq); |
| 547 | + void tVZFilter_setFreqAndBandwidth (tVZFilter* const vf, float freq, float bw); |
| 548 | + void tVZFilter_setGain (tVZFilter* const, float gain); |
| 549 | + void tVZFilter_setType (tVZFilter* const, VZFilterType type); |
| 550 | + float tVZFilter_BandwidthToR (tVZFilter* const vf, float B); |
| 551 | + |
| 552 | + |
| 553 | + /*! |
| 554 | + @defgroup tdiodefilter tDiodeFilter |
| 555 | + @ingroup filters |
| 556 | + @brief |
| 557 | + @{ |
| 558 | + */ |
| 559 | + |
| 560 | + /*! @} */ |
| 561 | + |
| 562 | + //diode ladder filter |
| 563 | + typedef struct _tDiodeFilter |
| 564 | + { |
| 565 | + tMempool mempool; |
| 566 | + float f; |
| 567 | + float r; |
| 568 | + float Vt; |
| 569 | + float n; |
| 570 | + float gamma; |
| 571 | + float zi; |
| 572 | + float g0inv; |
| 573 | + float g1inv; |
| 574 | + float g2inv; |
| 575 | + float s0, s1, s2, s3; |
| 576 | + } _tDiodeFilter; |
| 577 | + |
| 578 | + typedef _tDiodeFilter* tDiodeFilter; |
| 579 | + |
| 580 | + void tDiodeFilter_init (tDiodeFilter* const, float freq, float Q); |
| 581 | + void tDiodeFilter_initToPool (tDiodeFilter* const, float freq, float Q, tMempool* const); |
| 582 | + void tDiodeFilter_free (tDiodeFilter* const); |
| 583 | + |
| 584 | + float tDiodeFilter_tick (tDiodeFilter* const, float input); |
| 585 | + void tDiodeFilter_setFreq (tDiodeFilter* const vf, float cutoff); |
| 586 | + void tDiodeFilter_setQ (tDiodeFilter* const vf, float resonance); |
| 587 | + |
| 588 | + |
| 471 | 589 | #ifdef __cplusplus |
| 472 | 590 | } |
| 473 | 591 | #endif |
| @@ -476,3 +594,4 @@ extern "C" { · 2 unmodified lines |
| 476 | 594 | |
| 477 | 595 | //============================================================================== |
| 478 | 596 | |
| 597 | + |