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);
43 Native.GetEqualizerBandFrequency(_owner.Player.Handle, _index, out frequency).
44 ThrowIfFailed("Failed to initialize equalizer band");
46 Native.GetEqualizerBandFrequencyRange(_owner.Player.Handle, _index, out range).
47 ThrowIfFailed("Failed to initialize equalizer band");
49 Frequency = frequency;
50 FrequencyRange = range;
51 Log.Debug(PlayerLog.Tag, "frequency : " + frequency + ", range : " + range);
55 /// Sets or gets the gain for the equalizer band.
57 /// <param name="value">The value indicating new gain in decibel(dB).</param>
58 /// <exception cref="ObjectDisposedException">The player that this EqualizerBand belongs to has already been disposed of.</exception>
59 /// <exception cref="ArgumentOutOfRangeException">
60 /// <paramref name="value"/> is not inside of <see cref="AudioEffect.BandLevelRange"/>.
62 /// <since_tizen> 3 </since_tizen>
67 _owner.Player.ValidateNotDisposed();
70 Native.GetEqualizerBandLevel(_owner.Player.Handle, _index, out value).
71 ThrowIfFailed("Failed to get the level of the equalizer band");
72 Log.Info(PlayerLog.Tag, "get level : " + value);
77 _owner.Player.ValidateNotDisposed();
79 if (value < _owner.BandLevelRange.Min || _owner.BandLevelRange.Max < value)
81 Log.Error(PlayerLog.Tag, "invalid level : " + value);
82 throw new ArgumentOutOfRangeException(nameof(value), value,
83 $"valid value range is { nameof(AudioEffect.BandLevelRange) }." +
87 Native.SetEqualizerBandLevel(_owner.Player.Handle, _index, value).
88 ThrowIfFailed("Failed to set the level of the equalizer band");
94 /// Gets the frequency in the dB.
96 /// <since_tizen> 3 </since_tizen>
97 public int Frequency { get; }
100 /// Gets the frequency range in the dB.
102 /// <since_tizen> 3 </since_tizen>
103 public int FrequencyRange { get; }