Exemplo n.º 1
0
        /// <summary>
        /// play one column of the grids
        /// </summary>
        private void PlayColumn(short xCell)
        {
            if ((Width * NumberOfGrids) % 2 == 0)
            {
                //play kick on root note
                if (xCell == 0)
                {
                    Synthesizer.Kick();
                }

                if (xCell == (float)(Width * NumberOfGrids) / 2)
                {
                    Synthesizer.Snare();
                }
                else
                {
                    Synthesizer.Hat();
                }
            }
            else
            {
                //play kick on root note
                if (xCell == 0 && Kick)
                {
                    Synthesizer.Kick();
                    Kick = !Kick;
                    Synthesizer.Hat();
                }
                else if (xCell == 0)
                {
                    Synthesizer.Snare();
                    Kick = !Kick;
                }
                else
                {
                    Synthesizer.Hat();
                }
            }

            //divide grids
            int z = 0;

            //determine grid
            while (xCell >= Width)
            {
                z++;
                xCell -= Width;
            }

            //play column
            if (Numeric)
            {
                short key = Numbers.Zero;

                for (short yCell = 0; yCell < Height; yCell++)
                {
                    if (CellValues[z][xCell, yCell])
                    {
                        key++;
                    }
                }

                if (progressive)
                {
                    Synthesizer.Play(key, 1, (short)ChordProgression[_CellularAutomata[0].Iterations % _CellularAutomata[0].Repeat]);
                }
                else
                {
                    Synthesizer.Play(key, 1, 0);
                }
            }
            else
            {
                int i = Numbers.Zero;

                for (short yCell = 0; yCell < Height; yCell++)
                {
                    if (CellValues[z][xCell, yCell])
                    {
                        i++;
                    }
                }

                for (short yCell = 0; yCell < Height; yCell++)
                {
                    if (CellValues[z][xCell, yCell])
                    {
                        if (progressive)
                        {
                            Synthesizer.Play((short)(Height - 1 - yCell), i,
                                             (short)ChordProgression[_CellularAutomata[0].Iterations % _CellularAutomata[0].Repeat]);
                        }
                        else
                        {
                            Synthesizer.Play((short)(Height - 1 - yCell), i, 0);
                        }
                    }
                }
            }

            //if ((xCell % Width == 0) || (xCell % ((double)Width / 2) == 0))
            //s += xCell + ": Kick";

            //Console.WriteLine(s);
        }