[xiph-cvs] cvs commit: positron/positron audiofile.py config.py
Stan Seibert
volsung at xiph.org
Thu Mar 11 20:32:50 PST 2004
volsung 04/03/11 23:32:50
Modified: positron audiofile.py config.py
Log:
WAV support for positron, thanks to Alec Mitchell. Closes bug 511.
Revision Changes Path
1.7 +25 -1 positron/positron/audiofile.py
Index: audiofile.py
===================================================================
RCS file: /usr/local/cvsroot/positron/positron/audiofile.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- a/audiofile.py 19 Sep 2003 04:13:29 -0000 1.6
+++ b/audiofile.py 12 Mar 2004 04:32:50 -0000 1.7
@@ -18,6 +18,7 @@
import os
from os import path
import string
+import struct
import MP3Info
@@ -117,14 +118,37 @@
return info
+def detect_wav(filename):
+ if filename[-4:] in ['.wav','.WAV','.Wav']:
+ info = { "type" : "wav",
+ "size" : os.stat(filename).st_size,
+ "length" : 1,
+ "title" : None,
+ "artist" : None,
+ "album" : None,
+ "genre" : None,
+ "tracknumber" : None}
+ wav_file=open(filename)
+ wav_file.seek(0x04,0)
+ size = int(struct.unpack('1i',wav_file.read(4))[0])
+ wav_file.seek(0x1c,0)
+ bytes_sec = int(struct.unpack('1i',wav_file.read(4))[0])
+ wav_file.close()
+ duration = size/bytes_sec
+
+ info["length"] = duration
+ return info
+ else:
+ return None
# Only put the ogg vorbis detection code in the list if
# we have the python module needed.
-detect_functions = [detect_mp3]
+detect_functions = [detect_mp3,detect_wav]
try:
import ogg.vorbis
detect_functions.insert(0, detect_oggvorbis)
except ImportError:
pass
+
<p><p>1.5 +17 -0 positron/positron/config.py
Index: config.py
===================================================================
RCS file: /usr/local/cvsroot/positron/positron/config.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- a/config.py 6 Sep 2003 23:12:28 -0000 1.4
+++ b/config.py 12 Mar 2004 04:32:50 -0000 1.5
@@ -74,6 +74,7 @@
self.sort_database = True
self.mp3_support = True
self.oggvorbis_support = False
+ self.wav_support = True
self.syncdirs = []
def set_config_dir(self, config_dir):
@@ -110,6 +111,9 @@
if self.oggvorbis_support:
types.append("oggvorbis")
+
+ if self.wav_support:
+ types.append("wav")
return types
@@ -223,6 +227,13 @@
raise Error(tokenizer.error_leader()
+"Non boolean value '%s' given for %s",
(value, key))
+ elif key == "wav_support":
+ try:
+ self.wav_support = parse_boolean(value)
+ except Error:
+ raise Error(tokenizer.error_leader()
+ +"Non boolean value '%s' given for %s",
+ (value, key))
else:
print tokenizer.error_leader() \
+ "Ignoring unknown option %s" % (key,)
@@ -263,6 +274,12 @@
mp3_support_value = "false"
f.write("mp3_support=%s\n" % (mp3_support_value,))
+ if self.wav_support:
+ wav_support_value = "true"
+ else:
+ wav_support_value = "false"
+ f.write("wav_support=%s\n" % (wav_support_value,))
+
for (src,dest) in self.syncdirs:
f.write("\nbegin sync\n")
f.write(" src=%s\n" % (quote_string(src),))
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list