Spaces:
Running
Running
Commit
·
9e07bd7
1
Parent(s):
6bd893f
feat: add ping-pong delay controls with adjustable parameters
Browse files
app.py
CHANGED
|
@@ -596,9 +596,57 @@ with gr.Blocks() as demo:
|
|
| 596 |
comp_plot = gr.Plot(
|
| 597 |
plot_comp(), label="Compressor Curve", elem_id="comp-plot"
|
| 598 |
)
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 602 |
reverb_plot = gr.Plot(
|
| 603 |
plot_reverb(), label="Reverb Tone Correction PEQ", elem_id="reverb-plot"
|
| 604 |
)
|
|
@@ -674,6 +722,37 @@ with gr.Blocks() as demo:
|
|
| 674 |
outputs=update_pc_outputs + [json_output, comp_plot],
|
| 675 |
)
|
| 676 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 677 |
render_button.click(
|
| 678 |
# lambda *args: (
|
| 679 |
# lambda x: (
|
|
@@ -714,6 +793,12 @@ with gr.Blocks() as demo:
|
|
| 714 |
comp.params.exp_ratio.item(),
|
| 715 |
coef2ms(comp.params.at, 44100).item(),
|
| 716 |
coef2ms(comp.params.rt, 44100).item(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 717 |
]
|
| 718 |
update_fx_outputs = [
|
| 719 |
pk1_freq,
|
|
@@ -737,6 +822,12 @@ with gr.Blocks() as demo:
|
|
| 737 |
exp_ratio,
|
| 738 |
attack_time,
|
| 739 |
release_time,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 740 |
]
|
| 741 |
update_plots = lambda: [
|
| 742 |
plot_eq(),
|
|
|
|
| 596 |
comp_plot = gr.Plot(
|
| 597 |
plot_comp(), label="Compressor Curve", elem_id="comp-plot"
|
| 598 |
)
|
| 599 |
+
|
| 600 |
+
_ = gr.Markdown("## Ping-Pong Delay")
|
| 601 |
+
with gr.Row():
|
| 602 |
+
with gr.Column():
|
| 603 |
+
delay = fx[7].effects[0]
|
| 604 |
+
delay_time = gr.Slider(
|
| 605 |
+
minimum=100,
|
| 606 |
+
maximum=1000,
|
| 607 |
+
value=delay.params.delay.item(),
|
| 608 |
+
interactive=True,
|
| 609 |
+
label="Delay Time (ms)",
|
| 610 |
+
)
|
| 611 |
+
feedback = gr.Slider(
|
| 612 |
+
minimum=0,
|
| 613 |
+
maximum=1,
|
| 614 |
+
value=delay.params.feedback.item(),
|
| 615 |
+
interactive=True,
|
| 616 |
+
label="Feedback",
|
| 617 |
+
)
|
| 618 |
+
delay_gain = gr.Slider(
|
| 619 |
+
minimum=-80,
|
| 620 |
+
maximum=0,
|
| 621 |
+
value=delay.params.gain.log10().item() * 20,
|
| 622 |
+
interactive=True,
|
| 623 |
+
label="Gain (dB)",
|
| 624 |
+
)
|
| 625 |
+
odd_pan = gr.Slider(
|
| 626 |
+
minimum=-100,
|
| 627 |
+
maximum=100,
|
| 628 |
+
value=delay.odd_pan.params.pan.item() * 200 - 100,
|
| 629 |
+
interactive=True,
|
| 630 |
+
label="Odd Delay Pan",
|
| 631 |
+
)
|
| 632 |
+
even_pan = gr.Slider(
|
| 633 |
+
minimum=-100,
|
| 634 |
+
maximum=100,
|
| 635 |
+
value=delay.even_pan.params.pan.item() * 200 - 100,
|
| 636 |
+
interactive=True,
|
| 637 |
+
label="Even Delay Pan",
|
| 638 |
+
)
|
| 639 |
+
delay_lp_freq = gr.Slider(
|
| 640 |
+
minimum=200,
|
| 641 |
+
maximum=16000,
|
| 642 |
+
value=delay.eq.params.freq.item(),
|
| 643 |
+
interactive=True,
|
| 644 |
+
label="Low Pass Frequency (Hz)",
|
| 645 |
+
)
|
| 646 |
+
with gr.Column():
|
| 647 |
+
delay_plot = gr.Plot(
|
| 648 |
+
plot_delay(), label="Delay Frequency Response", elem_id="delay-plot"
|
| 649 |
+
)
|
| 650 |
reverb_plot = gr.Plot(
|
| 651 |
plot_reverb(), label="Reverb Tone Correction PEQ", elem_id="reverb-plot"
|
| 652 |
)
|
|
|
|
| 722 |
outputs=update_pc_outputs + [json_output, comp_plot],
|
| 723 |
)
|
| 724 |
|
| 725 |
+
for m, f, s, attr_name, update_plot in zip(
|
| 726 |
+
[delay] * 2 + [delay.eq] + [delay, delay.odd_pan, delay.even_pan],
|
| 727 |
+
[update_param] * 3
|
| 728 |
+
+ [
|
| 729 |
+
lambda m, a, v: update_param(m, a, 10 ** (v / 20)),
|
| 730 |
+
lambda m, a, v: update_param(m, a, (v + 100) / 200),
|
| 731 |
+
lambda m, a, v: update_param(m, a, (v + 100) / 200),
|
| 732 |
+
],
|
| 733 |
+
[delay_time, feedback, delay_lp_freq, delay_gain, odd_pan, even_pan],
|
| 734 |
+
["delay", "feedback", "freq", "gain", "pan", "pan"],
|
| 735 |
+
[True] * 4 + [False] * 2,
|
| 736 |
+
):
|
| 737 |
+
s.input(
|
| 738 |
+
lambda *args, f=f, m=m, attr_name=attr_name, update_plot=update_plot: chain_functions(
|
| 739 |
+
lambda args: (f(m, attr_name, args[0]), args[1]),
|
| 740 |
+
lambda args: (fx2z(), args[1]),
|
| 741 |
+
lambda args: args[1],
|
| 742 |
+
lambda i: (
|
| 743 |
+
update_pc(i)
|
| 744 |
+
+ [model2json()]
|
| 745 |
+
+ ([plot_delay()] if update_plot else [])
|
| 746 |
+
),
|
| 747 |
+
)(
|
| 748 |
+
args
|
| 749 |
+
),
|
| 750 |
+
inputs=[s, extra_pc_dropdown],
|
| 751 |
+
outputs=update_pc_outputs
|
| 752 |
+
+ [json_output]
|
| 753 |
+
+ ([delay_plot] if update_plot else []),
|
| 754 |
+
)
|
| 755 |
+
|
| 756 |
render_button.click(
|
| 757 |
# lambda *args: (
|
| 758 |
# lambda x: (
|
|
|
|
| 793 |
comp.params.exp_ratio.item(),
|
| 794 |
coef2ms(comp.params.at, 44100).item(),
|
| 795 |
coef2ms(comp.params.rt, 44100).item(),
|
| 796 |
+
delay.params.delay.item(),
|
| 797 |
+
delay.params.feedback.item(),
|
| 798 |
+
delay.params.gain.log10().item() * 20,
|
| 799 |
+
delay.eq.params.freq.item(),
|
| 800 |
+
delay.odd_pan.params.pan.item() * 200 - 100,
|
| 801 |
+
delay.even_pan.params.pan.item() * 200 - 100,
|
| 802 |
]
|
| 803 |
update_fx_outputs = [
|
| 804 |
pk1_freq,
|
|
|
|
| 822 |
exp_ratio,
|
| 823 |
attack_time,
|
| 824 |
release_time,
|
| 825 |
+
delay_time,
|
| 826 |
+
feedback,
|
| 827 |
+
delay_gain,
|
| 828 |
+
delay_lp_freq,
|
| 829 |
+
odd_pan,
|
| 830 |
+
even_pan,
|
| 831 |
]
|
| 832 |
update_plots = lambda: [
|
| 833 |
plot_eq(),
|