2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System.Diagnostics;
18 using Native = Interop.AudioEffect;
20 namespace Tizen.Multimedia
24 /// Represents a equalizer band of <see cref="AudioEffect"/>.
26 public class EqualizerBand
28 private readonly AudioEffect _owner;
29 private readonly int _index;
31 internal EqualizerBand(AudioEffect owner, int index)
33 Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
34 Debug.Assert(owner != null);
42 Native.GetEqualizerBandFrequency(_owner.Player.Handle, _index, out frequency).
43 ThrowIfFailed("Failed to initialize equalizer band");
45 Native.GetEqualizerBandFrequencyRange(_owner.Player.Handle, _index, out range).
46 ThrowIfFailed("Failed to initialize equalizer band");
48 Frequency = frequency;
49 FrequencyRange = range;
50 Log.Debug(PlayerLog.Tag, "frequency : " + frequency + ", range : " + range);
54 /// Sets or gets the gain for the equalizer band.
56 /// <param name="value">The value indicating new gain in decibel(dB).</param>
57 /// <exception cref="ObjectDisposedException">The player that this EqualizerBand belongs to has already been disposed of.</exception>
58 /// <exception cref="ArgumentOutOfRangeException">
59 /// <paramref name="value"/> is less than <see cref="AudioEffect.MinBandLevel"/>.\n
61 /// <paramref name="value"/> is greater than <see cref="AudioEffect.MaxBandLevel"/>.
67 Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
68 _owner.Player.ValidateNotDisposed();
71 Native.GetEqualizerBandLevel(_owner.Player.Handle, _index, out value).
72 ThrowIfFailed("Failed to get the level of the equalizer band");
73 Log.Info(PlayerLog.Tag, "get level : " + value);
78 Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
79 _owner.Player.ValidateNotDisposed();
81 if (value < _owner.BandLevelRange.Min || _owner.BandLevelRange.Max < value)
83 Log.Error(PlayerLog.Tag, "invalid level : " + value);
84 throw new ArgumentOutOfRangeException(nameof(value), value,
85 $"valid value range is { nameof(AudioEffect.BandLevelRange) }." +
89 Native.SetEqualizerBandLevel(_owner.Player.Handle, _index, value).
90 ThrowIfFailed("Failed to set the level of the equalizer band");
96 /// Gets the frequency in dB.
98 public int Frequency { get; }
101 /// Gets the frequency range in dB.
103 public int FrequencyRange { get; }