public Atom(string voice, string layer, string instrument, Note note) { var context = new StaccatoParserContext(null); IVLSubparser.PopulateContext(context); var subparser = new IVLSubparser(); CreateAtom(subparser.GetValue(voice.ToUpper(), context), subparser.GetValue(layer.ToUpper(), context), (Instrument)subparser.GetValue(instrument.ToUpper(), context), new Note(note)); }
public StaccatoParser() { Context = new StaccatoParserContext(this); NoteSubparser.PopulateContext(Context); TempoSubparser.PopulateContext(Context); IVLSubparser.PopulateContext(Context); InitializeSubparsers(); InitializePreprocessors(); InitializeFunctionManager(); }
/// <summary> /// Turns the given pattern into a pattern of Voice-Instrument-Note atoms /// </summary> /// <returns>this pattern for method chaining</returns> public Pattern Atomize() { var currentLayer = new string[MidiDefaults.Tracks]; // Most recent layer for each voice var currentInstrument = new string[MidiDefaults.Tracks]; // Most recent instrument for each voice var tokens = GetTokens(); // Set current values var currentVoice = "" + IVLSubparser.VoiceChar + ValueOrZero(explicitVoice); currentLayer[ValueOrZero(explicitVoice)] = "" + IVLSubparser.LayerChar + ValueOrZero(explicitLayer); currentInstrument[ValueOrZero(explicitVoice)] = "" + IVLSubparser.InstrumentChar + ValueOrZero(explicitInstrument); // Clear the current contents of pattern (except for Tempo) patternBuilder.Clear(); explicitVoice = UndeclaredExplicit; explicitLayer = UndeclaredExplicit; explicitInstrument = UndeclaredExplicit; int voiceCounter = 0; foreach (var token in tokens) { string s = token.GetPattern().ToString(); switch (token.Type) { case TokenType.Voice: currentVoice = s; voiceCounter = new IVLSubparser().GetValue(currentVoice, null); if (currentLayer[voiceCounter] == null) { currentLayer[voiceCounter] = IVLSubparser.LayerChar + "0"; } if (currentInstrument[voiceCounter] == null) { currentInstrument[voiceCounter] = IVLSubparser.InstrumentChar + "0"; } break; case TokenType.Layer: currentLayer[voiceCounter] = s; break; case TokenType.Instrument: currentInstrument[voiceCounter] = s; break; case TokenType.Note: Add(new Atom(currentVoice, currentLayer[voiceCounter], currentInstrument[voiceCounter], s)); break; default: Add(s); break; } } return(this); }