/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

module NMM {

  /** Interface for controlling the volume of an audio output device.
   *
   * This interface is implemented by audio sink nodes which support volume control. It provides methods for
   * setting the volume, querying the currently set volume and the possible range of volumes. The interface
   * allows both attenuation and amplification if supported by the audio device (this can be queried by
   * getVolumeRange). Volumes can be specified as linear quantities (represented as rational numbers) or as
   * logarithmic quantities in dezibel (db) (represented as floating-point values). Note that the granularity
   * of the device may be less than the resolution of the types used by this interface.
   */
  interface IVolumeControl {
    /** Set the linear volume of an audio output device.
     *
     * This methods sets the volume of an audio output device. The volume is given as a linear quantity
     * where 0 means "silence", values between 0 and 1 mean attenuation and values greater than 1 mean
     * amplification. The volume is internally clipped to the range of possible values.
     *
     * Examples:
     * @code
     * setLinearVolume(Rational(1,1));    // set volume to 1   (no attenuation or amplification)
     * setLinearVolume(Rational(0,1));    // set volume to 0   (silence)
     * setLinearVolume(Rational(1,2));    // set volume to 1/2 (50% attenuation)
     * @endcode
     *
     * @param linear_volume The linear volume
     * @return The new linear volume
     */
    Rational setLinearVolume(in Rational linear_volume);

    /** Set the linear volume of an audio output device relative to the current volume.
     *
     * This methods increases or decreases the volume of an audio output device by adding a linear offset to
     * the current linear volume, which can be positive or negative. The volume is internally clipped to the
     * range of possible values.
     *
     * This method should be used in favour of setLinearVolume/getLinearVolume when the volume is set relative
     * to the current volume (as opposed to absolute), especially in distributed scenarios, to reduce the number
     * of (distributed) method calls.
     *
     * Examples:
     * @code
     * setLinearVolumeRelative(Rational(1,10));    // increase linear volume by 1/10
     * @endcode
     *
     * @param relative_linear_volume Linear offset to add to current linear volume.
     * @return The new absolute linear volume
     */
    Rational setLinearVolumeRelative(in Rational relative_linear_volume);

    /** Get the linear volume of an audio output device.
     *
     * This method returns the volume of an audio output device. The volume is given as a linear quantity
     * where 0 means "silence", values between 0 and 1 mean attenuation and values greater than 1 mean
     * amplification.
     *
     * @return The linear volume
     */
    Rational getLinearVolume() const;

    /** Set the logarithmic volume of an audio output device.
     *
     * This sets returns the volume of an audio output device. The volume is given as a logarithmic quantity
     * in dezibel (dB) where 0 means no attenuation or amplification, -INFINITY means silence and positive values
     * mean amplification.  The volume is internally clipped to the range of possible values.
     *
     * @param volume_in_db The logarithmic volume in dezibel (dB)
     * @return The new logarithmic volume in dezibel (dB)
     */
    nmm_double setLogarithmicVolume(in nmm_double volume_in_db);

    /** Set the logarithmic volume of an audio output device relative to the current logarithmic volume.
     *
     * This sets returns the volume of an audio output device. This is done by adding an offsrt in dezibel (dB)
     * to the current logarithmic volume. The volume is internally clipped to the range of possible values.
     *
     * This method should be used in favour of setLogarithmicVolume/getLogarithmicVolume when the volume is set relative
     * to the current volume (as opposed to absolute), especially in distributed scenarios, to reduce the number
     * of (distributed) method calls.
     *
     * Examples:
     * @code
     * setLogarithmicVolumeRelative(6);    // decrease volume by 6 dB (set volume to approx. 2 times the current volume)
     * setLogarithmicVolumeRelative(-6);   // decrease volume by 6 dB (set volume to approx. half the current volume)
     * @endcode
     *
     * @param relative_volume_in_db The logarithmic volume offset in dezibel (dB)
     * @return The new absolute logarithmic volume in dezibel (dB)
     */
    nmm_double setLogarithmicVolumeRelative(in nmm_double relative_volume_in_db);

    /** Get the logarithmic volume of an audio output device.
     *
     * This methods returns the volume of an audio output device. The volume is given as a logarithmic quantity
     * in dezibel (dB) where 0 means no attenuation or amplification, -INFINITY means silence and positive values
     * mean amplification.
     *
     * @return The logarithmic volume in dezibel (dB)
     */
    nmm_double getLogarithmicVolume() const;
    
    /** Get the linear volume range of an audio output device.
     *
     * This method returns the volume range of an audio output device. The volume is given as a linear quantity
     * where 0 means "silence", values between 0 and 1 mean attenuation and values greater than 1 mean
     * amplification.
     *
     * @param min_linear_volume Returns the minimum linear volume
     * @param max_linear_volume Returns the maximum linear volume
     */
    void getLinearVolumeRange(out Rational min_linear_volume, out Rational max_linear_volume) const;

    /** Get the logarithmic volume range of an audio output device.
     *
     * This method returns the volume range of an audio output device. The volume is given as a logarithmic quantity
     * in dezibel (dB) where 0 means no attenuation or amplification, -INFINITY means silence and positive values
     * mean amplification.
     *
     * @param min_volume_in_db Returns the minimum logarithmic volume in dezibel (dB)
     * @param max_volume_in_db Returns the maximum logarithmic volume in dezibel (dB)
     */
    void getLogarithmicVolumeRange(out nmm_double min_volume_in_db, out nmm_double max_volume_in_db) const;
  };

}

