private static void UpdateLights()
        {
            int?newBrightness = null;
            ColorInformation colorInformation = new ColorInformation();

            switch (PartyOptions.activePartyOption.brightnessOptionIndex)
            {
            case 1:
                newBrightness = SetRandomBrightness();
                break;
            }

            switch (PartyOptions.activePartyOption.colorOptionIndex)
            {
            case 2:
                colorInformation = LightProcessingColor.SetRandomColorFromUIInput();
                break;
            }

            if (BridgeInformation.usedLights.Count > 0)
            {
                BasicLightController.SendCommonCommond();
            }

            if (newBrightness != null || colorInformation.rgbColor != null || colorInformation.colorTemperature != null)
            {
                PartyUIUpdater.UpdateOutputDisplay(newBrightness, colorInformation.rgbColor, colorInformation.colorTemperature);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Converts the raw audio level to a audio level from 0 to 100 and calls the necessary following methods.
        /// </summary>
        /// <param name="rawLevel"></param>
        private static void NewRawSoundLevel(double rawLevel)
        {
            rawLevel += 100;
            rawLevel  = rawLevel < 0 ? 0 : rawLevel;
            rawLevel  = rawLevel > 100 ? 100 : rawLevel;

            if (!Double.IsNaN(rawLevel))
            {
                double soundLevel = CalculateAverage(rawLevel);

                LightProcessingSoundInput.NewSoundLevel(soundLevel);
                PartyUIUpdater.NewSoundLevel(soundLevel);
            }
        }
        public static void SetUpdateInterval(string intervalInSecondsString)
        {
            if (float.TryParse(intervalInSecondsString, out float intervalInSeconds))
            {
                if (intervalInSeconds >= 0.2f)
                {
                    updateInterval = Convert.ToInt32(intervalInSeconds * 1000);

                    PartyUIUpdater.NewRandomInterval(intervalInSeconds);
                    PartyOptions.activePartyOption.randomInterval = intervalInSeconds;
                }
            }

            PartyUIUpdater.UpdateRandomIntervalTextBoxes();
        }
Beispiel #4
0
        private static ColorInformation ProcessInputDifferenceColor(double soundLevel)
        {
            ColorInformation colorInformation = new ColorInformation();

            double inputDifference = soundLevel - savedSoundLevel;

            if (inputDifference > PartyOptions.activePartyOption.colorDifferencePercent)
            {
                colorInformation = LightProcessingColor.SetRandomColorFromUIInput();
            }

            PartyUIUpdater.NewInputDifference(inputDifference);
            savedSoundLevel = soundLevel;

            return(colorInformation);
        }
Beispiel #5
0
        public static void NewSoundLevel(double soundLevel)
        {
            if (callCount > 8)
            {
                int?newBrightness = null;
                ColorInformation colorInformation = new ColorInformation();

                switch (PartyOptions.activePartyOption.brightnessOptionIndex)
                {
                case 0:
                    newBrightness = ProcessSoundLevelBrightness(soundLevel);
                    break;
                }

                switch (PartyOptions.activePartyOption.colorOptionIndex)
                {
                case 0:
                    colorInformation = LightProcessingColor.SetColorGradienStep((float)soundLevel / 100f);
                    break;

                case 1:
                    colorInformation = ProcessInputDifferenceColor(soundLevel);
                    break;
                }

                if (BridgeInformation.usedLights.Count > 0)
                {
                    BasicLightController.SendCommonCommond();
                }

                if (newBrightness != null || colorInformation.rgbColor != null || colorInformation.colorTemperature != null)
                {
                    PartyUIUpdater.UpdateOutputDisplay(newBrightness, colorInformation.rgbColor, colorInformation.colorTemperature);
                }

                callCount = 0;
            }

            callCount++;
        }