2 * Copyright (C) 2016 Damien Zammit <damien@zamaudio.com>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
21 #include <cairo/cairo.h>
22 #include "ardour/lv2_extensions.h"
25 #include "lv2/lv2plug.in/ns/lv2core/lv2.h"
27 #define ACOMP_URI "urn:ardour:a-comp"
28 #define ACOMP_STEREO_URI "urn:ardour:a-comp#stereo"
31 # define M_PI 3.14159265358979323846
36 #define isfinite_local(val) (bool)_finite((double)val)
38 #define isfinite_local isfinite
89 LV2_Inline_Display_Image_Surface surf;
91 cairo_surface_t* display;
92 LV2_Inline_Display* queue_draw;
95 /* ports pointers are only valid during run so we'll
96 * have to cache them for the display, besides
97 * we do want to check for changes
112 instantiate(const LV2_Descriptor* descriptor,
114 const char* bundle_path,
115 const LV2_Feature* const* features)
117 AComp* acomp = (AComp*)calloc(1, sizeof(AComp));
119 for (int i=0; features[i]; ++i) {
121 if (!strcmp(features[i]->URI, LV2_INLINEDISPLAY__queue_draw)) {
122 acomp->queue_draw = (LV2_Inline_Display*) features[i]->data;
128 acomp->old_yl=acomp->old_y1=acomp->old_yg=0.f;
129 acomp->tau = (1.0 - exp (-2.f * M_PI * 25.f / acomp->srate));
131 acomp->need_expose = true;
132 acomp->v_lvl_out = -70.f;
135 return (LV2_Handle)acomp;
140 connect_port(LV2_Handle instance,
144 AComp* acomp = (AComp*)instance;
146 switch ((PortIndex)port) {
148 acomp->attack = (float*)data;
151 acomp->release = (float*)data;
154 acomp->knee = (float*)data;
157 acomp->ratio = (float*)data;
159 case ACOMP_THRESHOLD:
160 acomp->thresdb = (float*)data;
163 acomp->makeup = (float*)data;
166 acomp->gainr = (float*)data;
169 acomp->outlevel = (float*)data;
171 case ACOMP_SIDECHAIN:
172 acomp->sidechain = (float*)data;
175 acomp->enable = (float*)data;
183 connect_mono(LV2_Handle instance,
187 AComp* acomp = (AComp*)instance;
188 connect_port (instance, port, data);
190 switch ((PortIndex)port) {
192 acomp->input0 = (float*)data;
195 acomp->sc = (float*)data;
198 acomp->output0 = (float*)data;
206 connect_stereo(LV2_Handle instance,
210 AComp* acomp = (AComp*)instance;
211 connect_port (instance, port, data);
213 switch ((PortIndex)port) {
215 acomp->input0 = (float*)data;
218 acomp->input1 = (float*)data;
221 acomp->sc = (float*)data;
224 acomp->output0 = (float*)data;
227 acomp->output1 = (float*)data;
234 // Force already-denormal float value to zero
236 sanitize_denormal(float value) {
237 if (!isnormal(value)) {
245 return (exp(gdb/20.f*log(10.f)));
250 return (20.f*log10(g));
254 activate(LV2_Handle instance)
256 AComp* acomp = (AComp*)instance;
258 *(acomp->gainr) = 0.0f;
259 *(acomp->outlevel) = -45.0f;
260 acomp->old_yl=acomp->old_y1=acomp->old_yg=0.f;
264 run_mono(LV2_Handle instance, uint32_t n_samples)
266 AComp* acomp = (AComp*)instance;
268 const float* const input = acomp->input0;
269 const float* const sc = acomp->sc;
270 float* const output = acomp->output0;
272 float srate = acomp->srate;
273 float width = (6.f * *(acomp->knee)) + 0.01;
275 float attack_coeff = exp(-1000.f/(*(acomp->attack) * srate));
276 float release_coeff = exp(-1000.f/(*(acomp->release) * srate));
279 float lgaininp = 0.f;
281 float Lxg, Lxl, Lyg, Lyl, Ly1;
282 int usesidechain = (*(acomp->sidechain) <= 0.f) ? 0 : 1;
288 float ratio = *acomp->ratio;
289 float thresdb = *acomp->thresdb;
290 float makeup = *acomp->makeup;
291 float makeup_target = from_dB(makeup);
292 float makeup_gain = acomp->makeup_gain;
294 const float tau = acomp->tau;
296 if (*acomp->enable <= 0) {
304 if (acomp->v_knee != *acomp->knee) {
305 acomp->v_knee = *acomp->knee;
306 acomp->need_expose = true;
309 if (acomp->v_ratio != ratio) {
310 acomp->v_ratio = ratio;
311 acomp->need_expose = true;
314 if (acomp->v_thresdb != thresdb) {
315 acomp->v_thresdb = thresdb;
316 acomp->need_expose = true;
319 if (acomp->v_makeup != makeup) {
320 acomp->v_makeup = makeup;
321 acomp->need_expose = true;
326 acomp->v_gainr = 0.0;
328 for (i = 0; i < n_samples; i++) {
331 ingain = usesidechain ? fabs(sc0) : fabs(in0);
332 in_peak = fmaxf (in_peak, ingain);
334 Lxg = (ingain==0.f) ? -160.f : to_dB(ingain);
335 Lxg = sanitize_denormal(Lxg);
338 if (2.f*(Lxg-thresdb) < -width) {
340 } else if (2.f*(Lxg-thresdb) > width) {
341 Lyg = thresdb + (Lxg-thresdb)/ratio;
342 Lyg = sanitize_denormal(Lyg);
344 Lyg = Lxg + (1.f/ratio-1.f)*(Lxg-thresdb+width/2.f)*(Lxg-thresdb+width/2.f)/(2.f*width);
349 acomp->old_y1 = sanitize_denormal(acomp->old_y1);
350 acomp->old_yl = sanitize_denormal(acomp->old_yl);
351 Ly1 = fmaxf(Lxl, release_coeff * acomp->old_y1+(1.f-release_coeff)*Lxl);
352 Lyl = attack_coeff * acomp->old_yl+(1.f-attack_coeff)*Ly1;
353 Ly1 = sanitize_denormal(Ly1);
354 Lyl = sanitize_denormal(Lyl);
357 Lgain = from_dB(cdb);
359 *(acomp->gainr) = Lyl;
360 if (Lyl > acomp->v_gainr) {
361 acomp->v_gainr = Lyl;
364 lgaininp = in0 * Lgain;
366 makeup_gain += tau * (makeup_target - makeup_gain) + 1e-12;
367 output[i] = lgaininp * makeup_gain;
369 max = (fabsf(output[i]) > max) ? fabsf(output[i]) : sanitize_denormal(max);
371 // TODO re-use local variables on stack
372 // store values back to acomp at the end of the inner-loop
378 *(acomp->outlevel) = (max < 0.0056f) ? -45.f : to_dB(max);
379 acomp->makeup_gain = makeup_gain;
382 const float old_v_lv1 = acomp->v_lv1;
383 const float old_v_lvl = acomp->v_lvl;
384 const float tot_rel_c = exp(-1000.f/(*(acomp->release) * srate) * n_samples);
385 const float tot_atk_c = exp(-1000.f/(*(acomp->attack) * srate) * n_samples);
386 acomp->v_lv1 = fmaxf (in_peak, tot_rel_c*old_v_lv1 + (1.f-tot_rel_c)*in_peak);
387 acomp->v_lvl = tot_atk_c*old_v_lvl + (1.f-tot_atk_c)*acomp->v_lv1;
389 if (!isfinite_local (acomp->v_lvl)) {
392 const float v_lvl_in = (acomp->v_lvl < 0.001f) ? -60.f : to_dB(acomp->v_lvl);
393 const float v_lvl_out = (max < 0.001f) ? -60.f : to_dB(max);
394 if (fabsf (acomp->v_lvl_out - v_lvl_out) >= 1 || fabsf (acomp->v_lvl_in - v_lvl_in) >= 1) {
396 acomp->need_expose = true;
397 acomp->v_lvl_in = v_lvl_in;
398 const float relax_coef = exp(-(float)n_samples/srate);
399 acomp->v_lvl_out = fmaxf (v_lvl_out, relax_coef*acomp->v_lvl_out + (1.f-relax_coef)*v_lvl_out);
401 if (acomp->need_expose && acomp->queue_draw) {
402 acomp->need_expose = false;
403 acomp->queue_draw->queue_draw (acomp->queue_draw->handle);
409 run_stereo(LV2_Handle instance, uint32_t n_samples)
411 AComp* acomp = (AComp*)instance;
413 const float* const input0 = acomp->input0;
414 const float* const input1 = acomp->input1;
415 const float* const sc = acomp->sc;
416 float* const output0 = acomp->output0;
417 float* const output1 = acomp->output1;
419 float srate = acomp->srate;
420 float width = (6.f * *(acomp->knee)) + 0.01;
422 float attack_coeff = exp(-1000.f/(*(acomp->attack) * srate));
423 float release_coeff = exp(-1000.f/(*(acomp->release) * srate));
426 float lgaininp = 0.f;
427 float rgaininp = 0.f;
429 float Lxg, Lxl, Lyg, Lyl, Ly1;
430 int usesidechain = (*(acomp->sidechain) <= 0.f) ? 0 : 1;
438 float ratio = *acomp->ratio;
439 float thresdb = *acomp->thresdb;
440 float makeup = *acomp->makeup;
441 float makeup_target = from_dB(makeup);
442 float makeup_gain = acomp->makeup_gain;
444 const float tau = acomp->tau;
446 if (*acomp->enable <= 0) {
454 if (acomp->v_knee != *acomp->knee) {
455 acomp->v_knee = *acomp->knee;
456 acomp->need_expose = true;
459 if (acomp->v_ratio != ratio) {
460 acomp->v_ratio = ratio;
461 acomp->need_expose = true;
464 if (acomp->v_thresdb != thresdb) {
465 acomp->v_thresdb = thresdb;
466 acomp->need_expose = true;
469 if (acomp->v_makeup != makeup) {
470 acomp->v_makeup = makeup;
471 acomp->need_expose = true;
476 acomp->v_gainr = 0.0;
478 for (i = 0; i < n_samples; i++) {
482 maxabslr = fmaxf(fabs(in0), fabs(in1));
483 ingain = usesidechain ? fabs(sc0) : maxabslr;
484 in_peak = fmaxf (in_peak, ingain);
486 Lxg = (ingain==0.f) ? -160.f : to_dB(ingain);
487 Lxg = sanitize_denormal(Lxg);
490 if (2.f*(Lxg-thresdb) < -width) {
492 } else if (2.f*(Lxg-thresdb) > width) {
493 Lyg = thresdb + (Lxg-thresdb)/ratio;
494 Lyg = sanitize_denormal(Lyg);
496 Lyg = Lxg + (1.f/ratio-1.f)*(Lxg-thresdb+width/2.f)*(Lxg-thresdb+width/2.f)/(2.f*width);
501 acomp->old_y1 = sanitize_denormal(acomp->old_y1);
502 acomp->old_yl = sanitize_denormal(acomp->old_yl);
503 Ly1 = fmaxf(Lxl, release_coeff * acomp->old_y1+(1.f-release_coeff)*Lxl);
504 Lyl = attack_coeff * acomp->old_yl+(1.f-attack_coeff)*Ly1;
505 Ly1 = sanitize_denormal(Ly1);
506 Lyl = sanitize_denormal(Lyl);
509 Lgain = from_dB(cdb);
511 *(acomp->gainr) = Lyl;
512 if (Lyl > acomp->v_gainr) {
513 acomp->v_gainr = Lyl;
516 lgaininp = in0 * Lgain;
517 rgaininp = in1 * Lgain;
519 makeup_gain += tau * (makeup_target - makeup_gain) + 1e-12;
521 output0[i] = lgaininp * makeup_gain;
522 output1[i] = rgaininp * makeup_gain;
524 max = (fmaxf(fabs(output0[i]), fabs(output1[i])) > max) ? fmaxf(fabs(output0[i]), fabs(output1[i])) : sanitize_denormal(max);
526 // TODO re-use local variables on stack
527 // store values back to acomp at the end of the inner-loop
533 *(acomp->outlevel) = (max < 0.0056f) ? -45.f : to_dB(max);
534 acomp->makeup_gain = makeup_gain;
537 const float old_v_lv1 = acomp->v_lv1;
538 const float old_v_lvl = acomp->v_lvl;
539 const float tot_rel_c = exp(-1000.f/(*(acomp->release) * srate) * n_samples);
540 const float tot_atk_c = exp(-1000.f/(*(acomp->attack) * srate) * n_samples);
541 acomp->v_lv1 = fmaxf (in_peak, tot_rel_c*old_v_lv1 + (1.f-tot_rel_c)*in_peak);
542 acomp->v_lvl = tot_atk_c*old_v_lvl + (1.f-tot_atk_c)*acomp->v_lv1;
543 if (!isfinite_local (acomp->v_lvl)) {
546 const float v_lvl_in = (acomp->v_lvl < 0.001f) ? -60.f : to_dB(acomp->v_lvl);
547 const float v_lvl_out = (max < 0.001f) ? -60.f : to_dB(max);
548 if (fabsf (acomp->v_lvl_out - v_lvl_out) >= 1 || fabsf (acomp->v_lvl_in - v_lvl_in) >= 1) {
550 acomp->need_expose = true;
551 acomp->v_lvl_in = v_lvl_in;
552 const float relax_coef = exp(-2.0*n_samples/srate);
553 acomp->v_lvl_out = fmaxf (v_lvl_out, relax_coef*acomp->v_lvl_out + (1.f-relax_coef)*v_lvl_out);
555 if (acomp->need_expose && acomp->queue_draw) {
556 acomp->need_expose = false;
557 acomp->queue_draw->queue_draw (acomp->queue_draw->handle);
563 deactivate(LV2_Handle instance)
569 cleanup(LV2_Handle instance)
572 AComp* acomp = (AComp*)instance;
573 if (acomp->display) {
574 cairo_surface_destroy (acomp->display);
583 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
588 comp_curve (const AComp* self, float xg) {
589 const float knee = self->v_knee;
590 const float ratio = self->v_ratio;
591 const float thresdb = self->v_thresdb;
592 const float makeup = self->v_makeup;
594 const float width = 6.f * knee + 0.01f;
597 if (2.f * (xg - thresdb) < -width) {
599 } else if (2.f * (xg - thresdb) > width) {
600 yg = thresdb + (xg - thresdb) / ratio;
602 yg = xg + (1.f / ratio - 1.f ) * (xg - thresdb + width / 2.f) * (xg - thresdb + width / 2.f) / (2.f * width);
611 render_inline_full (cairo_t* cr, const AComp* self)
613 const float w = self->w;
614 const float h = self->h;
616 const float makeup_thres = self->v_thresdb + self->v_makeup;
619 cairo_rectangle (cr, 0, 0, w, h);
620 cairo_set_source_rgba (cr, .2, .2, .2, 1.0);
623 cairo_set_line_width(cr, 1.0);
625 // draw grid 10dB steps
626 const double dash1[] = {1, 2};
627 const double dash2[] = {1, 3};
629 cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
630 cairo_set_dash(cr, dash2, 2, 2);
631 cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.5);
633 for (uint32_t d = 1; d < 7; ++d) {
634 const float x = -.5 + floorf (w * (d * 10.f / 70.f));
635 const float y = -.5 + floorf (h * (d * 10.f / 70.f));
637 cairo_move_to (cr, x, 0);
638 cairo_line_to (cr, x, h);
641 cairo_move_to (cr, 0, y);
642 cairo_line_to (cr, w, y);
645 cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 1.0);
646 cairo_set_dash(cr, dash1, 2, 2);
647 if (self->v_thresdb < 0) {
648 const float y = -.5 + floorf (h * ((makeup_thres - 10.f) / -70.f));
649 cairo_move_to (cr, 0, y);
650 cairo_line_to (cr, w, y);
654 cairo_move_to (cr, 0, h);
655 cairo_line_to (cr, w, 0);
660 cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.5);
661 const float x = -.5 + floorf (w * (60.f / 70.f));
662 const float y = -.5 + floorf (h * (10.f / 70.f));
663 cairo_move_to (cr, x, 0);
664 cairo_line_to (cr, x, h);
666 cairo_move_to (cr, 0, y);
667 cairo_line_to (cr, w, y);
672 const float x = -.5 + floorf (w * (62.5f / 70.f));
673 const float y = -.5 + floorf (h * (10.0f / 70.f));
674 const float wd = floorf (w * (5.f / 70.f));
675 const float ht = floorf (h * (55.f / 70.f));
676 cairo_rectangle (cr, x, y, wd, ht);
679 const float h_gr = fminf (ht, floorf (h * self->v_gainr / 70.f));
680 cairo_set_source_rgba (cr, 0.95, 0.0, 0.0, 1.0);
681 cairo_rectangle (cr, x, y, wd, h_gr);
683 cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.5);
684 cairo_rectangle (cr, x, y, wd, ht);
685 cairo_set_source_rgba (cr, 0.75, 0.75, 0.75, 1.0);
690 cairo_set_source_rgba (cr, .8, .8, .8, 1.0);
691 cairo_move_to (cr, 0, h);
693 for (uint32_t x = 0; x < w; ++x) {
695 const float x_db = 70.f * (-1.f + x / (float)w) + 10.f;
696 const float y_db = comp_curve (self, x_db) - 10.f;
697 const float y = h * (y_db / -70.f);
698 cairo_line_to (cr, x, y);
700 cairo_stroke_preserve (cr);
702 cairo_line_to (cr, w, h);
703 cairo_close_path (cr);
706 // draw signal level & reduction/gradient
707 const float top = comp_curve (self, 0) - 10.f;
708 cairo_pattern_t* pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, h);
709 if (top > makeup_thres - 10.f) {
710 cairo_pattern_add_color_stop_rgba (pat, 0.0, 0.8, 0.1, 0.1, 0.5);
711 cairo_pattern_add_color_stop_rgba (pat, top / -70.f, 0.8, 0.1, 0.1, 0.5);
713 if (self->v_knee > 0) {
714 cairo_pattern_add_color_stop_rgba (pat, ((makeup_thres -10.f) / -70.f), 0.7, 0.7, 0.2, 0.5);
715 cairo_pattern_add_color_stop_rgba (pat, ((makeup_thres - self->v_knee - 10.f) / -70.f), 0.5, 0.5, 0.5, 0.5);
717 cairo_pattern_add_color_stop_rgba (pat, ((makeup_thres - 10.f)/ -70.f), 0.7, 0.7, 0.2, 0.5);
718 cairo_pattern_add_color_stop_rgba (pat, ((makeup_thres - 10.01f) / -70.f), 0.5, 0.5, 0.5, 0.5);
720 cairo_pattern_add_color_stop_rgba (pat, 1.0, 0.5, 0.5, 0.5, 0.5);
722 // maybe cut off at x-position?
723 const float x = w * (self->v_lvl_in + 60) / 70.f;
724 const float y = x + h*self->v_makeup;
725 cairo_rectangle (cr, 0, h - y, x, y);
726 if (self->v_ratio > 1.0) {
727 cairo_set_source (cr, pat);
729 cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.5);
733 cairo_pattern_destroy (pat); // TODO cache pattern
737 render_inline_only_bars (cairo_t* cr, const AComp* self)
739 const float w = self->w;
740 const float h = self->h;
742 cairo_rectangle (cr, 0, 0, w, h);
743 cairo_set_source_rgba (cr, .2, .2, .2, 1.0);
749 const float ht = 0.25f * h;
751 const float x1 = w*0.05;
752 const float wd = w - 2.0f*x1;
754 const float y1 = 0.17*h;
755 const float y2 = h - y1 - ht;
757 cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.5);
759 cairo_rectangle (cr, x1, y1, wd, ht);
762 cairo_rectangle (cr, x1, y2, wd, ht);
765 cairo_set_source_rgba (cr, 0.75, 0.0, 0.0, 1.0);
766 const float w_gr = (self->v_gainr > 60.f) ? wd : wd * self->v_gainr * (1.f/60.f);
767 cairo_rectangle (cr, x1+wd-w_gr, y2, w_gr, ht);
770 if (self->v_lvl_out > -60.f) {
771 if (self->v_lvl_out > 10.f) {
772 cairo_set_source_rgba (cr, 0.75, 0.0, 0.0, 1.0);
773 } else if (self->v_lvl_out > 0.f) {
774 cairo_set_source_rgba (cr, 0.66, 0.66, 0.0, 1.0);
776 cairo_set_source_rgba (cr, 0.0, 0.66, 0.0, 1.0);
778 const float w_g = (self->v_lvl_out > 10.f) ? wd : wd * (60.f+self->v_lvl_out) / 70.f;
779 cairo_rectangle (cr, x1, y1, w_g, ht);
783 cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0);
785 const float tck = 0.33*ht;
787 cairo_set_line_width (cr, .5);
789 for (uint32_t d = 1; d < 7; ++d) {
790 const float x = x1 + (d * wd * (10.f / 70.f));
792 cairo_move_to (cr, x, y1);
793 cairo_line_to (cr, x, y1+tck);
795 cairo_move_to (cr, x, y1+ht);
796 cairo_line_to (cr, x, y1+ht-tck);
798 cairo_move_to (cr, x, y2);
799 cairo_line_to (cr, x, y2+tck);
801 cairo_move_to (cr, x, y2+ht);
802 cairo_line_to (cr, x, y2+ht-tck);
807 const float x_0dB = x1 + wd*(60.f/70.f);
809 cairo_move_to (cr, x_0dB, y1);
810 cairo_line_to (cr, x_0dB, y1+ht);
812 cairo_rectangle (cr, x1, y1, wd, ht);
813 cairo_rectangle (cr, x1, y2, wd, ht);
816 cairo_set_line_width (cr, 2.0);
818 // visualize threshold
819 const float tr = x1 + wd * (60.f+self->v_thresdb) / 70.f;
820 cairo_set_source_rgba (cr, 0.95, 0.95, 0.0, 1.0);
821 cairo_move_to (cr, tr, y1);
822 cairo_line_to (cr, tr, y1+ht);
826 const float reduced_0dB = self->v_thresdb * (1.f - 1.f/self->v_ratio);
827 const float rt = x1 + wd * (60.f+reduced_0dB) / 70.f;
828 cairo_set_source_rgba (cr, 0.95, 0.0, 0.0, 1.0);
829 cairo_move_to (cr, rt, y1);
830 cairo_line_to (cr, rt, y1+ht);
834 static LV2_Inline_Display_Image_Surface *
835 render_inline (LV2_Handle instance, uint32_t w, uint32_t max_h)
837 AComp* self = (AComp*)instance;
839 uint32_t h = MIN (w, max_h);
844 if (!self->display || self->w != w || self->h != h) {
845 if (self->display) cairo_surface_destroy(self->display);
846 self->display = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h);
851 cairo_t* cr = cairo_create (self->display);
854 render_inline_full (cr, self);
856 render_inline_only_bars (cr, self);
861 cairo_surface_flush (self->display);
862 self->surf.width = cairo_image_surface_get_width (self->display);
863 self->surf.height = cairo_image_surface_get_height (self->display);
864 self->surf.stride = cairo_image_surface_get_stride (self->display);
865 self->surf.data = cairo_image_surface_get_data (self->display);
872 extension_data(const char* uri)
875 static const LV2_Inline_Display_Interface display = { render_inline };
876 if (!strcmp(uri, LV2_INLINEDISPLAY__interface)) {
879 if (!strcmp(uri, LV2_INLINEDISPLAY__in_gui)) {
886 static const LV2_Descriptor descriptor_mono = {
897 static const LV2_Descriptor descriptor_stereo = {
909 const LV2_Descriptor*
910 lv2_descriptor(uint32_t index)
914 return &descriptor_mono;
916 return &descriptor_stereo;