Beispiel #1
0
        public static void SynthConsole()
        {
            var go = true;
            Debug.Listeners.Add(new ConsoleTraceListener());

            var bpm = 120D;
            double bps = bpm / 60D;
            uint m = (uint)(1000D / bps);

            var sound = new SystemSoundProvider();
            var sound2 = new NetSoundProvider();
            var wavSound = new WavSoundProvider("wavSynth.wav");
            var debugsound = new DebugSoundProvider();

            Octaves o = Octaves.O4;

            using (Mixer mix = new Mixer(debugsound, wavSound, sound))
            {
                while (go)
                {
                    Console.Write(">");

                    Notes n;
                    var keypress = Console.ReadKey().Key;
                    Console.WriteLine();

                    if (keypress == ConsoleKey.UpArrow && !o.Equals(Octaves.O8))
                    {
                        o++;
                        Console.WriteLine("Octave={0}", o);
                    }
                    if (keypress == ConsoleKey.DownArrow && !o.Equals(Octaves.O1))
                    {
                        o--;
                        Console.WriteLine("Octave={0}", o);
                    }

                    bool isNote = Enum.TryParse<Notes>(Enum.GetName(typeof(ConsoleKey),
                        keypress), out n);
                    if (isNote)
                        mix.PlaySound(new Pitch(n, o), m);

                    if (keypress.Equals(ConsoleKey.X))
                        go = false;
                }
            }
            Console.ReadLine();
        }
Beispiel #2
0
        public static void PerformTest()
        {
            Debug.Listeners.Add(new ConsoleTraceListener());

            var bpm = 120D;
            double bps = bpm / 60D;
            uint m = (uint)(1000D / bps);

            var sound = new SystemSoundProvider();
            var debugsound = new DebugSoundProvider();

            var instrument = new Instrument(sound);

            "ABCDEFG".Play(sound, 33);
            "AFB".Play(sound, m);
            Pitch[] majorG = { new Pitch(Notes.G, Octaves.O4), new Pitch(Notes.AS, Octaves.O5), new Pitch(Notes.C, Octaves.O5) };
            Pitch[] majorC = { new Pitch(Notes.C, Octaves.O4), new Pitch(Notes.E, Octaves.O4), new Pitch(Notes.G, Octaves.O4) };
            Pitch[] majorEinC = { new Pitch(Notes.E, Octaves.O4), new Pitch(Notes.G, Octaves.O4), new Pitch(Notes.B, Octaves.O5) };
            Pitch[] majorAinC = { new Pitch(Notes.A, Octaves.O4), new Pitch(Notes.C, Octaves.O4), new Pitch(Notes.E, Octaves.O5) };

            instrument.PlayChord(500, majorG);

            instrument.PlayChord(m, majorC);
            instrument.PlayChord(m / 2, majorAinC);
            instrument.PlayChord(m / 2, majorAinC);

            instrument.PlayChord(m, majorC);
            instrument.PlayChord(m / 2, majorAinC);
            instrument.PlayChord(m / 2, majorAinC);

            instrument.PlayChord(m, majorC);
            instrument.PlayChord(m, majorC);

            for (int i = 0; i < 8; i++)
            {
                instrument.PlayChord(m / 2, majorAinC);
                instrument.PlayChord(m / 2, majorEinC);
            }

            instrument.PlayKey(Scales.MajorScale, Notes.C, 100);
            instrument.PlayKey(Scales.MajorScale, Notes.G, 100);

            instrument.Arp5(Pitch.MinPitch, 33, 1);
            instrument.Arp1(33);
            instrument.Arp1(m);
            instrument.Arp2(33);
            instrument.Arp3(33);
            instrument.Arp4(new Pitch(Notes.F, Octaves.O4), new Pitch(Notes.C, Octaves.O4), 33);

            instrument.PlayScale(Scales.MajorScale, Notes.C, m);

            instrument.PlayScale(Scales.NaturalMinorScale, Notes.CS, m);
            instrument.PlayScale(Scales.HarmonicMinorScale, Notes.G, m, Octaves.O2);

            instrument.Play(new Pitch(Notes.G, Octaves.O4), 100);
            instrument.Play(new Pitch(Notes.E, Octaves.O5), 400);
            instrument.Play(new Pitch(Notes.G, Octaves.O4), 100);
            instrument.Play(new Pitch(Notes.E, Octaves.O5), 400);

            instrument.Play(new Pitch(Notes.A, Octaves.O2), 500);
        }