Module lua_libpulse_glib.volume

Bindings for libpulse’s pa_cvolume.

Contrary to libpulse, methods that change the a Volume object generally don’t return anything, but instead change the instance itself.

Table of contents

Static Functions

new(values) Creates an instance of Volume.
is_valid(value) Checks whether a value is a valid Volume.
from_dB(value) Converts a decibel value to an integer volume value.
to_dB(value) Converts an integer volume value to a decibel value.
from_linear(value) Converts a linear factor to an integer volume value.
to_linear(value) Converts an integer volume value to linear factor.

Class Volume

Volume:avg() Returns the average volume over all channels.
Volume:channels_equal_to(value) Returns true if the volume of all channels is equal to the specified value.
Volume:dec(value) Decreases the volume by the given amount.
Volume:divide(value) Divides the volume by the given value.
Volume:get(index) Returns the volume of a single channel.
Volume:inc(value) Increases the volume by the given amount.
Volume:is_muted() Returns true when all channels are muted.
Volume:is_norm() Returns true when all channels are on normal level.
Volume:max() Returns the maximum volume out of all channels.
Volume:min() Returns the minimum volume out of all channels.
Volume:multiply(value) Multiplies the volume by the given amount.
Volume:mute() Mutes all channels.
Volume:reset() Resets all channels to normal volume.
Volume:scale(value) Scales all channels to the passed amount.
Volume:set(index, value) Sets a channel to the given value.
Volume:set_channels(channels, value) Sets a number of channels to the given volume value.

Static Functions

new(values)
Creates an instance of Volume.

Parameters:

  • values :  An array of channel volumes.
    type table

Returns:

is_valid(value)
Checks whether a value is a valid Volume.

Parameters:

  • value :  The value to check
    type any

Returns:

  • type boolean
from_dB(value)
Converts a decibel value to an integer volume value.

This is only valid for software volumes. It does not operate on instances of Volume.

Parameters:

  • value
    type number

Returns:

  • type number
to_dB(value)
Converts an integer volume value to a decibel value.

This is only valid for software volumes. It does not operate on instances of Volume.

Parameters:

  • value
    type number

Returns:

  • type number
from_linear(value)
Converts a linear factor to an integer volume value.

0.0 and less is muted, 1.0 is normal volume.

This is only valid for software volumes. It does not operate on instances of Volume.

Parameters:

  • value
    type number

Returns:

  • type number
to_linear(value)
Converts an integer volume value to linear factor.

This is only valid for software volumes. It does not operate on instances of Volume.

Parameters:

  • value
    type number

Returns:

  • type number

Class Volume

Volume
Volume:avg()
Returns the average volume over all channels.

Returns:

  • type number
Volume:channels_equal_to(value)
Returns true if the volume of all channels is equal to the specified value.

Parameters:

  • value :  Volume to compare to
    type number

Returns:

  • type boolean
Volume:dec(value)
Decreases the volume by the given amount.

The proportions between the channels are kept.

Parameters:

  • value :  The value to decrease by.
    type number
Volume:divide(value)
Divides the volume by the given value.

The value to divide by may either be a scalar, that’s applied to all channels, or another instance of Volume, which would be applied channel by channel.

It is possible to divide a Volume by itself.

This is only valid for software volumes.

Parameters:

  • value :  The volume to divide by.
    type number or Volume
Volume:get(index)
Returns the volume of a single channel.

Parameters:

  • index :  The channel index
    type number

Returns:

  • The channel’s volume
    type number
Volume:inc(value)
Increases the volume by the given amount.

The proportions between the channels are kept.

Parameters:

  • value :  the value to increase by.
    type number
Volume:is_muted()
Returns true when all channels are muted.

Returns:

  • type boolean
Volume:is_norm()
Returns true when all channels are on normal level.

Returns:

  • type boolean
Volume:max()
Returns the maximum volume out of all channels.

Returns:

  • type number
Volume:min()
Returns the minimum volume out of all channels.

Returns:

  • type number
Volume:multiply(value)
Multiplies the volume by the given amount.

The value to multiply with may either be a scalar, that’s applied to all channels, or another instance of Volume, which would be applied channel by channel.

It is possible to multiply a Volume by itself.

This is only valid for software volumes.

Parameters:

Volume:mute()
Mutes all channels.
Volume:reset()
Resets all channels to normal volume.
Volume:scale(value)
Scales all channels to the passed amount.

This adjust all channel volumes so that the maximum between them equals the given value, while keeping proportions between channels the same.

Parameters:

  • value :  The value to scale to.
    type number
Volume:set(index, value)
Sets a channel to the given value.

Parameters:

  • index :  The channel index.
    type number
  • value :  The volume to set to.
    type number
Volume:set_channels(channels, value)
Sets a number of channels to the given volume value.

Parameters:

  • channels :  The number of channels to set
    type number
  • value :  The volume to set to.
    type number