Exemplo n.º 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
Exemplo n.º 2
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 = cdata.int_le(page.packets[0][52:56])
     if self.bitrate == -1:
         self.bitrate = 0
     self.serial = page.serial