~ubuntu-branches/ubuntu/lucid/exaile/lucid

« back to all changes in this revision

Viewing changes to plugins/replaygain/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2010-02-12 19:51:01 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100212195101-8jt3tculxcl92e6v
Tags: 0.3.1~b1-0ubuntu1
* New upstream release.
* Adjust exaile.install for new plugins.
* debian/control:
 - Drop unneeded python-dev Build-Dep.
 - Bump Standards-Version to 3.8.4 
* debian/rules: No empty po files to delete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
16
#
17
17
#
18
 
# The developers of the Exaile media player hereby grant permission 
19
 
# for non-GPL compatible GStreamer and Exaile plugins to be used and 
20
 
# distributed together with GStreamer and Exaile. This permission is 
21
 
# above and beyond the permissions granted by the GPL license by which 
22
 
# Exaile is covered. If you modify this code, you may extend this 
23
 
# exception to your version of the code, but you are not obligated to 
24
 
# do so. If you do not wish to do so, delete this exception statement 
 
18
# The developers of the Exaile media player hereby grant permission
 
19
# for non-GPL compatible GStreamer and Exaile plugins to be used and
 
20
# distributed together with GStreamer and Exaile. This permission is
 
21
# above and beyond the permissions granted by the GPL license by which
 
22
# Exaile is covered. If you modify this code, you may extend this
 
23
# exception to your version of the code, but you are not obligated to
 
24
# do so. If you do not wish to do so, delete this exception statement
25
25
# from your version.
26
26
 
27
27
from xl import providers, event, settings
36
36
except: # fail gracefully if we cant set up the UI
37
37
    pass
38
38
 
 
39
NEEDED_ELEMS = ["rgvolume", "rglimiter"]
39
40
 
40
41
def enable(exaile):
 
42
    for elem in NEEDED_ELEMS:
 
43
        if not gst.element_factory_find(elem):
 
44
            raise ImportError, "Needed gstreamer element %s missing."%elem
41
45
    providers.register("stream_element", ReplaygainVolume)
42
46
    providers.register("stream_element", ReplaygainLimiter)
43
47
 
48
52
 
49
53
class ReplaygainVolume(ElementBin):
50
54
    """
51
 
        Handles replaygain volume adjustment and pre-amp. 
 
55
        Handles replaygain volume adjustment and pre-amp.
52
56
 
53
 
        Placed at 20 in the pipeline, since most elements should do their 
 
57
        Placed at 20 in the pipeline, since most elements should do their
54
58
        processing after it.
55
59
    """
56
60
    index = 20
67
71
 
68
72
        # load settings
69
73
        for x in ("album-mode", "pre-amp", "fallback-gain"):
70
 
            self._on_setting_change("reaplygain_option_set", None, 
 
74
            self._on_setting_change("replaygain_option_set", None,
71
75
                    "replaygain/%s"%x)
72
76
 
73
77
    def _on_setting_change(self, name, object, data):
74
78
        if data == "replaygain/album-mode":
75
 
            self.rgvol.set_property("album-mode", 
 
79
            self.rgvol.set_property("album-mode",
76
80
                    settings.get_option("replaygain/album-mode", True))
77
81
        elif data == "replaygain/pre-amp":
78
82
            self.rgvol.set_property("pre-amp",
84
88
 
85
89
class ReplaygainLimiter(ElementBin):
86
90
    """
87
 
        Implements clipping protection. 
88
 
        
89
 
        Placed at 80 in the pipeline so that other elements can come 
 
91
        Implements clipping protection.
 
92
 
 
93
        Placed at 80 in the pipeline so that other elements can come
90
94
        before it if necessary.
91
95
    """
92
96
    index = 80
100
104
        self.setup_elements()
101
105
 
102
106
        event.add_callback(self._on_setting_change, "replaygain_option_set")
103
 
        self._on_setting_change("replaygain_option_set", None, 
 
107
        self._on_setting_change("replaygain_option_set", None,
104
108
                "replaygain/clipping-protection")
105
109
 
106
110
    def _on_setting_change(self, name, object, data):
107
111
        if data == "replaygain/clipping-protection":
108
 
            self.rglimit.set_property("enabled", 
109
 
                    settings.get_option("replaygain/clipping-protection", 
 
112
            self.rglimit.set_property("enabled",
 
113
                    settings.get_option("replaygain/clipping-protection",
110
114
                        True))
111
115