CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-python-vlc

VLC bindings for Python providing comprehensive multimedia functionality through LibVLC API.

Pending
Overview
Eval results
Files

audio-control.mddocs/

Audio Control

Comprehensive audio control including volume, equalizer, audio tracks, and audio output device management. These capabilities provide complete control over audio playback and processing.

Capabilities

Audio Playback Control

Basic audio control methods available on MediaPlayer for managing volume, mute state, and audio tracks.

# Audio control methods on MediaPlayer
def audio_get_volume(self):
    """Get the current audio volume.
    
    Returns:
        int: Volume level (0-100), or -1 on error
    """
    ...

def audio_set_volume(self, volume):
    """Set the audio volume.
    
    Args:
        volume (int): Volume level (0-100)
        
    Returns:
        int: 0 on success, -1 on error
    """
    ...

def audio_get_mute(self):
    """Get the mute status.
    
    Returns:
        bool: True if muted, False otherwise
    """
    ...

def audio_set_mute(self, mute):
    """Set the mute status.
    
    Args:
        mute (bool): True to mute, False to unmute
    """
    ...

def audio_toggle_mute(self):
    """Toggle the mute status."""
    ...

def audio_get_track_count(self):
    """Get the number of available audio tracks.
    
    Returns:
        int: Number of audio tracks
    """
    ...

def audio_get_track(self):
    """Get the current audio track.
    
    Returns:
        int: Current audio track ID, or -1 if none
    """
    ...

def audio_set_track(self, track):
    """Set the current audio track.
    
    Args:
        track (int): Audio track ID to select
        
    Returns:
        int: 0 on success, -1 on error
    """
    ...

def audio_get_track_description(self):
    """Get descriptions of available audio tracks.
    
    Returns:
        list: List of (track_id, track_name) tuples
    """
    ...

def audio_get_delay(self):
    """Get the current audio delay in microseconds.
    
    Returns:
        int: Audio delay in microseconds
    """
    ...

def audio_set_delay(self, delay):
    """Set the audio delay.
    
    Args:
        delay (int): Audio delay in microseconds
        
    Returns:
        int: 0 on success, -1 on error
    """
    ...

def audio_get_channel(self):
    """Get the audio channel configuration.
    
    Returns:
        AudioOutputChannel: Current audio channel mode
    """
    ...

def audio_set_channel(self, channel):
    """Set the audio channel configuration.
    
    Args:
        channel (AudioOutputChannel): Channel configuration to set
        
    Returns:
        int: 0 on success, -1 on error
    """
    ...

Audio Equalizer

The AudioEqualizer class provides comprehensive equalizer control with frequency band adjustment and preset management.

class AudioEqualizer:
    def __init__(self):
        """Create a new audio equalizer."""
        ...
    
    @staticmethod
    def create():
        """Create a new audio equalizer instance.
        
        Note: Use AudioEqualizer() constructor directly in Python-VLC.
        
        Returns:
            AudioEqualizer: New equalizer instance
        """
        ...
    
    def release(self):
        """Release the equalizer instance."""
        ...
    
    def set_preamp(self, preamp):
        """Set the equalizer pre-amplification value.
        
        Args:
            preamp (float): Pre-amplification value in dB (-20.0 to 20.0)
            
        Returns:
            int: 0 on success, -1 on error
        """
        ...
    
    def get_preamp(self):
        """Get the equalizer pre-amplification value.
        
        Returns:
            float: Pre-amplification value in dB
        """
        ...
    
    def set_amp_at_index(self, amp, band):
        """Set the amplification value for a specific frequency band.
        
        Args:
            amp (float): Amplification value in dB (-20.0 to 20.0)
            band (int): Band index (0-9 for 10-band equalizer)
            
        Returns:
            int: 0 on success, -1 on error
        """
        ...
    
    def get_amp_at_index(self, band):
        """Get the amplification value for a specific frequency band.
        
        Args:
            band (int): Band index (0-9 for 10-band equalizer)
            
        Returns:
            float: Amplification value in dB
        """
        ...
    
    @staticmethod
    def get_band_count():
        """Get the number of equalizer bands.
        
        Note: Use vlc.libvlc_audio_equalizer_get_band_count() in Python-VLC.
        
        Returns:
            int: Number of bands (typically 10)
        """
        ...
    
    @staticmethod
    def get_band_frequency(band):
        """Get the frequency for a specific band.
        
        Note: Use vlc.libvlc_audio_equalizer_get_band_frequency() in Python-VLC.
        
        Args:
            band (int): Band index (0-based)
            
        Returns:
            float: Frequency in Hz, or -1.0 if invalid band
        """
        ...
    
    @staticmethod
    def get_preset_count():
        """Get the number of available equalizer presets.
        
        Note: Use vlc.libvlc_audio_equalizer_get_preset_count() in Python-VLC.
        
        Returns:
            int: Number of presets
        """
        ...
    
    @staticmethod
    def get_preset_name(preset):
        """Get the name of a specific preset.
        
        Note: Use vlc.libvlc_audio_equalizer_get_preset_name() in Python-VLC.
        
        Args:
            preset (int): Preset index (0-based)
            
        Returns:
            str: Preset name or None if invalid
        """
        ...
    
    @staticmethod
    def create_from_preset(preset):
        """Create an equalizer from a preset.
        
        Note: Use vlc.libvlc_audio_equalizer_new_from_preset() in Python-VLC.
        
        Args:
            preset (int): Preset index (0-based)
            
        Returns:
            AudioEqualizer: New equalizer with preset values or None on error
        """
        ...

Audio Output Management

Audio output device enumeration and selection capabilities available through the Instance class.

