1
# Copyright 2004-2005 Joe Wreschnig, Michael Urman
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License version 2 as
5
# published by the Free Software Foundation
7
# $Id: mpc.py 4047 2007-04-30 03:49:58Z piman $
11
from formats._apev2 import APEv2File
13
extensions = [".mpc", ".mp+"]
15
from mutagen.musepack import Musepack
16
except (ImportError, OSError):
19
if gst.registry_get_default().find_plugin("musepack") is None:
22
class MPCFile(APEv2File):
25
def __init__(self, filename):
26
audio = Musepack(filename)
27
super(MPCFile, self).__init__(filename, audio)
28
self["~#length"] = int(audio.info.length)
29
self["~#bitrate"] = int(audio.info.bitrate)
32
if audio.info.title_gain:
33
track_g = u"%+0.2f dB" % audio.info.title_gain
34
self.setdefault("replaygain_track_gain", track_g)
35
if audio.info.album_gain:
36
album_g = u"%+0.2f dB" % audio.info.album_gain
37
self.setdefault("replaygain_album_gain", album_g)
38
if audio.info.title_peak:
39
track_p = unicode(audio.info.title_peak * 2)
40
self.setdefault("replaygain_track_peak", track_p)
41
if audio.info.album_peak:
42
album_p = unicode(audio.info.album_peak * 2)
43
self.setdefault("replaygain_album_peak", album_p)
44
except AttributeError:
47
self.sanitize(filename)