示例#1
0
 void PlayChordRun(OutputDevice outputDevice, Chord chord, int millisecondsBetween)
 {
     Pitch previousNote = (Pitch)(-1);
     for (Pitch pitch = Pitch.A0; pitch < Pitch.C8; ++pitch)
     {
         if (chord.Contains(pitch))
         {
             if (previousNote != (Pitch)(-1))
             {
                 outputDevice.SendNoteOff(Channel.Channel1, previousNote, 80);
             }
             outputDevice.SendNoteOn(Channel.Channel1, pitch, 80);
             Thread.Sleep(millisecondsBetween);
             previousNote = pitch;
         }
     }
     if (previousNote != (Pitch)(-1))
     {
         outputDevice.SendNoteOff(Channel.Channel1, previousNote, 80);
     }
 }
示例#2
0
        public void Contains()
        {
            Chord cmajor = new Chord("C");
            Pitch[] cmajorPitches = new Pitch[] {
                Pitch.C2, Pitch.E2, Pitch.G2 };
            Pitch[] cmajorNotPitches = new Pitch[] {
                Pitch.CSharp2, Pitch.D2, Pitch.DSharp2, Pitch.F2, Pitch.FSharp2, Pitch.GSharp2,
                Pitch.A2, Pitch.ASharp2 };
            foreach (Pitch p in cmajorPitches)
            {
                Assert.True(cmajor.Contains(p));
            }
            foreach (Pitch p in cmajorNotPitches)
            {
                Assert.False(cmajor.Contains(p));
            }

            Chord bbminor = new Chord("Bbm");
            Pitch[] bbminorPitches = new Pitch[] {
                Pitch.ASharp2, Pitch.CSharp3, Pitch.F3 };
            Pitch[] bbminorNotPitches = new Pitch[] {
                Pitch.B2, Pitch.C3, Pitch.D3, Pitch.DSharp3, Pitch.E3, Pitch.G3,  Pitch.FSharp3,
                Pitch.GSharp3, Pitch.A3 };
            foreach (Pitch p in bbminorPitches)
            {
                Assert.True(bbminor.Contains(p));
            }
            foreach (Pitch p in bbminorNotPitches)
            {
                Assert.False(bbminor.Contains(p));
            }
        }