public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable) => EnqueueAction(() =>
        {
            switch (type)
            {
            case AdjustableProperty.Balance:
                if (balanceAdjustments.Contains(adjustBindable))
                {
                    throw new ArgumentException("An adjustable binding may only be registered once.");
                }

                balanceAdjustments.Add(adjustBindable);
                break;

            case AdjustableProperty.Frequency:
                if (frequencyAdjustments.Contains(adjustBindable))
                {
                    throw new ArgumentException("An adjustable binding may only be registered once.");
                }

                frequencyAdjustments.Add(adjustBindable);
                break;

            case AdjustableProperty.Volume:
                if (volumeAdjustments.Contains(adjustBindable))
                {
                    throw new ArgumentException("An adjustable binding may only be registered once.");
                }

                volumeAdjustments.Add(adjustBindable);
                break;
            }

            InvalidateState();
        });
Пример #2
0
        public void RemoveAllAdjustments(AdjustableProperty type)
        {
            var aggregate = getAggregate(type);

            aggregate.RemoveAllSources();
            aggregate.AddSource(getProperty(type));
        }
Пример #3
0
        public void TestMultiplicativeComponent(AdjustableProperty type)
        {
            var adjustments = new AudioAdjustments();

            adjustments.AddAdjustment(type, new BindableDouble(0.5));
            adjustments.AddAdjustment(type, new BindableDouble(0.5));

            Assert.AreEqual(0.25, adjustments.GetAggregate(type).Value);
        }
Пример #4
0
        public void TestAddAdjustment([Values] AdjustableProperty type)
        {
            var adjustments = new AudioAdjustments();

            Assert.IsTrue(adjustments.GetAggregate(type).IsDefault);

            adjustments.AddAdjustment(type, new BindableDouble(0.5));

            Assert.IsFalse(adjustments.GetAggregate(type).IsDefault);
        }
Пример #5
0
        private Func <double, double, double> getAggregateFunction(AdjustableProperty type)
        {
            switch (type)
            {
            default:
                return((a, b) => a * b);

            case AdjustableProperty.Balance:
                return((a, b) => a + b);
            }
        }
Пример #6
0
        public void TestRemoveAllAdjustmentsRemovesExternalBindings([Values] AdjustableProperty type)
        {
            var adjustments = new AudioAdjustments();

            Assert.IsTrue(adjustments.GetAggregate(type).IsDefault);

            adjustments.AddAdjustment(type, new BindableDouble(0.5));
            adjustments.AddAdjustment(type, new BindableDouble(0.5));

            adjustments.RemoveAllAdjustments(type);

            Assert.IsTrue(adjustments.GetAggregate(type).IsDefault);
        }
Пример #7
0
        public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
        {
            switch (type)
            {
            case AdjustableProperty.Balance:
                balanceAggregate.RemoveSource(adjustBindable);
                break;

            case AdjustableProperty.Frequency:
                frequencyAggregate.RemoveSource(adjustBindable);
                break;

            case AdjustableProperty.Volume:
                volumeAggregate.RemoveSource(adjustBindable);
                break;
            }
        }
Пример #8
0
        private ref AggregateBindable <double> getAggregate(AdjustableProperty type)
        {
            switch (type)
            {
            case AdjustableProperty.Balance:
                return(ref balanceAggregate);

            case AdjustableProperty.Frequency:
                return(ref frequencyAggregate);

            case AdjustableProperty.Volume:
                return(ref volumeAggregate);

            case AdjustableProperty.Tempo:
                return(ref tempoAggregate);
            }

            throw new ArgumentException($"{nameof(AdjustableProperty)} \"{type}\" is missing mapping", nameof(type));
        }
        public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable) => EnqueueAction(() =>
        {
            switch (type)
            {
            case AdjustableProperty.Balance:
                balanceAdjustments.Remove(adjustBindable);
                break;

            case AdjustableProperty.Frequency:
                frequencyAdjustments.Remove(adjustBindable);
                break;

            case AdjustableProperty.Volume:
                volumeAdjustments.Remove(adjustBindable);
                break;
            }

            InvalidateState();
        });
