Esempio n. 1
0
        private static GloCommandContainer SamplesToCommands(Sample[] samples)
        {
            GloCommandContainer container = new GloCommandContainer(null, "END");
            GloColor            lastColor = GloColor.Black;
            int lastTick = 0;

            for (int i = 0; i < samples.Length; i++)
            {
                int delay = samples[i].ticks - lastTick;
                if (delay > 0)
                {
                    if (samples[i].colBefore == lastColor)
                    {
                        container.Commands.Add(new GloDelayCommand(delay));
                    }
                    else
                    {
                        container.Commands.Add(new GloRampCommand(samples[i].colBefore, delay));
                        lastColor = samples[i].colBefore;
                    }
                }

                if (samples[i].colAfter != lastColor)
                {
                    container.Commands.Add(new GloColorCommand(samples[i].colAfter));
                    lastColor = samples[i].colAfter;
                }

                lastTick = samples[i].ticks;
            }

            return(container);
        }
Esempio n. 2
0
        private static void WriteCommands(GloCommandContainer container, string file)
        {
            // convert commands to their string representation
            var commandStrings = container.ToGloLines();

            var lines = Enumerable.Repeat("; Generated by Glow Sequencer version " + GetProgramVersion() + " at " + DateTime.Now + ".", 1).Concat(commandStrings);

            System.IO.File.WriteAllLines(file, lines, Encoding.ASCII);
        }
Esempio n. 3
0
        public static void ExportTrack(Track track, string filename, float startTime = 0)
        {
            // Algorithm "back-to-front rendering" := every block paints all affected samples with its data
            // Each sample stores "color up to this point" and "color from this point forward" along with the block that set the respective half.
            // After painting is complete, all samples that just pass through a single block are redundant.

            Sample[]            samples          = CollectSamples(track, startTime);
            GloCommandContainer commandContainer = SamplesToCommands(samples);

            OptimizeCommands(commandContainer.Commands);

            // write to file
            WriteCommands(commandContainer, filename);
        }