# Audio output methods on Instance
def audio_output_enumerate(self):
    """Enumerate available audio output modules.
    
    Returns:
        list: List of (module_name, description) tuples
    """
    ...

def audio_output_enumerate_devices(self, audio_output=None):
    """Enumerate available audio output devices.
    
    Args:
        audio_output (str, optional): Audio output module name
        
    Returns:
        list: List of (device_id, device_name) tuples
    """
    ...

def audio_output_set_device_type(self, device_type):
    """Set the audio output device type.
    
    Args:
        device_type (AudioOutputDeviceType): Device type to set
        
    Returns:
        int: 0 on success, -1 on error
    """
    ...

def audio_output_get_device_type(self):
    """Get the current audio output device type.
    
    Returns:
        AudioOutputDeviceType: Current device type
    """
    ...

# Audio output methods on MediaPlayer
def audio_output_set(self, audio_output):
    """Set the audio output module.
    
    Args:
        audio_output (str): Audio output module name
        
    Returns:
        int: 0 on success, -1 on error
    """
    ...

def audio_output_device_enum(self):
    """Enumerate audio output devices for current output module.
    
    Returns:
        list: List of available audio devices
    """
    ...

def audio_output_device_set(self, device_id):
    """Set the audio output device.
    
    Args:
        device_id (str): Device identifier
        
    Returns:
        int: 0 on success, -1 on error
    """
    ...

def audio_output_device_get(self):
    """Get the current audio output device. (LibVLC 3.0.0+)
    
    Returns:
        str: Current device identifier or None
    """
    ...

Audio Channel Configuration

Enumeration for audio channel configurations.

class AudioOutputChannel:
    """Audio output channel configuration."""
    Error = -1
    Stereo = 1
    RStereo = 2
    Left = 3
    Right = 4
    Dolby = 5

Audio Device Types

Enumeration for audio output device types.

class AudioOutputDeviceType:
    """Audio output device types."""
    Error = -1
    Mono = 1
    Stereo = 2
    _2F2R = 4
    _3F2R = 5
    _5_1 = 6
    _6_1 = 7
    _7_1 = 8
    SPDIF = 10

Usage Examples

Basic Volume Control

import vlc

player = vlc.MediaPlayer('/path/to/audio.mp3')
player.play()

# Set volume to 80%
player.audio_set_volume(80)

# Get current volume
volume = player.audio_get_volume()
print(f"Current volume: {volume}%")

# Mute/unmute
player.audio_set_mute(True)
print(f"Muted: {player.audio_get_mute()}")
player.audio_toggle_mute()

Audio Track Selection

import vlc

player = vlc.MediaPlayer('/path/to/multilingual_video.mp4')
player.play()

# Get available audio tracks
track_count = player.audio_get_track_count()
print(f"Available audio tracks: {track_count}")

# Get track descriptions
tracks = player.audio_get_track_description()
for track_id, track_name in tracks:
    print(f"Track {track_id}: {track_name}")

# Select a specific audio track
player.audio_set_track(1)
print(f"Current track: {player.audio_get_track()}")

Equalizer Usage

import vlc

# Create equalizer from preset (using global function)
eq = vlc.libvlc_audio_equalizer_new_from_preset(2)  # Rock preset
# Or create empty equalizer
eq = vlc.AudioEqualizer()

# Get preset information (using global functions)
preset_count = vlc.libvlc_audio_equalizer_get_preset_count()
for i in range(preset_count):
    name = vlc.libvlc_audio_equalizer_get_preset_name(i)
    print(f"Preset {i}: {name}")

# Customize equalizer
eq.set_preamp(3.0)  # Boost pre-amp by 3dB
eq.set_amp_at_index(5.0, 0)  # Boost first band by 5dB

# Apply equalizer to player
player = vlc.MediaPlayer('/path/to/audio.mp3')
player.audio_set_equalizer(eq)  # Apply the equalizer settings

# Get band information (using global functions)
band_count = vlc.libvlc_audio_equalizer_get_band_count()
for i in range(band_count):
    freq = vlc.libvlc_audio_equalizer_get_band_frequency(i)
    amp = eq.get_amp_at_index(i)
    print(f"Band {i}: {freq}Hz = {amp}dB")

Audio Output Device Selection

import vlc

instance = vlc.Instance()

# List available audio output modules
outputs = instance.audio_output_enumerate()
for module, description in outputs:
    print(f"Module: {module} - {description}")

# List audio devices for default output
devices = instance.audio_output_enumerate_devices()
for device_id, device_name in devices:
    print(f"Device: {device_id} - {device_name}")

# Set specific audio output device
player = vlc.MediaPlayer('/path/to/audio.mp3')
player.audio_output_device_set('pulse')  # Use PulseAudio on Linux

# Get current device
current_device = player.audio_output_device_get()
print(f"Current audio device: {current_device}")

Audio Delay Adjustment

import vlc

player = vlc.MediaPlayer('/path/to/video.mp4')
player.play()

# Get current audio delay
delay = player.audio_get_delay()
print(f"Current audio delay: {delay} microseconds")

# Adjust audio delay (positive = audio after video, negative = audio before video)
player.audio_set_delay(100000)  # 100ms delay

# Set audio channel configuration
player.audio_set_channel(vlc.AudioOutputChannel.Stereo)
current_channel = player.audio_get_channel()
print(f"Audio channel mode: {current_channel}")

Install with Tessl CLI

npx tessl i tessl/pypi-python-vlc

docs

audio-control.md

core-playback.md

data-structures.md

discovery-renderers.md

event-system.md

index.md

low-level-functions.md

media-lists.md

video-control.md

tile.json