using System; using System.Collections; using System.Collections.Generic; namespace Wavelet_Tracker { public class GainerMachine : MachineParameterisedBase { private const string type = "Gain"; private const string author = "Internal"; private const int version = 1; // You must not alter the signature of the machine, but you can rename // this class which helps find bugs. public GainerMachine(string name) : base(type, author, version, name) { machineLimitations = MachineLimitations.ProcessWaveletsAndPCM; } protected override void endSetupInputOutputImpl() { outputs = new MachineConnection[1]; outputs[0] = new MachineConnection("Output"); inputs = new MachineConnection[1]; inputs[0] = new MachineConnection("Input"); } protected override void endSetupParametersImpl() { parameters = new MachineParameter[1]; MachineParameterContinuous gain = new MachineParameterContinuous("Gain", 0, 0.1f); gain.multiplier = 10; gain.label = "x"; parameters[0] = gain; } protected unsafe override void endProductionImpl(long interval) { float gain = ((float) parameters[0].parameterValue) * 10.0f; List list = inputs[0].buffer.getForProcessing(playTime, interval, true); // We are simply going to loop through the list of events we have. for (int x = 0; x < list.Count; x++) { SoundEvent e = list[x]; // Here we can see the machine filtering out the events that it is interested in. if (e.eventType == EventType.AUDIO_WAVELETS) { ((WaveletEvent)e).amplitude *= gain; } else if (e.eventType == EventType.AUDIO_PCM) { PCMEvent evt = (PCMEvent) e; for (int p = 0; p < evt.bufferLength; p++) { for (int q = 0; q < evt.numChannels; q++) { evt.data[q][p] *= gain; } } } } outputs[0].buffer.addAllEvents(list); } protected override void endSeekImpl(long seekTime) { } protected override void endTickImpl(ArrayList parameterChanges) { } } }