Beispiel #1
0
        public void GenerateTest()
        {
            var song = new GeneratedSong();

            song.Generate(Parameters);
            Console.WriteLine(song.WriteStats());
            foreach (var section in song.Sections)
            {
                Console.WriteLine("{0}: {1} meas, {2}", section.Type, section.Measures, string.Join(" - ", section.Chords.Select(c => c.Item2)));
            }
        }
Beispiel #2
0
        private void InitializeGenerators()
        {
            _generator         = new BackgroundWorker();
            _generator.DoWork += (o, args) =>
            {
                // Create export folder
                if (!Directory.Exists(_exportFolder))
                {
                    Directory.CreateDirectory(_exportFolder);
                }

                var song = new GeneratedSong();
                song.Generate(_parameterList.ToParameterList());
                args.Result = song;
            };
            _generator.RunWorkerCompleted += (o, args) =>
            {
                BtnGenerate.Content   = "Generate";
                BtnGenerate.IsEnabled = true;
                _song = (GeneratedSong)args.Result;
                BtnRender.IsEnabled      = true;
                TxtGeneratedResults.Text = $"{_song.WriteStats()}\n{_song.WriteSections()}";
            };

            _renderer         = new BackgroundWorker();
            _renderer.DoWork += (o, args) =>
            {
                var score      = _song.Render();
                var outputPath = $@"{_exportFolder}\{DateTime.Now:yyyyMMddhhmmss}.mid";
                score.ExportMidi(outputPath);
                args.Result = outputPath;
            };
            _renderer.RunWorkerCompleted += (o, args) =>
            {
                BtnRender.Content   = "Render";
                BtnRender.IsEnabled = true;
                if (ChkPlay.IsChecked ?? false)
                {
                    Process.Start(args.Result.ToString());
                }
            };
        }