1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/* -*- 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 <asoundlib.h>
#include <exception>
#include <string>
#include <vector>
/**
* 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<std::string> 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__*/
|