public void SetFlag(ChannelFlag flag, bool value) { var optionKey = flag.ToOptionKey(); var choiceDesc = ChoiceKeys.BooleanToChoice(value); _config.SetChoice(optionKey, choiceDesc, _channelId); }
public GenerationLayer( LayerMode Mode = LayerMode.Multiply, ChannelFlag Channels = ChannelFlag.A | ChannelFlag.B | ChannelFlag.G | ChannelFlag.R, bool Visible = true) { this.Generator = new FractalGenerator(0); this.Mode = Mode; this.Channels = Channels; this.Visible = Visible; }
/// <summary> /// Converts a <see cref="ChannelFlag" /> to an <see cref="OptionKey" />. /// </summary> /// <param name="flag">The channel flag to convert.</param> /// <returns>The corresponding option key.</returns> /// <exception cref="InvalidEnumArgumentException"></exception> /// <exception cref="ArgumentOutOfRangeException"></exception> public static OptionKey ToOptionKey(this ChannelFlag flag) { if (!Enum.IsDefined(typeof(ChannelFlag), flag)) { throw new InvalidEnumArgumentException(nameof(flag), (int)flag, typeof(ChannelFlag)); } return(flag switch { ChannelFlag.AutoAdvance => OptionKey.AutoAdvance, ChannelFlag.PlayOnLoad => OptionKey.AutoPlay, _ => OptionKey.Invalid });
public void TestChannelFlag_ToOptionKey_RoundTrip(ChannelFlag flag) { Assert.Equal(flag, flag.ToOptionKey().ToChannelFlag()); }
/// <summary> /// Implements a change of auto-advance to the given new value. /// </summary> /// <param name="setting">The setting to query.</param> /// <param name="newValue">The intended new value for auto-advance.</param> protected abstract void SetConfigFlag(ChannelFlag setting, bool newValue);
/// <summary> /// Gets whether a particular channel config setting can be toggled. /// </summary> /// <param name="setting">The setting to query.</param> /// <returns>Whether a toggle action for the given config setting can fire.</returns> protected abstract bool CanToggleConfig(ChannelFlag setting);
protected override void SetConfigFlag(ChannelFlag setting, bool newValue) { // Deliberately ignored }
protected override bool CanToggleConfig(ChannelFlag setting) { return(setting == ChannelFlag.AutoAdvance); }
static bool TryReadConfig(bool firstTime) { lock (_lockReadConfig) { XmlNode node; _configDocument.Load(_configFile); int oldDepth = _depth; string oldImpulsePath = _impulsePath; int oldBands = _eqBands; double oldLoudness = _eqLoudness; double oldFlatness = _eqFlatness; string oldMatrixFilter = _matrixFilter; string oldBFormatFilter = _bformatFilter; FilterProfile oldValues = new FilterProfile(_eqValues); _isBypass = nodeValueBool(_configDocument, "//InguzEQSettings/Client/@Bypass"); // SignalGenerator mode: if there's a "SignalGenerator" element it overrides normal processing. _siggen = null; node = _configDocument.SelectSingleNode("//InguzEQSettings/Client/SignalGenerator"); if (node != null) { _siggenUseEQ = ChannelFlag.NONE; string useEQ = nodeValue(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@UseEQ"); if (!String.IsNullOrEmpty(useEQ)) { switch (useEQ.ToUpperInvariant()) { case "1": case "YES": case "TRUE": case "BOTH": _siggenUseEQ = ChannelFlag.BOTH; break; case "L": _siggenUseEQ = ChannelFlag.LEFT; break; case "R": _siggenUseEQ = ChannelFlag.RIGHT; break; } } _siggen = nodeValueUpper(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@Type"); if (_siggen != null) { switch (_siggen) { case "IDENT": _sigparamA = nodeValue(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@L"); _sigparamB = nodeValue(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@R"); break; case "SWEEP": _sigparam1 = nodeValueInt(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@Length"); break; case "SINE": case "QUAD": case "SQUARE": case "BLSQUARE": case "TRIANGLE": case "BLTRIANGLE": case "SAWTOOTH": case "BLSAWTOOTH": _sigparam1 = nodeValueInt(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@Freq"); break; case "WHITE": break; case "PINK": // "Mono" param defaults to true for backward compatibility _sigparam1 = 1; string mono = nodeValue(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@Mono"); if (!String.IsNullOrEmpty(mono)) { _sigparam1 = bool.Parse(mono) ? 1 : 0; } break; case "INTERMODULATION": _sigparam1 = nodeValueInt(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@Freq1"); _sigparam2 = nodeValueInt(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@Freq2"); _sigparam3 = nodeValueInt(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@Freq3"); break; case "SHAPEDBURST": _sigparam1 = nodeValueInt(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@Freq"); _sigparam2 = nodeValueInt(_configDocument, "//InguzEQSettings/Client/SignalGenerator/@Cycles"); break; default: _siggen = null; break; } } } // Impulse path can be changed at runtime. Null or "" or "-" are all OK (null) values. node = _configDocument.SelectSingleNode("//InguzEQSettings/Client/Filter"); // @URL"); _impulsePath = node == null ? "" : node.InnerText; // Same for stereo-width ('matrix') filter node = _configDocument.SelectSingleNode("//InguzEQSettings/Client/Matrix"); // @URL"); _matrixFilter = node == null ? "" : node.InnerText; // Same for ambisonic filter (not documented) node = _configDocument.SelectSingleNode("//InguzEQSettings/Client/BFormat"); // @URL"); _bformatFilter = node == null ? "" : node.InnerText; node = _configDocument.SelectSingleNode("//InguzEQSettings/Client/EQ/@Bands"); _eqBands = (node == null) ? 0 : int.Parse(node.Value, CultureInfo.InvariantCulture); _eqValues.Clear(); XmlNodeList nodes = _configDocument.SelectNodes("//InguzEQSettings/Client/EQ/Band"); if (nodes != null) { foreach (XmlNode bnode in nodes) { string att; att = ((XmlElement)bnode).GetAttribute("Freq"); double freq = (att == null) ? 0 : double.Parse(att, CultureInfo.InvariantCulture); if (freq >= 10 && freq < 48000) { att = ((XmlElement)bnode).InnerText; //.GetAttribute("dB"); double gain = (att == null) ? 0 : double.Parse(att, CultureInfo.InvariantCulture); if (gain < -20) gain = -20; if (gain > 20) gain = 20; _eqValues.Add(new FreqGain(freq, gain)); } } } _eqLoudness = nodeValuePercentage(_configDocument, "//InguzEQSettings/Client/Quietness", 0); _eqFlatness = nodeValuePercentage(_configDocument, "//InguzEQSettings/Client/Flatness", 100); node = _configDocument.SelectSingleNode("//InguzEQSettings/Client/Width"); _width = (node == null) ? 0 : double.Parse(node.InnerText, CultureInfo.InvariantCulture); double fracWid = _width / 2; _widthShuffler.SigmaGain = MathUtil.gain(-fracWid); _widthShuffler.DeltaGain = MathUtil.gain(fracWid); // UI specifies width in dB // Depth not documented (and not really working either) node = _configDocument.SelectSingleNode("//InguzEQSettings/Client/Depth"); _depth = (node == null) ? 0 : int.Parse(node.InnerText, CultureInfo.InvariantCulture); // _depthSkewer.Skew = _depth; node = _configDocument.SelectSingleNode("//InguzEQSettings/Client/Balance"); _balance = (node == null) ? 0 : double.Parse(node.InnerText, CultureInfo.InvariantCulture); SetWriterGain(); node = _configDocument.SelectSingleNode("//InguzEQSettings/Client/Skew"); _skew = (node == null) ? 0 : int.Parse(node.InnerText, CultureInfo.InvariantCulture); _skewSkewer.Skew = _skew; // <AmbisonicDecode Type="XXX" Cardioid="N" Angle="N" File="path"> // // For 2ch Ambisonic decodes (stereo UHJ, stereo Blumlein, etc), the type is specified in a parameter _ambiType = nodeValue(_configDocument, "//InguzEQSettings/Client/AmbisonicDecode/@Type"); if (!String.IsNullOrEmpty(_ambiType) && _ambiType.ToUpperInvariant() == "MATRIX") { _aftenNeeded = true; } _ambiCardioid = nodeValueDouble(_configDocument, "//InguzEQSettings/Client/AmbisonicDecode/@Cardioid"); _ambiMicAngle = nodeValueDouble(_configDocument, "//InguzEQSettings/Client/AmbisonicDecode/@Angle"); _ambiRotateX = nodeValueDouble(_configDocument, "//InguzEQSettings/Client/AmbisonicDecode/@RotateX"); _ambiRotateY = nodeValueDouble(_configDocument, "//InguzEQSettings/Client/AmbisonicDecode/@RotateY"); _ambiRotateZ = nodeValueDouble(_configDocument, "//InguzEQSettings/Client/AmbisonicDecode/@RotateZ"); // For other Ambisonic decodes, the full decode matrix // is defined in a file, specified in config _ambiMatrixFile = nodeText(_configDocument, "//InguzEQSettings/Client/AmbisonicDecode/@File"); if (!firstTime) { bool eqChanged = false; if ((_eqBands != oldBands) || (_eqLoudness != oldLoudness) || (_eqFlatness != oldFlatness)) { eqChanged = true; } else { for (int n = 0; n < _eqValues.Count; n++) { if (_eqValues[n].Gain != oldValues[n].Gain || _eqValues[n].Gain != oldValues[n].Gain) { eqChanged = true; break; } } } if (eqChanged || (oldImpulsePath != _impulsePath)) { // Notify the convolver that there's a new impulse file LoadImpulse(); } if ((oldMatrixFilter != _matrixFilter) || (_depth != oldDepth)) { LoadMatrixFilter(); } if (oldBFormatFilter != _bformatFilter) { LoadBFormatFilter(); } } return true; } }