Example #1
0
 def __init__(self, fileobj, offset):
     fileobj.seek(offset or 0)
     header = fileobj.read(18)
     if len(header) != 18 or not header.startswith("TTA"):
         raise TrueAudioHeaderError("TTA header not found")
     self.sample_rate = cdata.int_le(header[10:14])
     samples = cdata.uint_le(header[14:18])
     self.length = float(samples) / self.sample_rate
Example #2
0
 def __init__(self, fileobj, offset):
     fileobj.seek(offset or 0)
     header = fileobj.read(18)
     if len(header) != 18 or not header.startswith("TTA"):
         raise TrueAudioHeaderError("TTA header not found")
     self.sample_rate = cdata.int_le(header[10:14])
     samples = cdata.uint_le(header[14:18])
     self.length = float(samples) / self.sample_rate
Example #3
0
 def __init__(self, fileobj):
     page = OggPage(fileobj)
     while not page.packets[0].startswith("Speex   "):
         page = OggPage(fileobj)
     if not page.first:
         raise OggSpeexHeaderError(
             "page has ID header, but doesn't start a stream")
     self.sample_rate = cdata.uint_le(page.packets[0][36:40])
     self.channels = cdata.uint_le(page.packets[0][48:52])
     self.bitrate = max(0, cdata.int_le(page.packets[0][52:56]))
     self.serial = page.serial
Example #4
0
 def __init__(self, fileobj):
     page = OggPage(fileobj)
     while not page.packets[0].startswith("Speex   "):
         page = OggPage(fileobj)
     if not page.first:
         raise OggSpeexHeaderError(
             "page has ID header, but doesn't start a stream")
     self.sample_rate = cdata.uint_le(page.packets[0][36:40])
     self.channels = cdata.uint_le(page.packets[0][48:52])
     self.bitrate = max(0, cdata.int_le(page.packets[0][52:56]))
     self.serial = page.serial