Пример #10
0
 public void PopulateAdjustableProperties()
 {
     if (_selectedResponse != null)
     {
         _adjustableProperties.Clear();
         var responseType           = _selectedResponse.GetType();
         var adjustablePropertyList = PlottingUtilities.GetAllAdjustableProperties(responseType);
         var headerItem             = new AdjustableProperty
         {
             PropertyName = AdjustableProperty._header,
         };
         AdjustableProperty1 = headerItem;
         AdjustableProperties.Add(headerItem);
         foreach (var adjustableProperty in adjustablePropertyList)
         {
             AdjustableProperties.Add(adjustableProperty);
         }
     }
 }
Пример #11
0
        private BindableNumber <double> getProperty(AdjustableProperty type)
        {
            switch (type)
            {
            case AdjustableProperty.Balance:
                return(Balance);

            case AdjustableProperty.Frequency:
                return(Frequency);

            case AdjustableProperty.Volume:
                return(Volume);

            case AdjustableProperty.Tempo:
                return(Tempo);
            }

            throw new ArgumentException($"{nameof(AdjustableProperty)} \"{type}\" is missing mapping", nameof(type));
        }
Пример #12
0
        public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
        {
            switch (type)
            {
            case AdjustableProperty.Balance:
                balanceAdjustments.Add(adjustBindable);
                break;

            case AdjustableProperty.Frequency:
                frequencyAdjustments.Add(adjustBindable);
                break;

            case AdjustableProperty.Volume:
                volumeAdjustments.Add(adjustBindable);
                break;
            }

            InvalidateState();
        }
Пример #13
0
 public void RemoveAllAdjustments(AdjustableProperty type) => throw new NotSupportedException();
Пример #14
0
 public void RemoveAdjustment(AdjustableProperty type, IBindable <double> adjustBindable) => throw new NotSupportedException();
Пример #15
0
 public void RemoveAllAdjustments(AdjustableProperty type) => adjustments.RemoveAllAdjustments(type);
Пример #16
0
 public void RemoveAdjustment(AdjustableProperty type, IBindable <double> adjustBindable)
 => adjustments.RemoveAdjustment(type, adjustBindable);
Пример #17
0
 public IBindable <double> GetAggregate(AdjustableProperty type) => adjustments.GetAggregate(type);
Пример #18
0
 public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable) =>
 adjustments.AddAdjustment(type, adjustBindable);
Пример #19
0
 public void AddAdjustment(AdjustableProperty type, IBindable <double> adjustBindable)
 => getAggregate(type).AddSource(adjustBindable);
Пример #20
0
 public void RemoveAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable) => throw new NotImplementedException();
Пример #21
0
 public void AddAdjustment(AdjustableProperty type, IBindable <double> adjustBindable)
 {
     sample.AddAdjustment(type, adjustBindable);
 }
Пример #22
0
 public void RemoveAllAdjustments(AdjustableProperty type)
 {
     sample.RemoveAllAdjustments(type);
 }
 public void AddAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable) =>
 adjustments.AddAdjustment(type, adjustBindable);
Пример #24
0
 public IBindable <double> GetAggregate(AdjustableProperty type) => throw new NotSupportedException();
Пример #25
0
 public void AddAdjustment(AdjustableProperty type, IBindable <double> adjustBindable) => throw new NotImplementedException();
Пример #26
0
 public void RemoveAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable)
 => getAggregate(type).RemoveSource(adjustBindable);
        public static IBindable <double> GetAggregate(this IAggregateAudioAdjustment adjustment, AdjustableProperty type)
        {
            switch (type)
            {
            case AdjustableProperty.Volume:
                return(adjustment.AggregateVolume);

            case AdjustableProperty.Balance:
                return(adjustment.AggregateBalance);

            case AdjustableProperty.Frequency:
                return(adjustment.AggregateFrequency);

            case AdjustableProperty.Tempo:
                return(adjustment.AggregateTempo);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), "Invalid adjustable property type.");
            }
        }
Пример #28
0
 public IBindable <double> GetAggregate(AdjustableProperty type)
 => getAggregate(type).Result;
Пример #29
0
 public void AddAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable) => throw new NotSupportedException();