Пример #1
0
        void AddSpiral(Song song, int startTime)
        {
            const double A       = 4;
            const int    NumArms = 3;
            var          color   = new LightColor(0, NumArms - 1, new List <IReadOnlyList <int> >
            {
                new List <int> {
                    0x101010, 0x000000, 0x000000
                },
                new List <int> {
                    0x000010, 0x000010, 0x000000
                },
                new List <int> {
                    0x100010, 0x001010, 0x000000
                },
                new List <int> {
                    0x100000, 0x101000, 0x000010
                },
                new List <int> {
                    0x000010, 0x001010, 0x040818
                },
            });
            var colorSpacing = A * 2 * Math.PI / NumArms;

            var segment = new Segment();
            var center  = new Point(48, 48);

            for (var rotateAngle = 0; rotateAngle < 360; ++rotateAngle)
            {
                var useAngle = rotateAngle * Math.PI / 180;
                foreach (var light in bodyLayout.GetAllLights())
                {
                    var point = bodyLayout.GetLightPosition(light);

                    var angle    = Math.Atan2(point.Y - 48, point.X - 48) - useAngle;
                    var distance = (point - center).Length;
                    var numLoops = (distance - angle * A) / colorSpacing + 999;
                    distance -= colorSpacing * (numLoops - Math.Floor(numLoops));
                    var arm = (int)numLoops % NumArms;

                    segment.AddLight(light, rotateAngle, color, arm);
                }
            }

            var beatLengths = new List <int> {
                135, 135, 135, 135, 90, 90, 135, 135, 135, 135, 90, 90, 135, 135, 90, 135, 135, 90, 135, 135, 90, 135, 135, 90, 135, 135, 90, 135, 135, 90, 360
            };
            var clockwise = true;
            var absPos    = 0;
            var segPos    = 0;

            foreach (var beatLength in beatLengths)
            {
                var multiplier = clockwise ? 5 : -3;
                var nextSegPos = segPos + beatLength * multiplier;
                while (segPos != nextSegPos)
                {
                    if ((segPos == 0) && (nextSegPos < 0))
                    {
                        segPos     += 360;
                        nextSegPos += 360;
                    }
                    if ((segPos == 360) && (nextSegPos > 360))
                    {
                        segPos     -= 360;
                        nextSegPos -= 360;
                    }
                    var segLen = Math.Min(Math.Max(0, nextSegPos), 360) - segPos;
                    var absLen = segLen / multiplier;
                    song.AddSegment(segment, segPos, segPos + segLen, startTime + absPos / 360d, absLen / 360d);
                    segPos += segLen;
                    absPos += absLen;
                }
                clockwise = !clockwise;
            }
            const int FadeTime = 200;

            song.AddPaletteChange(startTime, 0);
            song.AddPaletteFade(startTime + 2, FadeTime, 1);
            song.AddPaletteFade(startTime + 4, FadeTime, 2);
            song.AddPaletteFade(startTime + 6, FadeTime, 3);
            song.AddPaletteFade(startTime + 8, FadeTime, 4);
            song.AddPaletteChange(startTime + 11, 0);
        }
Пример #2
0
        public override Song Render()
        {
            var song = new Song("orchestra.ogg");

            song.AddMeasure(1000);             // Empty lead-in time
            song.AddMeasure(1220);             // Pickup
            song.AddMeasure(1890, 93);         // Measures
            // Beats appear quantized to 1/8

            // Lines (intro: 1; measures: 2)
            var lines = Lines();

            song.AddSegment(lines, 259, 382, 1, 1);
            song.AddSegment(lines, 0, 382, 2, 2, 4);
            song.AddPaletteChange(1, 0);
            song.AddPaletteChange(1, 2, 1);
            song.AddPaletteFade(4, 1000, 2);
            song.AddPaletteFade(6, 1000, 3);
            song.AddPaletteFade(8, 1000, 4);
            song.AddPaletteChange(10, 0);

            // BeatPattern (10)
            var beatPattern = BeatPattern(out int beatPatternTime);

            song.AddSegment(beatPattern, 0, beatPatternTime, 10, 15);

            // BeatCircles (25)
            var beatCircles = BeatCircles();

            song.AddSegment(beatCircles, 0, 15120, 25, 8);

            // Corners (33)
            var corners = Corners();

            song.AddSegment(corners, 0, 19, 33, 1, 12);
            song.AddPaletteChange(33, 0);
            song.AddPaletteFade(35, 1000, 1);
            song.AddPaletteFade(37, 1000, 2);
            song.AddPaletteFade(39, 1000, 3);
            song.AddPaletteFade(41, 1000, 4);
            song.AddPaletteFade(43, 1000, 5);
            song.AddPaletteChange(45, 0);

            // SquareCircles (45)
            var squareCircles = SquareCircles(out var squareCirclesTime);

            song.AddSegment(squareCircles, 100, 400, 45, 3);
            song.AddSegment(squareCircles, 0, 400, 48, 4, 2);
            song.AddPaletteChange(45, 0);
            new List <double> {
                0, 0.375, 0.75, 1.125, 1.5, 1.75, 2, 2.375, 2.75, 3.125, 3.5, 3.75, 4, 4.375, 4.75, 5, 5.375, 5.75, 6, 6.375, 6.75, 7, 7.375, 7.75, 8, 8.375, 8.75, 9, 9.375, 9.75, 10
            }.Skip(1).Select(x => x + 45).ForEach((x, index) => song.AddPaletteFade(x, 200, (index + 1) % 4));
            song.AddPaletteChange(56, 0);

            // BeatGrow (56)
            var beatGrow = BeatGrow();

            song.AddSegment(beatGrow, 0, 64, 56, 8);

            // Blinds (64)
            var blinds = Blinds();

            song.AddSegment(blinds, 0, 1440, 64, 6, 2);
            song.AddPaletteChange(64, 0);
            song.AddPaletteFade(68, 1000, 1);
            song.AddPaletteFade(72, 1000, 2);
            song.AddPaletteChange(76, 0);

            // Spiral (76)
            AddSpiral(song, 76);

            // BeatSquares (87)
            var beatSquares = BeatSquares();

            song.AddSegment(beatSquares, 0, 6400, 87, 8);

            // End (95)

            return(song);
        }
