-- Copyright (C) 2007-2008 Stefan Kersten -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA module Sound.SonicVisualiser.File ( read , readFile ) where import qualified Codec.Binary.UTF8.String as UTF8 import qualified Codec.Compression.BZip as BZip import qualified Data.ByteString.Lazy as ByteString import Prelude hiding (read, readFile) import Sound.SonicVisualiser.Types import qualified Sound.SonicVisualiser.XML as XML import System.IO (Handle) -- | Read a compressed Sonic-Visualiser Document from a lazy ByteString. read :: ByteString.ByteString -> IO Document read = XML.readString . UTF8.decode . ByteString.unpack . BZip.decompress -- | Read a Sonic-Visualiser Document from a file handle. hGetContents :: Handle -> IO Document hGetContents handle = (ByteString.hGetContents handle) >>= read -- | Read a Sonic-Visualiser Document from a file. readFile :: FilePath -> IO Document readFile file = (ByteString.readFile file) >>= read -- EOF