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.
18 using System.Diagnostics;
19 using Native = Interop.AudioEffect;
21 namespace Tizen.Multimedia
25 /// Represents an equalizer band of <see cref="AudioEffect"/>.
27 /// <since_tizen> 3 </since_tizen>
28 public class EqualizerBand
30 private readonly AudioEffect _owner;
31 private readonly int _index;
33 internal EqualizerBand(AudioEffect owner, int index)
35 Debug.Assert(owner != null);
40 Native.GetEqualizerBandFrequency(_owner.Player.Handle, _index, out var frequency).
41 ThrowIfFailed(_owner.Player, "Failed to initialize equalizer band");
43 Native.GetEqualizerBandFrequencyRange(_owner.Player.Handle, _index, out var range).
44 ThrowIfFailed(_owner.Player, "Failed to initialize equalizer band");
46 Frequency = frequency;
47 FrequencyRange = range;
48 Log.Debug(PlayerLog.Tag, "frequency : " + frequency + ", range : " + range);
52 /// Sets or gets the gain for the equalizer band.
54 /// <param name="value">The value indicating new gain in decibel(dB).</param>
55 /// <exception cref="ObjectDisposedException">The player that this EqualizerBand belongs to has already been disposed of.</exception>
56 /// <exception cref="ArgumentOutOfRangeException">
57 /// <paramref name="value"/> is not inside of <see cref="AudioEffect.BandLevelRange"/>.
59 /// <since_tizen> 3 </since_tizen>
64 _owner.Player.ValidateNotDisposed();
66 Native.GetEqualizerBandLevel(_owner.Player.Handle, _index, out var value).
67 ThrowIfFailed(_owner.Player, "Failed to get the level of the equalizer band");
69 Log.Info(PlayerLog.Tag, "get level : " + value);
74 _owner.Player.ValidateNotDisposed();
76 if (value < _owner.BandLevelRange.Min || _owner.BandLevelRange.Max < value)
78 Log.Error(PlayerLog.Tag, "invalid level : " + value);
79 throw new ArgumentOutOfRangeException(nameof(value), value,
80 $"valid value range is { nameof(AudioEffect.BandLevelRange) }." +
84 Native.SetEqualizerBandLevel(_owner.Player.Handle, _index, value).
85 ThrowIfFailed(_owner.Player, "Failed to set the level of the equalizer band");
91 /// Gets the frequency in the dB.
93 /// <since_tizen> 3 </since_tizen>
94 public int Frequency { get; }
97 /// Gets the frequency range in the dB.
99 /// <since_tizen> 3 </since_tizen>
100 public int FrequencyRange { get; }