Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [MachineDecl(Name = "Jeskola Gain", ShortName = "Gain", Author = "Oskari Tammelin")]
- public class GainMachine : IBuzzMachine
- {
- IBuzzMachineHost host;
- public GainMachine(IBuzzMachineHost host)
- {
- this.host = host;
- Gain = new Interpolator();
- MachineState = new State();
- }
- [ParameterDecl(ResponseTime = 5, MaxValue = 127, DefValue = 80, Transformation = Transformations.Cubic, TransformUnityValue = 80, ValueDescriptor = Descriptors.Decibel)]
- public Interpolator Gain { get; private set; }
- [ParameterDecl(ValueDescriptions = new[] { "no", "yes" })]
- public bool Bypass { get; set; }
- public Sample Work(Sample s)
- {
- return Bypass ? s : s * Gain.Tick();
- }
- public class State : INotifyPropertyChanged
- {
- public State() { text = "here is state"; } // NOTE: parameterless constructor is required by the xml serializer
- string text;
- public string Text
- {
- get { return text; }
- set
- {
- text = value;
- if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Text"));
- }
- }
- public event PropertyChangedEventHandler PropertyChanged;
- }
- public State MachineState { get; set; } // a property called 'MachineState' gets automatically saved in songs and presets
- }
- public class MachineGUIFactory : IMachineGUIFactory { public IMachineGUI CreateGUI(IMachineGUIHost host) { return new GainGUI(); } }
- public class GainGUI : UserControl, IMachineGUI
- {
- IMachine machine;
- GainMachine gainMachine;
- TextBox tb;
- public IMachine Machine
- {
- get { return machine; }
- set
- {
- machine = value;
- if (machine != null)
- {
- gainMachine = (GainMachine)machine.ManagedMachine;
- tb.SetBinding(TextBox.TextProperty, new Binding("Text") { Source = gainMachine.MachineState, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
- }
- }
- }
- public GainGUI()
- {
- this.Content = tb = new TextBox() { Margin = new Thickness(0, 0, 0, 4) };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement