Advertisement
Guest User

Untitled

a guest
Jan 1st, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Buzz.MachineInterface;
  6.  
  7. namespace Jeskola.Gain
  8. {
  9.     [MachineDecl(Name = "Jeskola Gain", ShortName = "Gain", Author = "Oskari Tammelin")]
  10.     public class GainMachine : IBuzzMachine
  11.     {
  12.         IBuzzMachineHost host;
  13.  
  14.         public GainMachine(IBuzzMachineHost host)
  15.         {
  16.             this.host = host;
  17.             Gain = new Interpolator();
  18.         }
  19.  
  20.         [ParameterDecl(ResponseTime = 5, MaxValue = 127, DefValue = 80, Transformation = Transformations.Cubic, TransformUnityValue = 80, ValueDescriptor = Descriptors.Decibel)]
  21.         public Interpolator Gain { get; private set; }
  22.  
  23.         [ParameterDecl(ValueDescriptions = new[] { "no", "yes" })]
  24.         public bool Bypass { get; set; }
  25.  
  26.         /*
  27.         public Sample Work(Sample s)
  28.         {
  29.             return Bypass ? s : s * Gain.Tick();
  30.         }
  31.          */
  32.  
  33.         public bool Work(Sample[] output, Sample[] input, int numsamples, WorkModes mode)
  34.         {
  35.             if (mode == WorkModes.WM_READWRITE)
  36.             {
  37.                 for (int i = 0; i < numsamples; i++)
  38.                     output[i] = Bypass ? input[i] : input[i] * Gain.Tick();
  39.  
  40.                 return true;
  41.             }
  42.            
  43.             return false;
  44.         }
  45.  
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement