1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# -*- coding: utf-8 -*-
#
# Picard, the next-generation MusicBrainz tagger
# Copyright (C) 2007 Lukáš Lalinský
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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.
import wave
import os
from zmusic.picard.file import File
from zmusic.picard.metadata import Metadata
from zmusic.picard.util import encode_filename
class WaveInfo(object):
def __init__(self, file):
self.length = 1000 * file.getnframes() / file.getframerate()
class Wave(object):
def __init__(self, file):
self.mime = "audio/wav"
self.info = WaveInfo(file)
class WAVFile(File):
EXTENSIONS = [".wav"]
NAME = "Microsoft WAVE"
def _load(self, filename):
self.log.debug("Loading file %r", filename)
f = wave.open(encode_filename(filename), "rb")
metadata = Metadata()
metadata['~#channels'] = f.getnchannels()
metadata['~#bits_per_sample'] = f.getsampwidth() * 8
metadata['~#sample_rate'] = f.getframerate()
metadata.length = 1000 * f.getnframes() / f.getframerate()
metadata['~format'] = 'Microsoft WAVE'
file = Wave(f)
self._info(metadata, file)
metadata["title"] = os.path.splitext(os.path.basename(filename))[0]
metadata["album"] = ''
metadata["artist"] = ''
return metadata
def _save(self, filename, metadata, settings):
self.log.debug("Saving file %r", filename)
pass
|