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();
        });
Beispiel #2
0
        public void RemoveAllAdjustments(AdjustableProperty type)
        {
            var aggregate = getAggregate(type);

            aggregate.RemoveAllSources();
            aggregate.AddSource(getProperty(type));
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #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);
        }
        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;
            }
        }
Beispiel #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();
        });
Beispiel #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);
         }
     }
 }
Beispiel #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));
        }
Beispiel #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();
        }
 public void RemoveAllAdjustments(AdjustableProperty type) => throw new NotSupportedException();
 public void RemoveAdjustment(AdjustableProperty type, IBindable <double> adjustBindable) => throw new NotSupportedException();
Beispiel #15
0
 public void RemoveAllAdjustments(AdjustableProperty type) => adjustments.RemoveAllAdjustments(type);
Beispiel #16
0
 public void RemoveAdjustment(AdjustableProperty type, IBindable <double> adjustBindable)
 => adjustments.RemoveAdjustment(type, adjustBindable);
 public IBindable <double> GetAggregate(AdjustableProperty type) => adjustments.GetAggregate(type);
Beispiel #18
0
 public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable) =>
 adjustments.AddAdjustment(type, adjustBindable);
Beispiel #19
0
 public void AddAdjustment(AdjustableProperty type, IBindable <double> adjustBindable)
 => getAggregate(type).AddSource(adjustBindable);
Beispiel #20
0
 public void RemoveAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable) => throw new NotImplementedException();
Beispiel #21
0
 public void AddAdjustment(AdjustableProperty type, IBindable <double> adjustBindable)
 {
     sample.AddAdjustment(type, adjustBindable);
 }
Beispiel #22
0
 public void RemoveAllAdjustments(AdjustableProperty type)
 {
     sample.RemoveAllAdjustments(type);
 }
 public void AddAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable) =>
 adjustments.AddAdjustment(type, adjustBindable);
 public IBindable <double> GetAggregate(AdjustableProperty type) => throw new NotSupportedException();
Beispiel #25
0
 public void AddAdjustment(AdjustableProperty type, IBindable <double> adjustBindable) => throw new NotImplementedException();
Beispiel #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.");
            }
        }
Beispiel #28
0
 public IBindable <double> GetAggregate(AdjustableProperty type)
 => getAggregate(type).Result;
Beispiel #29
0
 public void AddAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable) => throw new NotSupportedException();