File size: 882 Bytes
c983126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import torch

from deepafx_st.processors.autodiff.compressor import Compressor
from deepafx_st.processors.autodiff.peq import ParametricEQ
from deepafx_st.processors.autodiff.fir import FIRFilter


class AutodiffChannel(torch.nn.Module):
    def __init__(self, sample_rate):
        super().__init__()

        self.peq = ParametricEQ(sample_rate)
        self.comp = Compressor(sample_rate)
        self.ports = [self.peq.ports, self.comp.ports]
        self.num_control_params = (
            self.peq.num_control_params + self.comp.num_control_params
        )

    def forward(self, x, p, sample_rate=24000, **kwargs):

        # split params between EQ and Comp.
        p_peq = p[:, : self.peq.num_control_params]
        p_comp = p[:, self.peq.num_control_params :]

        y = self.peq(x, p_peq, sample_rate)
        y = self.comp(y, p_comp, sample_rate)

        return y