Exemplo n.º 1
0
    def __init__(self,
                 fc_stack_layers=2,
                 fc_stack_ch=256,
                 rnn_ch=512,
                 rnn_type='gru',
                 n_harmonics=100,
                 amp_scale_fn=ddsp.core.exp_sigmoid,
                 f0_depth=64,
                 hz_min=20.0,
                 hz_max=1200.0,
                 sample_rate=16000,
                 name='sinusoidal_to_harmonic_encoder'):
        """Constructor."""
        super().__init__(name=name)
        self.n_harmonics = n_harmonics
        self.amp_scale_fn = amp_scale_fn
        self.f0_depth = f0_depth
        self.hz_min = hz_min
        self.hz_max = hz_max
        self.sample_rate = sample_rate

        # Layers.
        self.pre_rnn = nn.FcStack(fc_stack_ch, fc_stack_layers)
        self.rnn = nn.Rnn(rnn_ch, rnn_type)
        self.post_rnn = nn.FcStack(fc_stack_ch, fc_stack_layers)

        self.amp_out = tfkl.Dense(1)
        self.hd_out = tfkl.Dense(n_harmonics)
        self.f0_out = tfkl.Dense(f0_depth)
Exemplo n.º 2
0
  def __init__(self,
               rnn_channels=512,
               rnn_type='gru',
               ch=512,
               layers_per_stack=3,
               input_keys=('ld_scaled', 'f0_scaled', 'z'),
               output_splits=(('amps', 1), ('harmonic_distribution', 40)),
               **kwargs):
    super().__init__(
        input_keys=input_keys, output_splits=output_splits, **kwargs)
    stack = lambda: nn.FcStack(ch, layers_per_stack)

    # Layers.
    self.input_stacks = [stack() for k in self.input_keys]
    self.rnn = nn.Rnn(rnn_channels, rnn_type)
    self.out_stack = stack()
    self.dense_out = tfkl.Dense(self.n_out)

    # Backwards compatability.
    self.f_stack = self.input_stacks[0] if len(
      self.input_stacks) >= 1 else None
    self.l_stack = self.input_stacks[1] if len(
      self.input_stacks) >= 2 else None
    self.z_stack = self.input_stacks[2] if len(
      self.input_stacks) >= 3 else None
Exemplo n.º 3
0
 def __init__(self,
              fc_units=512,
              hidden_layers=3,
              input_keys=('object_embedding'),
              output_splits=(('frequencies', 200), ('gains', 200), ('dampings', 200)),
              **kwargs):
   super().__init__(
       input_keys=input_keys, output_splits=output_splits, **kwargs)
   stack = lambda: nn.FcStack(fc_units, hidden_layers)
   self.input_stacks = [stack() for k in self.input_keys]
   self.out_stack = stack()
Exemplo n.º 4
0
    def __init__(self,
                 ch=512,
                 layers_per_stack=3,
                 input_keys=['f0_midi_scaled'],
                 output_splits=(('car_amp', 1), ('mod_amp', 1), ('mod_freq',
                                                                 1)),
                 **kwargs):
        super().__init__(input_keys=input_keys,
                         output_splits=output_splits,
                         **kwargs)
        stack = lambda: nn.FcStack(ch, layers_per_stack)

        # Layers.
        self.input_stacks = [stack() for k in self.input_keys]
        self.out_stack = stack()
Exemplo n.º 5
0
  def __init__(self,
               rnn_channels=512,
               rnn_type='gru',
               ch=512,
               layers_per_stack=3,
               input_keys=('ld_scaled', 'f0_scaled', 'z'),
               output_splits=(('amps', 1), ('harmonic_distribution', 40)),
               **kwargs):
    super().__init__(
        input_keys=input_keys, output_splits=output_splits, **kwargs)
    stack = lambda: nn.FcStack(ch, layers_per_stack)

    # Layers.
    self.input_stacks = [stack() for k in self.input_keys]
    self.rnn = nn.Rnn(rnn_channels, rnn_type)
    self.out_stack = stack()
Exemplo n.º 6
0
 def fc_stack():
   return nn.FcStack(ch, layers_per_input_stack-1)