/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set et sw=2 ts=2: */ /*************************************************************************** * mixer.h * * Tue Sep 23 14:38:54 CEST 2014 * Copyright 2014 Bent Bisballe Nyeng * deva@aasimon.org ****************************************************************************/ /* * This file is part of LibAudioIO. * * LibAudioIO is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * LibAudioIO 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with LibAudioIO; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __LIBAUDIOIO_MIXER_H__ #define __LIBAUDIOIO_MIXER_H__ // Make API behave like ALSA 1.x.x with ALSA 0.9.x #define ALSA_PCM_NEW_HW_PARAMS_API #include #include #include #include /** * A Mixer object represents a single group of channels, for example the two * channels of a stereo mixer. */ class Mixer { public: /** * Mixer constructor is not to be called "manually" is is invoked by * Device::getMixer() */ Mixer(snd_mixer_t *handle, snd_mixer_elem_t *elem); ~Mixer(); /** * Get number of channels in this mixer 'strip' */ int numberOfChannels(); /** * Return true if this mixer is a capture device, false otherwise. */ bool isCapture(); /** * Return true if this mixer is a playback device, false otherwise. */ bool isPlayback(); /** * Return true if this mixer is a enum, false otherwise. */ bool isEnum(); /** * For capture channels only! * Set arm for recording flag on all mixer channels. */ void setCapture(bool capture); /** * Return true if all channels are armed for recording. * Return false if not a capture channels strip, or if at least one channel * is not armed. */ bool capture(); /** * Set enum value. */ void setEnumValue(std::string value); /** * Get enum value. */ std::string enumValue(); /** * Get list of possible enum values. */ std::vector enumValues(); /** * Set mixer volume level in dB. * Returns 0 on succes. On error (no such channel) 1 returned. */ int setLevel(int channel, float level); /** * Get mixer volume level in dB. * On error (no such channel) -INF is returned. */ float level(int channel); typedef struct { float min; float max; } range_t; /** * Poll the valid volume range of this mixer in dB. */ range_t range(); /** * Mute/unmute this mixer (only playback channels). */ void setMuted(bool muted); /** * Get mute/unmute state of this mixer (only playback channels). */ bool muted(); private: snd_mixer_selem_channel_id_t chanId(int idx); snd_mixer_t *handle; snd_mixer_elem_t *elem; }; #endif/*__LIBAUDIOIO_MIXER_H__*/