Пример #3
0
		public override Song Render()
		{
			var song = new Song("popular.ogg");

			song.AddMeasure(1000); // Empty lead-in time
			song.AddMeasure(2424, 81); // Measures

			// PulseSquares (1)
			var pulseSquares = PulseSquares();
			song.AddSegment(pulseSquares, 0, 100, 1, 1, 4);
			song.AddPaletteChange(1, 0);
			song.AddPaletteChange(2, 1);
			song.AddPaletteChange(3, 2);
			song.AddPaletteChange(4, 3);
			song.AddPaletteChange(5, 0);

			// MoveSquares (5)
			var moveSquares = MoveSquares();
			song.AddSegment(moveSquares[0], 0, moveSquares[0].MaxTime(), 5, 1);
			song.AddSegment(moveSquares[1], 0, moveSquares[1].MaxTime(), 6, 1);
			song.AddSegment(moveSquares[1], moveSquares[1].MaxTime(), 0, 7, 1);
			song.AddSegment(moveSquares[0], moveSquares[0].MaxTime(), 0, 8, 1);
			song.AddSegment(moveSquares[0], 0, moveSquares[0].MaxTime(), 9, 1);
			song.AddSegment(moveSquares[1], 0, moveSquares[1].MaxTime(), 10, 1);
			song.AddSegment(moveSquares[1], moveSquares[1].MaxTime(), 0, 11, 1);
			song.AddSegment(moveSquares[0], moveSquares[0].MaxTime(), 0, 12, 1);
			song.AddPaletteChange(5, 0);
			song.AddPaletteFade(6, 1000, 1);
			song.AddPaletteFade(7, 1000, 2);
			song.AddPaletteFade(8, 1000, 3);
			song.AddPaletteFade(9, 1000, 4);
			song.AddPaletteFade(10, 1000, 5);
			song.AddPaletteFade(11, 1000, 6);
			song.AddPaletteFade(12, 1000, 7);
			song.AddPaletteChange(13, 0);

			// SyncSquares (13)
			var syncSquares = SyncSquares();
			song.AddSegment(syncSquares, 29588, 48980, 13, 8);

			// SineShine (21)
			var sineShine = SineShine();
			song.AddSegment(sineShine, 0, 1, 21, 1, 12);
			song.AddPaletteChange(21, 0);
			song.AddPaletteFade(25, 1000, 1);
			song.AddPaletteFade(29, 1000, 2);
			song.AddPaletteChange(33, 0);

			// Crowd (33)
			var crowd = Crowd();
			song.AddSegment(crowd, 0, 250 * 3, 33, 12);

			// Wavey (45)
			var wavey = Wavey();
			song.AddSegment(wavey, 0, 1, 45, 1, 8);
			song.AddPaletteChange(45, 0);
			song.AddPaletteFade(46, 500, 1);
			song.AddPaletteFade(47, 500, 2);
			song.AddPaletteFade(48, 500, 3);
			song.AddPaletteFade(49, 500, 4);
			song.AddPaletteFade(50, 500, 5);
			song.AddPaletteFade(51, 500, 6);
			song.AddPaletteFade(52, 500, 7);
			song.AddPaletteChange(53, 0);

			// RainbowSquare (53)
			var rainbowSquare = RainbowSquare();
			song.AddSegment(rainbowSquare, 0, 1000, 53, 1, 16);
			song.AddPaletteChange(53, 0);
			song.AddPaletteFade(57, 1000, 1);
			song.AddPaletteFade(61, 1000, 2);
			song.AddPaletteFade(65, 1000, 3);
			song.AddPaletteChange(69, 0);

			// Stairs (69)
			var stairs = Stairs();
			song.AddSegment(stairs, 0, 360, 69, 1, 13);
			song.AddPaletteChange(69, 0);
			song.AddPaletteFade(73, 1000, 1);
			song.AddPaletteFade(77, 1000, 2);
			song.AddPaletteChange(81.25, 81.5, 3);
			song.AddPaletteChange(82, 0);

			return song;
		}