# -*- coding: utf-8 -*- # Copyright (C) 2006 Lukas Lalinsky # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. """OptimFROG audio streams with APEv2 tags. OptimFROG is a lossless audio compression program. Its main goal is to reduce at maximum the size of audio files, while permitting bit identical restoration for all input. It is similar with the ZIP compression, but it is highly specialized to compress audio data. Only versions 4.5 and higher are supported. For more information, see http://www.losslessaudio.org/ """ __all__ = ["OptimFROG", "Open", "delete"] import struct from ._compat import endswith from mutagen import StreamInfo from mutagen.apev2 import APEv2File, error, delete class OptimFROGHeaderError(error): pass class OptimFROGInfo(StreamInfo): """OptimFROG stream information. Attributes: * channels - number of audio channels * length - file length in seconds, as a float * sample_rate - audio sampling rate in Hz """ def __init__(self, fileobj): header = fileobj.read(76) if (len(header) != 76 or not header.startswith(b"OFR ") or struct.unpack("