Beispiel #1
0
        private Melody[] GetMelody()
        {
            var durations = new[]
            {
                NoteDuration.Eighth,
                NoteDuration.Quarter,
            };
            var generator = new MelodyGenerator(new RandomDurationGenerator(durations: durations));
            var melody    = generator.Generate(Gammas.CMaj5, 600);

            var bassDurations = new[]
            {
                NoteDuration.Half,
                NoteDuration.Half,
                NoteDuration.Quarter
            };
            var bassGenerator = new MelodyGenerator(new RandomDurationGenerator(durations: bassDurations));
            var bass          = bassGenerator.GenerateMajChords(Gammas.CMaj3, 200);

            var drums = new MelodyGenerator(new RandomDurationGenerator(durations: new [] { NoteDuration.Whole }))
                        .Generate(new [] { NoteKey.C2 }, 100);

            var synth = new MelodyGenerator(new RandomDurationGenerator(durations: new []
            {
                NoteDuration.Eighth
            }))
                        .Generate(Gammas.CMaj4, 800);

            return(new[] { melody, bass, synth });
        }
Beispiel #2
0
        private void PlayNew()
        {
            PlayChord();
            return;


            var durations = new[]
            {
                NoteDuration.Eighth,
                NoteDuration.Quarter,
            };
            var generator = new MelodyGenerator(new RandomDurationGenerator(durations: durations));
            var melody    = generator.Generate(Gammas.CMaj5, 80);

            var bassDurations = new[]
            {
                NoteDuration.Half,
                NoteDuration.Half,
                NoteDuration.Quarter
            };
            var bassGenerator = new MelodyGenerator(new RandomDurationGenerator(durations: bassDurations));
            var bass          = bassGenerator.GenerateMajChords(Gammas.CMaj3, 40);

            //var drums = new MelodyGenerator(new RandomDurationGenerator(durations: new [] {NoteDuration.Whole}))
            //    .Generate(new [] {NoteKey.C2}, 40);

            using var memoryStream = File.OpenWrite("temp.wav");
            using var binaryWriter = new BinaryWriter(memoryStream);
            var recorder = new WaveRecorder();

            //var wave = recorder.Record(binaryWriter, new [] {melody, bass});

            //new WaveVisualiser().Visualize(wave, 800, 600).Save("temp.png", ImageFormat.Png);
            //memoryStream.Position = 0;

            //new SoundPlayer(memoryStream).Play();
        }