Ejemplo n.º 1
0
 public bool Same(Note x)
 {
     return this.DemisTonsOffset == x.DemisTonsOffset
         && this.Octave == x.Octave
         && this.Name == x.Name;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Play the notes in a song.
 /// </summary>
 /// <param name="tune"></param>
 protected static void Play(Note[] tune)
 {
     foreach (Note n in tune)
     {
         if (n.NoteTone == Tone.REST)
             Thread.Sleep((int)n.NoteDuration);
         else
             Console.Beep((int)n.NoteTone, (int)n.NoteDuration);
     }
 }
Ejemplo n.º 3
0
 public GammeManager(Gamme gamme, Note start)
 {
     this.gamme = gamme;
     this.start = start;
     Init();
 }
Ejemplo n.º 4
0
        private void RemplirGuitare()
        {
            notes.Clear();

            int x = 10;
            int y = 10;
            int ky = 0;
            int kxOffset = 55;
            int kyOffset = 45;
            var guitar = new Guitar();
            var notesAVide = guitar.GetCordesAVide();
            int maxFrets = 15;

            //foreach (var noteVide in notesAVide)
            //{
            //    for (int i = 0; i <= maxFrets; i++)
            //    {
            //        Note cur = new Note(noteVide.DemisTonsOffset + i);
            //        if (notesGamme.Select(p => p.Name).Contains(cur.Name))
            //        {
            //            notes.Add(new NoteModel() { NoteToPlay = cur, X = x + (i * kxOffset), Y = y + ky, Fret = i });
            //        }
            //    }
            //    ky += kyOffset;
            //}

            //var notesGammeMajeur = new GammeManager(new GammeMajeur(), new Note(name, 3)).GetNotesTwoOctaves();
            //int[] accord = new int[] { 1, 3, 5 };
            //List<Note> notesAccord = new List<Note>();
            //for (int i = 0; i < accord.Length; i++)
            //{
            //    notesAccord.Add(notesGammeMajeur[accord[i] - 1]);
            //}

            //var notesSelection = new GammeManager(gamme, new Note(name, 3)).GetNotes();
            var notesSelection = AccordDef.Get_X7(name);

            Dictionary<NoteName, int> flagDic = new Dictionary<NoteName, int>();

            foreach (var noteVide in notesAVide)
            {
                for (int i = 0; i <= maxFrets; i++)
                {
                    Note cur = new Note(noteVide.DemisTonsOffset + i);

                    if (notesSelection.Select(p => p.Name).Contains(cur.Name))
                    {
                        var model = new NoteModel();
                        model.NoteToPlay = cur;
                        model.X = x + (i * kxOffset);
                        model.Y = y + ky;
                        model.Fret = i;

                        if (flagDic.ContainsKey(cur.Name))
                        {
                            model.Flag = flagDic[cur.Name];
                        } else
                        {
                            int f = flagDic.Count;
                            model.Flag = f;
                            flagDic.Add(cur.Name, f);
                        }

                        notes.Add(model);
                    }
                }
                ky += kyOffset;
            }
        }
Ejemplo n.º 5
0
        public void TestScoreBasic()
        {
            Scale cscale = new Scale("C", Scale.ScaleTypes.Major);
            Score score  = new Score(new Rational(4, 4), cscale, new string[] { "Piano", "S", "A", "T", "B" });

            score.AddMeasures(3);
            int[]      yankee    = { 0, 0, 2, 4, 0, 4, 2 };
            Rational[] durations = { new Rational(1, 4), new Rational(1, 4),
                                     new Rational(1, 4), new Rational(1, 4),new Rational(1,  4),
                                     new Rational(1, 4), new Rational(2, 4) };

            int item = 0;

            for (int measure = 0; measure < 3; measure++)
            {
                bool ok = false;
                do
                {
                    if (item < yankee.Length)
                    {
                        ok = score.AddNote("Piano", measure, new Note(yankee[item], 0, durations[item]));
                        if (ok)
                        {
                            //Console.WriteLine("Added note {0} to measure {1}", yankee[item], measure);
                            item++;
                        }
                    }
                    else
                    {
                        break;
                    }
                } while(ok);
            }

            // There should only be 2 of 3 measures full
            // measure one contains (C, 1/4) (C, 1/4), (D, 1/4), (E, 1/4)

            Measure m0   = score.GetMeasure("Piano", 0);
            Note    m0n0 = m0.GetNote(0);
            Note    m0n1 = m0.GetNote(1);
            Note    m0n2 = m0.GetNote(2);
            Note    m0n3 = m0.GetNote(3);

            Assert.IsTrue(m0n0.GetTone() == yankee[0] && m0n0.GetDuration().CompareTo(durations[0]) == 0);
            Assert.IsTrue(m0n1.GetTone() == yankee[1] && m0n1.GetDuration().CompareTo(durations[1]) == 0);
            Assert.IsTrue(m0n2.GetTone() == yankee[2] && m0n2.GetDuration().CompareTo(durations[2]) == 0);
            Assert.IsTrue(m0n3.GetTone() == yankee[3] && m0n3.GetDuration().CompareTo(durations[3]) == 0);

            // measure two contains (C, 1/4) (E, 1/4), (D, 1/2)
            Measure m1   = score.GetMeasure("Piano", 1);
            Note    m1n0 = m1.GetNote(0);
            Note    m1n1 = m1.GetNote(1);
            Note    m1n2 = m1.GetNote(2);

            Assert.IsTrue(m1n0.GetTone() == yankee[4] && m1n0.GetDuration().CompareTo(durations[4]) == 0);
            Assert.IsTrue(m1n1.GetTone() == yankee[5] && m1n1.GetDuration().CompareTo(durations[5]) == 0);
            Assert.IsTrue(m1n2.GetTone() == yankee[6] && m1n2.GetDuration().CompareTo(durations[6]) == 0);

            // measure three is empty

            Measure m2 = score.GetMeasure("Piano", 2);

            Assert.IsTrue(m2.Length().CompareTo(new Rational(0)) == 0);
        }