~ubuntu-branches/ubuntu/karmic/quodlibet/karmic

« back to all changes in this revision

Viewing changes to formats/wav.py

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2009-01-30 23:55:34 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20090130235534-l4e72ulw0vqfo17w
Tags: 2.0-1ubuntu1
* Merge from Debian experimental (LP: #276856), remaining Ubuntu changes:
  + debian/patches/40-use-music-profile.patch:
    - Use the "Music and Movies" pipeline per default.
* Refresh the above patch for new upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2006 Joe Wreschnig
2
 
#
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
6
 
#
7
 
# $Id: wav.py 3684 2006-07-23 22:20:43Z piman $
8
 
 
9
 
import os
10
 
import wave
11
 
 
12
 
import gst
13
 
 
14
 
from formats._audio import AudioFile
15
 
 
16
 
extensions = [".wav"]
17
 
 
18
 
if gst.registry_get_default().find_plugin("wavparse") is None:
19
 
    extensions = []
20
 
 
21
 
class WAVEFile(AudioFile):
22
 
    format = "WAVE"
23
 
 
24
 
    def __init__(self, filename):
25
 
        f = wave.open(filename, "rb")
26
 
        self["~#length"] = f.getnframes() // f.getframerate()
27
 
        self.sanitize(filename)
28
 
 
29
 
    def sanitize(self, filename):
30
 
        super(WAVEFile, self).sanitize(filename)
31
 
        self["title"] = os.path.basename(self["~filename"])[:-4]
32
 
 
33
 
    def write(self):
34
 
        pass
35
 
 
36
 
    def can_change(self, k=None):
37
 
        if k is None: return ["artist"]
38
 
        else: return k == "artist"
39
 
 
40
 
info = WAVEFile