Esempio n. 1
0
        public void Play(string moddl, Output <float> output)
        {
            var ast  = new Parser().Parse(moddl);
            var mmls = new Dictionary <string, StringBuilder>();

            foreach (var stmt in ast.Statements)
            {
                if (stmt is DirectiveStatement dir)
                {
                    this.ProcessDirectiveStatement(dir);
                }
                else if (stmt is MmlStatement mml)
                {
                    foreach (var track in mml.Tracks)
                    {
                        if (!mmls.ContainsKey(track))
                        {
                            mmls.Add(track, new StringBuilder());
                        }
                        mmls[track].AppendLine(mml.Mml);
                    }
                }
            }

            var nodes = mmls
                        .Where(kv => this.muteSpecifiedTracks != this.mutedOrUnmutedTracks.Contains(kv.Key))
                        .Select(kv => this.MmlToNode(kv.Key, kv.Value.ToString()));

            this.ShowGuiIfNeeded(output);

            var master    = nodes.Aggregate(Const(0f), (acc, node) => (Node <float>)(acc + node));
            var masterVol = 0.25f;

            ModuleSpace.Play <float>((master * masterVol).AsFloat(), output);
        }
Esempio n. 2
0
        private static void NoiseSample()
        {
            var noise = Noise();

            using (ModuleSpace.Play((noise * 0.125f).AsFloat())) Console.ReadKey();
        }