[gst-devel] Using Mixer Interface
Mathis Hofer
mathis.hofer at dreamlab.net
Fri Mar 16 09:56:48 CET 2007
Hi
I don't know if the mixer interface can be used from the command line.
But as an example here is some C code to adjust the master volume and
balance:
*****
static void adjust_mixer(int volume, int balance)
{
GstElement *mixer;
const GList *tracks;
mixer = gst_element_factory_make("alsamixer", "mixer");
g_object_set(G_OBJECT(mixer),
"device", "hw:0",
NULL);
gst_element_set_state(mixer, GST_STATE_READY);
for (tracks = gst_mixer_list_tracks(GST_MIXER(mixer));
tracks; tracks = tracks->next) {
GstMixerTrack *track = (GstMixerTrack *)tracks->data;
if (GST_MIXER_TRACK_HAS_FLAG(track, GST_MIXER_TRACK_MASTER)) {
// Set master volume and balance
double volume = ((double)volume/100.0
* (double)(track->max_volume -
track->min_volume)) - track->min_volume;
int volumes[2];
// Left channel
volumes[0] = (int)(volume/50.0 * (50.0-MAX(balance, 0)));
// Right channel
volumes[1] = (int)(volume/50.0 * (50.0-abs(MIN(balance, 0))));
gst_mixer_set_volume(GST_MIXER(mixer), track, volumes);
} else {
}
}
gst_element_set_state(mixer, GST_STATE_NULL);
gst_object_unref(GST_OBJECT(mixer));
*****
Hope this helps...
Regards,
Mathis
--
DreamLab Technologies AG
Monbijoustrasse 36
3011 Bern
Switzerland
Tel: +41 31 398 66 66
Fax: +41 31 398 66 69
PGP Key ID: 2462240B
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20070316/499a116e/attachment.pgp>
More information about the gstreamer-devel
mailing list