-- fc.hs
import Graphics.UI.Gtk
main = do
initGUI
fchdal <- fileChooserDialogNew Nothing Nothing
FileChooserActionOpen
[("Cancel", ResponseCancel), ("Select", ResponseAccept)]
fchdal `set` [fileChooserDoOverwriteConfirmation := True]
widgetShow fchdal
response <- dialogRun fchdal
case response of
ResponseCancel -> putStrLn "You cancelled..."
ResponseAccept -> do
nwf <- fileChooserGetFilename fchdal
case nwf of
Nothing -> putStrLn "Nothing"
Just path -> putStr path
w <- windowNew
w `set` [windowDefaultWidth := 16, windowDefaultHeight := 16]
s <- spinnerNew
containerAdd w s
widgetShowAll w
spinnerStart s
widgetDestroy fchdal
fchdal `on` objectDestroy $ mainQuit
mainGUI
-- end of fc.hs
-- t.hs
import System.Directory
import System.FilePath.Posix
import System.Process
duration :: FilePath -> IO ()
duration f = createProcess (proc "soxi" ["-D",f]) >> return ()
splitFileName' = return . splitFileName
main = do
(d,f) <- readFile "fn" >>= splitFileName'
setCurrentDirectory d
duration f
-- end of t.hs
-- t2.hs
import System.Directory
import System.FilePath.Posix
import System.Process
getC :: IO Double
getC = getContents >>= return . read
splitFileName' = return . splitFileName
main = do
d <- getC
(dir,f) <- readFile "fn" >>= splitFileName'
setCurrentDirectory dir
n <- f1 d 1
let t = d / n
let l = f2 t n
doComs f t l
f1 d n = if (d / n) < 300 then return n else f1 d (n + 1)
f2 d n = map (\x -> x*d) [0..(n - 1)]
doComs f d l = do
mapM_ (\x -> trim f (nf f x) x (d + 10)) (init l)
let x = last l
trim f (nf f x) x d
where nf f x = "trimed" ++ show (round x) ++ takeBaseName f ++ ".flac"
trim :: FilePath -> FilePath -> Double -> Double -> IO ()
trim i o sP d = createProcess (proc "sox" [i, o,"trim", show sP, show d]) >> return ()
-- end of t2.hs
2023年6月14日水曜日
Flacファイルの分割
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