/// <summary> /// Composes a new MIDI file based on the given seed /// </summary> /// <param name="seed"></param> /// <returns></returns> public static Composition Compose(string seed) { using (var engine = new ChakraCoreJsEngine()) { foreach (var script in scripts) { engine.Execute(script); } var result = engine.CallFunction <string>("exportMidi", seed); var midiBytes = result.Split(',').Select(str => Convert.ToByte(str)).ToArray(); return(new Composition(seed, new MemoryStream(midiBytes))); } }
protected override string Compile(string code) => engine.CallFunction("transform", code) as string;