protected void Init(string stringToParse) { m_tracks = new List<Track>(); m_warnings = new List<CompilerWarning>(); m_text = new StringBuilder(stringToParse); m_trackIndex = Track.FIRST_TRACK; m_octave = 4; m_relativeDir = true; m_velocity = 100; m_velocityDetail = true; m_length = TickFromLength(4); m_tempo = 120; m_keyOff = true; m_gate = 15; m_maxGate = 16; m_form = OscillatorForm.Pulse; m_noteShift = 0; m_maxPipe = 0; }
public void RecordLFO(OscillatorForm form, OscillatorForm subform, int depth, int width, int delay, int time, bool reverse) { Events.LFO e = new Events.LFO() { Main = form, Sub = subform, Depth = depth, Width = width, Delay = delay, Time = time, Reverse = reverse }; SetDeltaAndAddEvent(e); }
protected void AtmarkToken() { Track track; char c = CharacterToken(); int tmp = 1; int attack = 0; int decay = 64; int sustain = 32; int release = 0; int sens = 0; int mode = 0; switch (c) { case 'v': m_velocityDetail = false; NextToken(); m_velocity = (int)UIntToken((uint)m_velocity); m_velocity = Math.Min(m_velocity, Channel.VELOCITY_MAX2); break; case 'x': NextToken(); int expression = (int)UIntToken((uint)Channel.VELOCITY_MAX2); expression = Math.Min(expression, Channel.VELOCITY_MAX2); track = m_tracks[m_trackIndex]; track.RecordExpression(expression); break; case 'e': NextToken(); tmp = (int)UIntToken((uint)tmp); if (CharacterToken() == ',') NextToken(); attack = (int)UIntToken((uint)attack); if (CharacterToken() == ',') NextToken(); decay = (int)UIntToken((uint)decay); if (CharacterToken() == ',') NextToken(); sustain = (int)UIntToken((uint)sustain); if (CharacterToken() == ',') NextToken(); release = (int)UIntToken((uint)release); track = m_tracks[m_trackIndex]; track.RecordEnvelopeADSR(attack, decay, sustain, release, tmp == 1); break; case 'n': NextToken(); int noise = (int)Math.Min(UIntToken(0), Channel.VELOCITY_MAX2); m_tracks[m_trackIndex].RecordNoiseFrequency(noise); break; case 'w': NextToken(); int pwm = (int)Math.Min(Math.Max(UIntToken(50), 1), 99); m_tracks[m_trackIndex].RecordPWM(pwm); break; case 'p': NextToken(); int pan = (int)Math.Min(Math.Max(UIntToken(64), 1), Channel.VELOCITY_MAX2); m_tracks[m_trackIndex].RecordPan(pan); break; case '\'': NextToken(); FormantVowel vowel = FormantVowel.Unknown; while (true) { char v = CharacterToken(); if (v == '\'') { NextToken(); break; } else { switch (v) { case 'a': vowel = FormantVowel.A; break; case 'e': vowel = FormantVowel.E; break; case 'i': vowel = FormantVowel.I; break; case 'o': vowel = FormantVowel.O; break; case 'u': vowel = FormantVowel.U; break; } NextToken(); } } m_tracks[m_trackIndex].RecordFormantVowel(vowel); break; case 'd': NextToken(); int detune = IntToken(0); m_tracks[m_trackIndex].RecordDetune(detune); break; case 'l': NextToken(); bool reverse = false; int form = 1, subform = 0, delay = 0, time = 0; int depth = (int)UIntToken(0); if (CharacterToken() == ',') NextToken(); int width = (int)UIntToken(0); if (CharacterToken() == ',') { NextToken(); if (CharacterToken() == '-') { reverse = true; NextToken(); } form = (int)UIntToken((uint)form) + 1; if (CharacterToken() == '-') { NextToken(); subform = (int)UIntToken((uint)subform); } if (CharacterToken() == ',') { NextToken(); delay = (int)UIntToken((uint)delay); if (CharacterToken() == ',') { NextToken(); time = (int)UIntToken((uint)time); } } } track = m_tracks[m_trackIndex]; track.RecordLFO( (OscillatorForm)form, (OscillatorForm)subform, depth, width, delay, time, reverse ); break; case 'f': NextToken(); int amount = 0, frequency = 0, resonance = 0; int swt = IntToken(0); if (CharacterToken() == ',') { NextToken(); amount = IntToken(0); if (CharacterToken() == ',') { NextToken(); frequency = (int)UIntToken(0); if (CharacterToken() == ',') { NextToken(); resonance = (int)UIntToken(0); } } } track = m_tracks[m_trackIndex]; track.RecordLPF((FilterType)swt, amount, frequency, resonance); break; case 'q': NextToken(); int gate2 = (int)UIntToken(2); m_tracks[m_trackIndex].RecordGate(gate2); break; case 'i': NextToken(); sens = (int)UIntToken(0); if (CharacterToken() == ',') { NextToken(); attack = (int)UIntToken((uint)attack); attack = Math.Min(attack, m_maxPipe); } m_tracks[m_trackIndex].RecordInput(sens, attack); break; case 'o': NextToken(); mode = (int)UIntToken(0); if (CharacterToken() == ',') { NextToken(); attack = (int)UIntToken((uint)attack); if (attack > m_maxPipe) { m_maxPipe = attack; if (m_maxPipe >= MAX_PIPE) m_maxPipe = attack = MAX_PIPE; } } m_tracks[m_trackIndex].RecordOutput((ChannelOutputMode)mode, attack); break; case 'r': NextToken(); sens = (int)UIntToken(0); if (CharacterToken() == ',') { NextToken(); attack = (int)UIntToken((uint)attack); attack = Math.Min(attack, m_maxPipe); } m_tracks[m_trackIndex].RecordRing(sens, attack); break; case 's': NextToken(); mode = (int)UIntToken(0); if (CharacterToken() == ',') { NextToken(); attack = (int)UIntToken((uint)attack); if (mode == 1) { if (attack > m_maxSyncSource) { m_maxSyncSource = attack; if (m_maxSyncSource >= MAX_SYNC_SOURCE) m_maxSyncSource = attack = MAX_SYNC_SOURCE; } } else if (mode == 2) { if (attack > m_maxSyncSource) attack = m_maxSyncSource; } } m_tracks[m_trackIndex].RecordSync((ChannelOutputMode)mode, attack); break; default: m_form = (OscillatorForm)UIntToken((uint)m_form); subform = 0; if (CharacterToken() == '-') { NextToken(); subform = (int)UIntToken(0); } track = m_tracks[m_trackIndex]; track.RecordForm(m_form, (OscillatorForm)subform); break; } }
public void RecordForm(OscillatorForm form, OscillatorForm subform) { Events.Form e = new Events.Form() { Main = form, Sub = subform }; SetDeltaAndAddEvent(e); }