X-Git-Url: http://git.maemo.org/git/?p=demorecorder;a=blobdiff_plain;f=src%2FMixerBin.vala;fp=src%2FMixerBin.vala;h=e8af28dd089a0f95f35b4e0856424a76868cafce;hp=0000000000000000000000000000000000000000;hb=804630a4e0d41b182d8540f2aec69cf25ca0acfd;hpb=753fb925588aeeacdd74a163672acf2bf362a99e diff --git a/src/MixerBin.vala b/src/MixerBin.vala new file mode 100644 index 0000000..e8af28d --- /dev/null +++ b/src/MixerBin.vala @@ -0,0 +1,126 @@ +/* Demo Recorder for MAEMO 5 +* Copyright (C) 2010 Dru Moore +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2, +* or (at your option) any later version, as published by the Free +* Software Foundation +* +* This program 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 General Public License for more details +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +namespace IdWorks { + +public class MixerBin : Gst.Bin { + + Gst.Element adder; + Gst.Element equalizer; + Gst.Element panorama; + Gst.Element volume; + List tracks; + Gst.GhostPad sink_pad; + Gst.GhostPad src_pad; + + public MixerBin(string name) { + this.name = name; + tracks = new List(); + + adder = Gst.ElementFactory.make("adder", "adder_source"); + this.add(adder); + equalizer = Gst.ElementFactory.make("equalizer-10bands", "eq"); + this.add(equalizer); + panorama = Gst.ElementFactory.make("audiopanorama", "panorama"); + this.add(panorama); + volume = Gst.ElementFactory.make("volume", "vol"); + this.add(volume); + + adder.link(equalizer); + equalizer.link(panorama); + panorama.link(volume); + //volume.link(sink); + + sink_pad = new Gst.GhostPad("sink", adder.get_static_pad("sink")); + this.add_pad(sink_pad); + src_pad = new Gst.GhostPad("src", volume.get_static_pad("src")); + this.add_pad(src_pad); + } + + public bool add_track(TrackBin bin) { + this.add(bin); + bin.link(adder); + if (null == tracks) { + tracks = new List(); + } + tracks.append(bin); + return true; + } + + public void remove_all_tracks() { + while (null != tracks.first()) { + TrackBin track = tracks.first().data as TrackBin; + if (null != track) { + track.unlink(adder); + this.remove(track); + } + tracks.remove_link(tracks.first()); + } + } + + public bool remove_track(TrackBin track) { + track.unlink(adder); + this.remove(track); + tracks.remove(track); + return true; + } + + public new Gst.PadTemplate get_pad_template(string name) { + switch (name) { + case "src": + return this.volume.get_pad_template("src"); + case "sink": + return this.adder.get_pad_template("sink"); + default: + return this.get_pad_template(name); + } + } + + public void set_volume(double val) + requires (val >= 0.0 && val <= 10.0) { + volume.set_property("volume", val); + } + public double get_volume() { + GLib.Value ret = 0.0; + volume.get_property("volume", ref ret); + return ret.get_double(); + } + + public void set_panorama(double val) + requires (val >= -1 && val <= 1) { + panorama.set_property("panorama", val); + } + public double get_panorama() { + GLib.Value ret = 0.0; + panorama.get_property("panorama", ref ret); + return ret.get_double(); + } + + public void set_eq(int band, double val) + requires (band > -1 && band < 10) + requires (val >= -24 && val <= 12) { + equalizer.set_property("band" + band.to_string(), val); + } + public double get_eq(int band) { + GLib.Value ret = 0.0; + equalizer.get_property("band" + band.to_string(), ref ret); + return ret.get_double(); + } + +} + +} \ No newline at end of file