1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966
|
/* -*- linux-c -*-
Copyright (C) 2004 Tom Szilagyi
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* This plugin is identical to TAP Equalizer (2141), but it has
* separate user controls for setting the bandwidth of every filter.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ladspa.h>
#include "tap_utils.h"
/* The Unique ID of the plugin */
#define ID_MONO 2151
/* Default bandwidth of EQ filters in octaves */
#define BWIDTH 1.0f
/* Port numbers */
#define EQ_CH0G 0
#define EQ_CH1G 1
#define EQ_CH2G 2
#define EQ_CH3G 3
#define EQ_CH4G 4
#define EQ_CH5G 5
#define EQ_CH6G 6
#define EQ_CH7G 7
#define EQ_CH0F 8
#define EQ_CH1F 9
#define EQ_CH2F 10
#define EQ_CH3F 11
#define EQ_CH4F 12
#define EQ_CH5F 13
#define EQ_CH6F 14
#define EQ_CH7F 15
#define EQ_CH0B 16
#define EQ_CH1B 17
#define EQ_CH2B 18
#define EQ_CH3B 19
#define EQ_CH4B 20
#define EQ_CH5B 21
#define EQ_CH6B 22
#define EQ_CH7B 23
#define EQ_INPUT 24
#define EQ_OUTPUT 25
/* Total number of ports */
#define PORTCOUNT_MONO 26
static LADSPA_Descriptor *eqDescriptor = NULL;
typedef struct {
LADSPA_Data *ch0f;
LADSPA_Data *ch0g;
LADSPA_Data *ch0b;
LADSPA_Data *ch1f;
LADSPA_Data *ch1g;
LADSPA_Data *ch1b;
LADSPA_Data *ch2f;
LADSPA_Data *ch2g;
LADSPA_Data *ch2b;
LADSPA_Data *ch3f;
LADSPA_Data *ch3g;
LADSPA_Data *ch3b;
LADSPA_Data *ch4f;
LADSPA_Data *ch4g;
LADSPA_Data *ch4b;
LADSPA_Data *ch5f;
LADSPA_Data *ch5g;
LADSPA_Data *ch5b;
LADSPA_Data *ch6f;
LADSPA_Data *ch6g;
LADSPA_Data *ch6b;
LADSPA_Data *ch7f;
LADSPA_Data *ch7g;
LADSPA_Data *ch7b;
LADSPA_Data *input;
LADSPA_Data *output;
biquad * filters;
float fs;
LADSPA_Data old_ch0f;
LADSPA_Data old_ch0g;
LADSPA_Data old_ch0b;
LADSPA_Data old_ch1f;
LADSPA_Data old_ch1g;
LADSPA_Data old_ch1b;
LADSPA_Data old_ch2f;
LADSPA_Data old_ch2g;
LADSPA_Data old_ch2b;
LADSPA_Data old_ch3f;
LADSPA_Data old_ch3g;
LADSPA_Data old_ch3b;
LADSPA_Data old_ch4f;
LADSPA_Data old_ch4g;
LADSPA_Data old_ch4b;
LADSPA_Data old_ch5f;
LADSPA_Data old_ch5g;
LADSPA_Data old_ch5b;
LADSPA_Data old_ch6f;
LADSPA_Data old_ch6g;
LADSPA_Data old_ch6b;
LADSPA_Data old_ch7f;
LADSPA_Data old_ch7g;
LADSPA_Data old_ch7b;
LADSPA_Data run_adding_gain;
} eq;
const
LADSPA_Descriptor *
ladspa_descriptor(unsigned long index) {
switch (index) {
case 0:
return eqDescriptor;
default:
return NULL;
}
}
static
void
activate_eq(LADSPA_Handle instance) {
eq *ptr = (eq *)instance;
biquad *filters = ptr->filters;
biquad_init(&filters[0]);
biquad_init(&filters[1]);
biquad_init(&filters[2]);
biquad_init(&filters[3]);
biquad_init(&filters[4]);
biquad_init(&filters[5]);
biquad_init(&filters[6]);
biquad_init(&filters[7]);
}
static
void
cleanup_eq(LADSPA_Handle instance) {
eq *plugin_data = (eq *)instance;
free(plugin_data->filters);
free(instance);
}
static
void
connectPort_eq(LADSPA_Handle instance, unsigned long port, LADSPA_Data *data) {
eq *plugin;
plugin = (eq *)instance;
switch (port) {
case EQ_CH0F:
plugin->ch0f = data;
break;
case EQ_CH0G:
plugin->ch0g = data;
break;
case EQ_CH0B:
plugin->ch0b = data;
break;
case EQ_CH1F:
plugin->ch1f = data;
break;
case EQ_CH1G:
plugin->ch1g = data;
break;
case EQ_CH1B:
plugin->ch1b = data;
break;
case EQ_CH2F:
plugin->ch2f = data;
break;
case EQ_CH2G:
plugin->ch2g = data;
break;
case EQ_CH2B:
plugin->ch2b = data;
break;
case EQ_CH3F:
plugin->ch3f = data;
break;
case EQ_CH3G:
plugin->ch3g = data;
break;
case EQ_CH3B:
plugin->ch3b = data;
break;
case EQ_CH4F:
plugin->ch4f = data;
break;
case EQ_CH4G:
plugin->ch4g = data;
break;
case EQ_CH4B:
plugin->ch4b = data;
break;
case EQ_CH5F:
plugin->ch5f = data;
break;
case EQ_CH5G:
plugin->ch5g = data;
break;
case EQ_CH5B:
plugin->ch5b = data;
break;
case EQ_CH6F:
plugin->ch6f = data;
break;
case EQ_CH6G:
plugin->ch6g = data;
break;
case EQ_CH6B:
plugin->ch6b = data;
break;
case EQ_CH7F:
plugin->ch7f = data;
break;
case EQ_CH7G:
plugin->ch7g = data;
break;
case EQ_CH7B:
plugin->ch7b = data;
break;
case EQ_INPUT:
plugin->input = data;
break;
case EQ_OUTPUT:
plugin->output = data;
break;
}
}
static
LADSPA_Handle
instantiate_eq(const LADSPA_Descriptor *descriptor, unsigned long s_rate) {
eq *ptr = (eq *)malloc(sizeof(eq));
biquad *filters = NULL;
float fs;
fs = s_rate;
memset(ptr, 0, sizeof(eq));
filters = calloc(8, sizeof(biquad));
ptr->filters = filters;
ptr->fs = fs;
ptr->run_adding_gain = 1.0f;
ptr->old_ch0f = 100.0f;
ptr->old_ch0g = 0.0f;
ptr->old_ch0b = BWIDTH;
ptr->old_ch1f = 200.0f;
ptr->old_ch1g = 0.0f;
ptr->old_ch1b = BWIDTH;
ptr->old_ch2f = 400.0f;
ptr->old_ch2g = 0.0f;
ptr->old_ch2b = BWIDTH;
ptr->old_ch3f = 1000.0f;
ptr->old_ch3g = 0.0f;
ptr->old_ch3b = BWIDTH;
ptr->old_ch4f = 3000.0f;
ptr->old_ch4g = 0.0f;
ptr->old_ch4b = BWIDTH;
ptr->old_ch5f = 6000.0f;
ptr->old_ch5g = 0.0f;
ptr->old_ch5b = BWIDTH;
ptr->old_ch6f = 12000.0f;
ptr->old_ch6g = 0.0f;
ptr->old_ch6b = BWIDTH;
ptr->old_ch7f = 15000.0f;
ptr->old_ch7g = 0.0f;
ptr->old_ch7b = BWIDTH;
eq_set_params(&filters[0], 100.0f, 0.0f, BWIDTH, fs);
eq_set_params(&filters[1], 200.0f, 0.0f, BWIDTH, fs);
eq_set_params(&filters[2], 400.0f, 0.0f, BWIDTH, fs);
eq_set_params(&filters[3], 1000.0f, 0.0f, BWIDTH, fs);
eq_set_params(&filters[4], 3000.0f, 0.0f, BWIDTH, fs);
eq_set_params(&filters[5], 6000.0f, 0.0f, BWIDTH, fs);
eq_set_params(&filters[6], 12000.0f, 0.0f, BWIDTH, fs);
eq_set_params(&filters[7], 15000.0f, 0.0f, BWIDTH, fs);
return (LADSPA_Handle)ptr;
}
static
void
run_eq(LADSPA_Handle instance, unsigned long sample_count) {
eq * ptr = (eq *)instance;
const LADSPA_Data ch0f = LIMIT(*(ptr->ch0f),40.0f,280.0f);
const LADSPA_Data ch0g = LIMIT(*(ptr->ch0g),-50.0f,20.0f);
const LADSPA_Data ch0b = LIMIT(*(ptr->ch0b),0.1f,5.0f);
const LADSPA_Data ch1f = LIMIT(*(ptr->ch1f),100.0f,500.0f);
const LADSPA_Data ch1g = LIMIT(*(ptr->ch1g),-50.0f,20.0f);
const LADSPA_Data ch1b = LIMIT(*(ptr->ch1b),0.1f,5.0f);
const LADSPA_Data ch2f = LIMIT(*(ptr->ch2f),200.0f,1000.0f);
const LADSPA_Data ch2g = LIMIT(*(ptr->ch2g),-50.0f,20.0f);
const LADSPA_Data ch2b = LIMIT(*(ptr->ch2b),0.1f,5.0f);
const LADSPA_Data ch3f = LIMIT(*(ptr->ch3f),400.0f,2800.0f);
const LADSPA_Data ch3g = LIMIT(*(ptr->ch3g),-50.0f,20.0f);
const LADSPA_Data ch3b = LIMIT(*(ptr->ch3b),0.1f,5.0f);
const LADSPA_Data ch4f = LIMIT(*(ptr->ch4f),1000.0f,5000.0f);
const LADSPA_Data ch4g = LIMIT(*(ptr->ch4g),-50.0f,20.0f);
const LADSPA_Data ch4b = LIMIT(*(ptr->ch4b),0.1f,5.0f);
const LADSPA_Data ch5f = LIMIT(*(ptr->ch5f),3000.0f,9000.0f);
const LADSPA_Data ch5g = LIMIT(*(ptr->ch5g),-50.0f,20.0f);
const LADSPA_Data ch5b = LIMIT(*(ptr->ch5b),0.1f,5.0f);
const LADSPA_Data ch6f = LIMIT(*(ptr->ch6f),6000.0f,18000.0f);
const LADSPA_Data ch6g = LIMIT(*(ptr->ch6g),-50.0f,20.0f);
const LADSPA_Data ch6b = LIMIT(*(ptr->ch6b),0.1f,5.0f);
const LADSPA_Data ch7f = LIMIT(*(ptr->ch7f),10000.0f,20000.0f);
const LADSPA_Data ch7g = LIMIT(*(ptr->ch7g),-50.0f,20.0f);
const LADSPA_Data ch7b = LIMIT(*(ptr->ch7b),0.1f,5.0f);
const LADSPA_Data * input = ptr->input;
LADSPA_Data * output = ptr->output;
biquad * filters = ptr->filters;
float fs = ptr->fs;
unsigned long pos;
float samp;
if ((ch0f != ptr->old_ch0f) ||
(ch0g != ptr->old_ch0g) ||
(ch0b != ptr->old_ch0b)) {
ptr->old_ch0f = ch0f;
ptr->old_ch0g = ch0g;
ptr->old_ch0b = ch0b;
eq_set_params(&filters[0], ch0f, ch0g, ch0b, fs);
}
if ((ch1f != ptr->old_ch1f) ||
(ch1g != ptr->old_ch1g) ||
(ch1b != ptr->old_ch1b)) {
ptr->old_ch1f = ch1f;
ptr->old_ch1g = ch1g;
ptr->old_ch1b = ch1b;
eq_set_params(&filters[1], ch1f, ch1g, ch1b, fs);
}
if ((ch2f != ptr->old_ch2f) ||
(ch2g != ptr->old_ch2g) ||
(ch2b != ptr->old_ch2b)) {
ptr->old_ch2f = ch2f;
ptr->old_ch2g = ch2g;
ptr->old_ch2b = ch2b;
eq_set_params(&filters[2], ch2f, ch2g, ch2b, fs);
}
if ((ch3f != ptr->old_ch3f) ||
(ch3g != ptr->old_ch3g) ||
(ch3b != ptr->old_ch3b)) {
ptr->old_ch3f = ch3f;
ptr->old_ch3g = ch3g;
ptr->old_ch3b = ch3b;
eq_set_params(&filters[3], ch3f, ch3g, ch3b, fs);
}
if ((ch4f != ptr->old_ch4f) ||
(ch4g != ptr->old_ch4g) ||
(ch4b != ptr->old_ch4b)) {
ptr->old_ch4f = ch4f;
ptr->old_ch4g = ch4g;
ptr->old_ch4b = ch4b;
eq_set_params(&filters[4], ch4f, ch4g, ch4b, fs);
}
if ((ch5f != ptr->old_ch5f) ||
(ch5g != ptr->old_ch5g) ||
(ch5b != ptr->old_ch5b)) {
ptr->old_ch5f = ch5f;
ptr->old_ch5g = ch5g;
ptr->old_ch5b = ch5b;
eq_set_params(&filters[5], ch5f, ch5g, ch5b, fs);
}
if ((ch6f != ptr->old_ch6f) ||
(ch6g != ptr->old_ch6g) ||
(ch6b != ptr->old_ch6b)) {
ptr->old_ch6f = ch6f;
ptr->old_ch6g = ch6g;
ptr->old_ch6b = ch6b;
eq_set_params(&filters[6], ch6f, ch6g, ch6b, fs);
}
if ((ch7f != ptr->old_ch7f) ||
(ch7g != ptr->old_ch7g) ||
(ch7b != ptr->old_ch7b)) {
ptr->old_ch7f = ch7f;
ptr->old_ch7g = ch7g;
ptr->old_ch7b = ch7b;
eq_set_params(&filters[7], ch7f, ch7g, ch7b, fs);
}
for (pos = 0; pos < sample_count; pos++) {
samp = input[pos];
if (ch0g != 0.0f)
samp = biquad_run(&filters[0], samp);
if (ch1g != 0.0f)
samp = biquad_run(&filters[1], samp);
if (ch2g != 0.0f)
samp = biquad_run(&filters[2], samp);
if (ch3g != 0.0f)
samp = biquad_run(&filters[3], samp);
if (ch4g != 0.0f)
samp = biquad_run(&filters[4], samp);
if (ch5g != 0.0f)
samp = biquad_run(&filters[5], samp);
if (ch6g != 0.0f)
samp = biquad_run(&filters[6], samp);
if (ch7g != 0.0f)
samp = biquad_run(&filters[7], samp);
output[pos] = samp;
}
}
void
set_run_adding_gain(LADSPA_Handle instance, LADSPA_Data gain) {
eq * ptr = (eq *)instance;
ptr->run_adding_gain = gain;
}
static
void
run_adding_eq(LADSPA_Handle instance, unsigned long sample_count) {
eq * ptr = (eq *)instance;
const LADSPA_Data ch0f = LIMIT(*(ptr->ch0f),40.0f,280.0f);
const LADSPA_Data ch0g = LIMIT(*(ptr->ch0g),-50.0f,20.0f);
const LADSPA_Data ch0b = LIMIT(*(ptr->ch0b),0.1f,5.0f);
const LADSPA_Data ch1f = LIMIT(*(ptr->ch1f),100.0f,500.0f);
const LADSPA_Data ch1g = LIMIT(*(ptr->ch1g),-50.0f,20.0f);
const LADSPA_Data ch1b = LIMIT(*(ptr->ch1b),0.1f,5.0f);
const LADSPA_Data ch2f = LIMIT(*(ptr->ch2f),200.0f,1000.0f);
const LADSPA_Data ch2g = LIMIT(*(ptr->ch2g),-50.0f,20.0f);
const LADSPA_Data ch2b = LIMIT(*(ptr->ch2b),0.1f,5.0f);
const LADSPA_Data ch3f = LIMIT(*(ptr->ch3f),400.0f,2800.0f);
const LADSPA_Data ch3g = LIMIT(*(ptr->ch3g),-50.0f,20.0f);
const LADSPA_Data ch3b = LIMIT(*(ptr->ch3b),0.1f,5.0f);
const LADSPA_Data ch4f = LIMIT(*(ptr->ch4f),1000.0f,5000.0f);
const LADSPA_Data ch4g = LIMIT(*(ptr->ch4g),-50.0f,20.0f);
const LADSPA_Data ch4b = LIMIT(*(ptr->ch4b),0.1f,5.0f);
const LADSPA_Data ch5f = LIMIT(*(ptr->ch5f),3000.0f,9000.0f);
const LADSPA_Data ch5g = LIMIT(*(ptr->ch5g),-50.0f,20.0f);
const LADSPA_Data ch5b = LIMIT(*(ptr->ch5b),0.1f,5.0f);
const LADSPA_Data ch6f = LIMIT(*(ptr->ch6f),6000.0f,18000.0f);
const LADSPA_Data ch6g = LIMIT(*(ptr->ch6g),-50.0f,20.0f);
const LADSPA_Data ch6b = LIMIT(*(ptr->ch6b),0.1f,5.0f);
const LADSPA_Data ch7f = LIMIT(*(ptr->ch7f),10000.0f,20000.0f);
const LADSPA_Data ch7g = LIMIT(*(ptr->ch7g),-50.0f,20.0f);
const LADSPA_Data ch7b = LIMIT(*(ptr->ch7b),0.1f,5.0f);
const LADSPA_Data * input = ptr->input;
LADSPA_Data * output = ptr->output;
biquad * filters = ptr->filters;
float fs = ptr->fs;
unsigned long pos;
float samp;
if ((ch0f != ptr->old_ch0f) ||
(ch0g != ptr->old_ch0g) ||
(ch0b != ptr->old_ch0b)) {
ptr->old_ch0f = ch0f;
ptr->old_ch0g = ch0g;
ptr->old_ch0b = ch0b;
eq_set_params(&filters[0], ch0f, ch0g, ch0b, fs);
}
if ((ch1f != ptr->old_ch1f) ||
(ch1g != ptr->old_ch1g) ||
(ch1b != ptr->old_ch1b)) {
ptr->old_ch1f = ch1f;
ptr->old_ch1g = ch1g;
ptr->old_ch1b = ch1b;
eq_set_params(&filters[1], ch1f, ch1g, ch1b, fs);
}
if ((ch2f != ptr->old_ch2f) ||
(ch2g != ptr->old_ch2g) ||
(ch2b != ptr->old_ch2b)) {
ptr->old_ch2f = ch2f;
ptr->old_ch2g = ch2g;
ptr->old_ch2b = ch2b;
eq_set_params(&filters[2], ch2f, ch2g, ch2b, fs);
}
if ((ch3f != ptr->old_ch3f) ||
(ch3g != ptr->old_ch3g) ||
(ch3b != ptr->old_ch3b)) {
ptr->old_ch3f = ch3f;
ptr->old_ch3g = ch3g;
ptr->old_ch3b = ch3b;
eq_set_params(&filters[3], ch3f, ch3g, ch3b, fs);
}
if ((ch4f != ptr->old_ch4f) ||
(ch4g != ptr->old_ch4g) ||
(ch4b != ptr->old_ch4b)) {
ptr->old_ch4f = ch4f;
ptr->old_ch4g = ch4g;
ptr->old_ch4b = ch4b;
eq_set_params(&filters[4], ch4f, ch4g, ch4b, fs);
}
if ((ch5f != ptr->old_ch5f) ||
(ch5g != ptr->old_ch5g) ||
(ch5b != ptr->old_ch5b)) {
ptr->old_ch5f = ch5f;
ptr->old_ch5g = ch5g;
ptr->old_ch5b = ch5b;
eq_set_params(&filters[5], ch5f, ch5g, ch5b, fs);
}
if ((ch6f != ptr->old_ch6f) ||
(ch6g != ptr->old_ch6g) ||
(ch6b != ptr->old_ch6b)) {
ptr->old_ch6f = ch6f;
ptr->old_ch6g = ch6g;
ptr->old_ch6b = ch6b;
eq_set_params(&filters[6], ch6f, ch6g, ch6b, fs);
}
if ((ch7f != ptr->old_ch7f) ||
(ch7g != ptr->old_ch7g) ||
(ch7b != ptr->old_ch7b)) {
ptr->old_ch7f = ch7f;
ptr->old_ch7g = ch7g;
ptr->old_ch7b = ch7b;
eq_set_params(&filters[7], ch7f, ch7g, ch7b, fs);
}
for (pos = 0; pos < sample_count; pos++) {
samp = input[pos];
if (ch0g != 0.0f)
samp = biquad_run(&filters[0], samp);
if (ch1g != 0.0f)
samp = biquad_run(&filters[1], samp);
if (ch2g != 0.0f)
samp = biquad_run(&filters[2], samp);
if (ch3g != 0.0f)
samp = biquad_run(&filters[3], samp);
if (ch4g != 0.0f)
samp = biquad_run(&filters[4], samp);
if (ch5g != 0.0f)
samp = biquad_run(&filters[5], samp);
if (ch6g != 0.0f)
samp = biquad_run(&filters[6], samp);
if (ch7g != 0.0f)
samp = biquad_run(&filters[7], samp);
output[pos] += ptr->run_adding_gain * samp;
}
}
void
__attribute__((constructor)) tap_init() {
char **port_names;
LADSPA_PortDescriptor *port_descriptors;
LADSPA_PortRangeHint *port_range_hints;
eqDescriptor =
(LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));
if (eqDescriptor) {
eqDescriptor->UniqueID = ID_MONO;
eqDescriptor->Label = "tap_equalizer_bw";
eqDescriptor->Properties = 0;
eqDescriptor->Name = "TAP Equalizer/BW";
eqDescriptor->Maker = "Tom Szilagyi";
eqDescriptor->Copyright = "GPL";
eqDescriptor->PortCount = PORTCOUNT_MONO;
port_descriptors =
(LADSPA_PortDescriptor *)calloc(PORTCOUNT_MONO,
sizeof(LADSPA_PortDescriptor));
eqDescriptor->PortDescriptors =
(const LADSPA_PortDescriptor *)port_descriptors;
port_range_hints =
(LADSPA_PortRangeHint *)calloc(PORTCOUNT_MONO,
sizeof(LADSPA_PortRangeHint));
eqDescriptor->PortRangeHints =
(const LADSPA_PortRangeHint *)port_range_hints;
port_names = (char **)calloc(PORTCOUNT_MONO, sizeof(char*));
eqDescriptor->PortNames =
(const char **)port_names;
/* Parameters for CH0 freq [Hz] */
port_descriptors[EQ_CH0F] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH0F] =
"Band 1 Freq [Hz]";
port_range_hints[EQ_CH0F].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_LOW;
port_range_hints[EQ_CH0F].LowerBound = 40;
port_range_hints[EQ_CH0F].UpperBound = 280;
/* Parameters for CH0 gain [dB] */
port_descriptors[EQ_CH0G] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH0G] =
"Band 1 Gain [dB]";
port_range_hints[EQ_CH0G].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0;
port_range_hints[EQ_CH0G].LowerBound = -50;
port_range_hints[EQ_CH0G].UpperBound = +20;
/* Parameters for CH0 bandwidth [octaves] */
port_descriptors[EQ_CH0B] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH0B] =
"Band 1 Bandwidth [octaves]";
port_range_hints[EQ_CH0B].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_1;
port_range_hints[EQ_CH0B].LowerBound = 0.1f;
port_range_hints[EQ_CH0B].UpperBound = 5.0f;
/* Parameters for CH1 freq [Hz] */
port_descriptors[EQ_CH1F] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH1F] =
"Band 2 Freq [Hz]";
port_range_hints[EQ_CH1F].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_LOW;
port_range_hints[EQ_CH1F].LowerBound = 100;
port_range_hints[EQ_CH1F].UpperBound = 500;
/* Parameters for CH1 gain [dB] */
port_descriptors[EQ_CH1G] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH1G] =
"Band 2 Gain [dB]";
port_range_hints[EQ_CH1G].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0;
port_range_hints[EQ_CH1G].LowerBound = -50;
port_range_hints[EQ_CH1G].UpperBound = +20;
/* Parameters for CH1 bandwidth [octaves] */
port_descriptors[EQ_CH1B] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH1B] =
"Band 2 Bandwidth [octaves]";
port_range_hints[EQ_CH1B].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_1;
port_range_hints[EQ_CH1B].LowerBound = 0.1f;
port_range_hints[EQ_CH1B].UpperBound = 5.0f;
/* Parameters for CH2 freq [Hz] */
port_descriptors[EQ_CH2F] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH2F] =
"Band 3 Freq [Hz]";
port_range_hints[EQ_CH2F].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_LOW;
port_range_hints[EQ_CH2F].LowerBound = 200;
port_range_hints[EQ_CH2F].UpperBound = 1000;
/* Parameters for CH2 gain [dB] */
port_descriptors[EQ_CH2G] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH2G] =
"Band 3 Gain [dB]";
port_range_hints[EQ_CH2G].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0;
port_range_hints[EQ_CH2G].LowerBound = -50;
port_range_hints[EQ_CH2G].UpperBound = +20;
/* Parameters for CH2 bandwidth [octaves] */
port_descriptors[EQ_CH2B] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH2B] =
"Band 3 Bandwidth [octaves]";
port_range_hints[EQ_CH2B].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_1;
port_range_hints[EQ_CH2B].LowerBound = 0.1f;
port_range_hints[EQ_CH2B].UpperBound = 5.0f;
/* Parameters for CH3 freq [Hz] */
port_descriptors[EQ_CH3F] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH3F] =
"Band 4 Freq [Hz]";
port_range_hints[EQ_CH3F].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_LOW;
port_range_hints[EQ_CH3F].LowerBound = 400;
port_range_hints[EQ_CH3F].UpperBound = 2800;
/* Parameters for CH3 gain [dB] */
port_descriptors[EQ_CH3G] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH3G] =
"Band 4 Gain [dB]";
port_range_hints[EQ_CH3G].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0;
port_range_hints[EQ_CH3G].LowerBound = -50;
port_range_hints[EQ_CH3G].UpperBound = +20;
/* Parameters for CH3 bandwidth [octaves] */
port_descriptors[EQ_CH3B] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH3B] =
"Band 4 Bandwidth [octaves]";
port_range_hints[EQ_CH3B].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_1;
port_range_hints[EQ_CH3B].LowerBound = 0.1f;
port_range_hints[EQ_CH3B].UpperBound = 5.0f;
/* Parameters for CH4 freq [Hz] */
port_descriptors[EQ_CH4F] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH4F] =
"Band 5 Freq [Hz]";
port_range_hints[EQ_CH4F].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_MIDDLE;
port_range_hints[EQ_CH4F].LowerBound = 1000;
port_range_hints[EQ_CH4F].UpperBound = 5000;
/* Parameters for CH4 gain [dB] */
port_descriptors[EQ_CH4G] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH4G] =
"Band 5 Gain [dB]";
port_range_hints[EQ_CH4G].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0;
port_range_hints[EQ_CH4G].LowerBound = -50;
port_range_hints[EQ_CH4G].UpperBound = +20;
/* Parameters for CH4 bandwidth [octaves] */
port_descriptors[EQ_CH4B] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH4B] =
"Band 5 Bandwidth [octaves]";
port_range_hints[EQ_CH4B].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_1;
port_range_hints[EQ_CH4B].LowerBound = 0.1f;
port_range_hints[EQ_CH4B].UpperBound = 5.0f;
/* Parameters for CH5 freq [Hz] */
port_descriptors[EQ_CH5F] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH5F] =
"Band 6 Freq [Hz]";
port_range_hints[EQ_CH5F].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_MIDDLE;
port_range_hints[EQ_CH5F].LowerBound = 3000;
port_range_hints[EQ_CH5F].UpperBound = 9000;
/* Parameters for CH5 gain [dB] */
port_descriptors[EQ_CH5G] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH5G] =
"Band 6 Gain [dB]";
port_range_hints[EQ_CH5G].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0;
port_range_hints[EQ_CH5G].LowerBound = -50;
port_range_hints[EQ_CH5G].UpperBound = +20;
/* Parameters for CH5 bandwidth [octaves] */
port_descriptors[EQ_CH5B] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH5B] =
"Band 6 Bandwidth [octaves]";
port_range_hints[EQ_CH5B].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_1;
port_range_hints[EQ_CH5B].LowerBound = 0.1f;
port_range_hints[EQ_CH5B].UpperBound = 5.0f;
/* Parameters for CH6 freq [Hz] */
port_descriptors[EQ_CH6F] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH6F] =
"Band 7 Freq [Hz]";
port_range_hints[EQ_CH6F].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_MIDDLE;
port_range_hints[EQ_CH6F].LowerBound = 6000;
port_range_hints[EQ_CH6F].UpperBound = 18000;
/* Parameters for CH6 gain [dB] */
port_descriptors[EQ_CH6G] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH6G] =
"Band 7 Gain [dB]";
port_range_hints[EQ_CH6G].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0;
port_range_hints[EQ_CH6G].LowerBound = -50;
port_range_hints[EQ_CH6G].UpperBound = +20;
/* Parameters for CH6 bandwidth [octaves] */
port_descriptors[EQ_CH6B] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH6B] =
"Band 7 Bandwidth [octaves]";
port_range_hints[EQ_CH6B].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_1;
port_range_hints[EQ_CH6B].LowerBound = 0.1f;
port_range_hints[EQ_CH6B].UpperBound = 5.0f;
/* Parameters for CH7 freq [Hz] */
port_descriptors[EQ_CH7F] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH7F] =
"Band 8 Freq [Hz]";
port_range_hints[EQ_CH7F].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_MIDDLE;
port_range_hints[EQ_CH7F].LowerBound = 10000;
port_range_hints[EQ_CH7F].UpperBound = 20000;
/* Parameters for CH7 gain [dB] */
port_descriptors[EQ_CH7G] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH7G] =
"Band 8 Gain [dB]";
port_range_hints[EQ_CH7G].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0;
port_range_hints[EQ_CH7G].LowerBound = -50;
port_range_hints[EQ_CH7G].UpperBound = +20;
/* Parameters for CH7 bandwidth [octaves] */
port_descriptors[EQ_CH7B] =
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
port_names[EQ_CH7B] =
"Band 8 Bandwidth [octaves]";
port_range_hints[EQ_CH7B].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_1;
port_range_hints[EQ_CH7B].LowerBound = 0.1f;
port_range_hints[EQ_CH7B].UpperBound = 5.0f;
/* Parameters for Input */
port_descriptors[EQ_INPUT] =
LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
port_names[EQ_INPUT] =
"Input";
port_range_hints[EQ_INPUT].HintDescriptor = 0;
/* Parameters for Output */
port_descriptors[EQ_OUTPUT] =
LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
port_names[EQ_OUTPUT] =
"Output";
port_range_hints[EQ_OUTPUT].HintDescriptor = 0;
eqDescriptor->activate = activate_eq;
eqDescriptor->cleanup = cleanup_eq;
eqDescriptor->connect_port = connectPort_eq;
eqDescriptor->deactivate = NULL;
eqDescriptor->instantiate = instantiate_eq;
eqDescriptor->run = run_eq;
eqDescriptor->run_adding = run_adding_eq;
eqDescriptor->set_run_adding_gain = set_run_adding_gain;
}
}
void
__attribute__((destructor)) tap_fini() {
if (eqDescriptor) {
free((LADSPA_PortDescriptor *)eqDescriptor->PortDescriptors);
free((char **)eqDescriptor->PortNames);
free((LADSPA_PortRangeHint *)eqDescriptor->PortRangeHints);
free(eqDescriptor);
}
}
|