using System; using System.Collections; using System.Collections.Generic; namespace Wavelet_Tracker { public class MyMachine : MachineParameterisedBase { ////////////////////////////////////////////////////////////////////////// // TODO: Fill in (and *maintain*) these values. ////////////////////////////////////////////////////////////////////////// private const string type = "BS Note Drift"; private const string author = "Internal"; private const int version = 1; ////////////////////////////////////////////////////////////////////////// // TODO: Add any internal variables you want to use here. ////////////////////////////////////////////////////////////////////////// // You must not alter the signature of the machine. public MyMachine(string name) : base(type, author, version, name) { machineLimitations = MachineLimitations.ProcessNotes; } protected override void endSetupInputOutputImpl() { outputs = new MachineConnection[2]; outputs[0] = new MachineConnection("Wet"); outputs[1] = new MachineConnection("Dry"); inputs = new MachineConnection[1]; inputs[0] = new MachineConnection("Input"); } protected override void endSetupParametersImpl() { ////////////////////////////////////////////////////////////////////////// // TODO: Describe your machine's parameters as demonstrated below. ////////////////////////////////////////////////////////////////////////// parameters = new MachineParameter[3]; MachineParameterContinuous delay = new MachineParameterContinuous("Delay", 0, 0.2f); delay.multiplier = 1000; delay.label = "ms"; parameters[0] = delay; delay = new MachineParameterContinuous("Decay", 0, 0.2f); delay.multiplier = 100; delay.label = "%"; parameters[1] = delay; delay = new MachineParameterContinuous("Drift", 0, 0.2f); delay.multiplier = 300; delay.offset = -150; delay.label = "cents"; parameters[2] = delay; } protected override void endProductionImpl(long interval) { float delay = ((float)parameters[0].parameterValue); long ldelay = (long)(delay * App.TIME_RES); float decay = ((float)parameters[1].parameterValue); float drift = ((float)parameters[2].parameterValue); drift -= 0.5f; int idrift = (int) (drift * 300.0); List list = inputs[0].buffer.getForProcessing(playTime, interval, true); for (int x = 0; x < list.Count; x++) { SoundEvent e = list[x]; if (e.eventType == EventType.STANDARD_NOTE) { NoteEvent w = (NoteEvent)e; long wtime = w.startTime; float wamp = 1.0f; try { wamp = (float)w.metadata.getAttribute("Volume"); } catch (Exception) { } int wnote = w.note; int wfine = w.fineTune; int numEchoes = 0; while (wamp > 0.001f && numEchoes < 15) { wamp *= (1.0f - decay); wtime += ldelay; // Adjust the pitch... wfine += idrift; while (wfine > 66) { wnote++; wfine -= 66; } while (wfine < -66) { wnote--; wfine += 66; } NoteEvent v = new NoteEvent(wtime, w.scale, wnote, wfine); v.metadata.setAttribute("Volume", wamp); outputs[0].buffer.addEvent(v); numEchoes++; } // The original event is put into the 'dry' output. outputs[1].buffer.addEvent(w); } } } protected override void endSeekImpl(long seekTime) { ////////////////////////////////////////////////////////////////////////// // TODO: Anything you might need to do before each time play is pressed. // At this time, playTime is being set to seekTime. You may wish to reset // some internal timers, cancel currently playing notes or samples, things // like that. ////////////////////////////////////////////////////////////////////////// } protected override void endTickImpl(ArrayList parameterChanges) { ////////////////////////////////////////////////////////////////////////// // TODO: Explicitly handle pattern events if you so desire. See the score // machine for an example of this. ////////////////////////////////////////////////////////////////////////// } } } // TODO: (Developer) Add information here on the different events, their signatures and behaviours.