--- a/jack_prepare.py~  2006-02-08 00:44:35.000000000 +0000
+++ b/jack_prepare.py   2006-02-08 00:56:07.000000000 +0000
@@ -38,6 +38,7 @@
 import jack_tag
 
 from jack_globals import *
+from jack_init import flac
 
 global tracknum
 datatracks = []
@@ -357,6 +358,28 @@
                     elif ext == ".ogg":
                         x = ogg.vorbis.VorbisFile(filename + ext)
                         temp_rate = int(x.raw_total(0) * 8 / x.time_total(0) / 
1000 + 0.5)
+                    elif ext == ".flac" and flac:
+                        chain = flac.metadata.Chain()
+                        chain.read(filename + ext)
+                        it = flac.metadata.Iterator()
+                        it.init(chain)
+                        sample_rate = total_samples = 0
+                        while 1:
+                            if it.get_block_type() == flac.metadata.STREAMINFO:
+                                block = it.get_block()
+                                streaminfo = block.data.stream_info
+                                sample_rate = streaminfo.sample_rate
+                                total_samples = streaminfo.total_samples
+                                break
+                            if not it.next():
+                                break
+                        size = os.path.getsize(filename + ext)
+                        if sample_rate and total_samples and size:
+                            temp_rate = int(size * 8 * sample_rate / 
total_samples / 1000)
+                            print temp_rate
+                        else:
+                            temp_rate = 0
+                        print sample_rate, total_samples
                     else:
                         error("don't know how to handle %s files." % ext)
                     status[num]['enc'] = `temp_rate` + cf['_progr_sep'] + 
"[simulated]"

-- 
Martin Michlmayr
http://www.cyrius.com/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to