packages feed

flaccuraterip 0.1 → 0.2

raw patch · 4 files changed

+53/−28 lines, 4 files

Files

CD/AccurateRip.hs view
@@ -56,8 +56,21 @@                                                     "\twith confidence\t" ++                                                     show c ++ "\n" -newtype ArData = ArData [ArCrcEntry]+showArCrcEntry :: ArCrcEntry -> String+showArCrcEntry (ArCrcEntry w1 w2 w3 xs) =+    (show w1) ++ "-" ++ (show w2) ++ "-" ++ (show w3)+                  ++ "\n" ++ "Track No.\tChecksum\tAccuracy" ++ "\n\n" +++                  showEntry+        where showEntry = concat $ zipWith f [(1::Int)..] xs+              f i (c,s) | c == 0 && s == DiscID 0 = "Track " ++ show i +++                                                    ":\t(not present)" ++ "\n"+                        | otherwise               = "Track " ++ show i +++                                                    ":\t" ++ show s +++                                                    "\t" ++ show c ++ "\n" ++newtype ArData = ArData {unArData :: [ArCrcEntry]}+ instance Binary ArData where     put (ArData ents) = mapM_ put ents     get = getList >>= return . ArData@@ -72,6 +85,10 @@     showsPrec _ (ArData []) = id     showsPrec n (ArData (x:xs)) = showsPrec n x . ('\n' :) . ('\n' :) .                                   showsPrec n (ArData xs)++showArData :: ArData -> String+showArData (ArData xs) = concat $ zipWith f xs [1..length xs]+    where f x i = "#" ++ show i ++ " " ++ showArCrcEntry x ++ "\n"  {- type DiscMatch = (Bool,Bool,Bool,Bool) -- track count, ID1, ID2, CDDB
CD/CDDB.hs view
@@ -16,16 +16,6 @@     put (DiscID w) = putWord32le w     get = getWord32le >>= return . DiscID -instance Enum DiscID where-    succ (DiscID w) = DiscID $ succ w-    pred (DiscID w) = DiscID $ pred w-    toEnum n = DiscID $ toEnum n-    fromEnum (DiscID w) = fromEnum w-    enumFrom (DiscID w) = map DiscID (enumFrom w)-    enumFromThen (DiscID v) (DiscID w) = map DiscID (enumFromThen v w)-    enumFromTo (DiscID v) (DiscID w) = map DiscID (enumFromTo v w)-    enumFromThenTo (DiscID u) (DiscID v) (DiscID w) = map DiscID (enumFromThenTo u v w)- instance Show DiscID where     show (DiscID w) =          (intToDigit $ fromIntegral ((shiftR w 28) .&. 15)) :@@ -39,15 +29,16 @@  -- |Calculate CDDB DiscID: the result is XXYYYYZZ where XX is the number of tracks, YYYY is the total length of the CD is seconds, and ZZ is ... cddbDiscId :: [Int] -> DiscID-cddbDiscId xs = toEnum $+cddbDiscId xs = DiscID $ fromIntegral $                 length xs +-                       shiftL (quot (last xs) 75) 8 +-                       shiftL (rem-                               (foldl-                                (\x y -> x + sumDigits(2 + quot y 75))-                                0 (0:init xs))-                               255-                              ) 24+                shiftL (quot (last xs) 75) 8 ++                shiftL (rem+                        (foldl+                         (\x y -> x + sumDigits(2 + quot y 75))+                         0 (0:init xs))+                        255+                       ) 24     where sumDigits 0 = 0-	  sumDigits n = (rem n 10) + sumDigits (quot n 10)+	  sumDigits n = let (q,r) = quotRem n 10+                        in r + sumDigits q 
Main.hs view
@@ -3,6 +3,7 @@ import CD.AccurateRip import CD.CDDB import Control.DeepSeq+import Control.Monad import Data.Binary import Data.Bits import Data.String@@ -22,7 +23,7 @@ exeName = "flaccuraterip"  version :: Version-version = Version [0,1] []+version = Version [0,2] []  intro :: String intro = progName ++ " " ++ showVersion version ++@@ -36,6 +37,7 @@ data Options = Options     { optOffset     :: Int     , opt30Samples  :: Bool+    , optShowEntry  :: Bool     , optFiles      :: [String]     } deriving (Data, Typeable) @@ -53,8 +55,13 @@                             \ripped using the correct offset, which is 30 \                             \samples less than that in \                             \http://www.accuraterip.com/driveoffsets.htm)"+                  , optShowEntry = False+                    &= explicit+                    &= name "show-database-entry"+                    &= help "Show the AccurateRip database entry for this rip"                   , optFiles = def                     &= args+                    &= typ "FLAC FILES"                   }  @@ -168,6 +175,13 @@          ardatastr <- getResponseBody res          putStrLn " OK"          let ardata = decode $ fromString ardatastr+         when (optShowEntry opts) $ do+             let n = length $ unArData ardata+             if n == 1+               then do putStrLn "Found 1 pressing:\n"+                       putStrLn $ showArData ardata+               else do putStrLn ("Found " ++ show n ++ " pressings:\n")+                       putStrLn $ showArData ardata          let offset = (optOffset opts) + 30*(fromEnum $ opt30Samples opts)          putStr "Computing track checksums from input files"          whenLoud $ putStr (" (using " ++ show offset ++ " samples offset)")
flaccuraterip.cabal view
@@ -1,5 +1,5 @@ Name:           flaccuraterip-Version:        0.1+Version:        0.2 Cabal-Version:  >= 1.8 Build-Type:     Simple License:        GPL-3@@ -15,14 +15,17 @@   files ripped form CD, using the information contained in the   AccurateRip™ database about other rips of the same CD.   .-  To use it, open a shell and run+  Usage: suppose you ripped a CD into @track01.flac@, @track02.flac@,+  ..., @trackNN.flac@. Open a shell in the directory containing the+  FLAC files, and run:   .-  >>> cd DIR_CONTAINING_RIPPED_FLAC_FILES-  >>> flaccuraterip *.flac+  >>> flaccuraterip track01.flac track02.flac ... trackNN.flac   .-  Notice: to work correctly, *.flac should expand to the list of flac-  files corresponding to the tracks of the CD you want to verify, and-  in the same order as they appear on the CD.+  If a pressing of this CD is present in the AccurateRip™ database,+  @flaccuraterip@ will output the ripping accuracy for each track. If+  the CD was ripped without setting the drive offset, you should use+  the flag @--sample-offset=N@, where N is the offset indicated in+  <http://accuraterip.com/driveoffsets.htm> for your drive.  Category:       Sound