module Music.Theory.Array.Csv.Midi.Cli where
import qualified Music.Theory.Array.Csv.Midi.Mnd as T
import qualified Music.Theory.Time.Seq as T
usage :: [String]
usage :: [String]
usage =
[String
"concat {r} -o output-file input-file..."
,String
"mnd-to-mndd {i|r} precision:int input-file output-file"
,String
"mndd-transpose precision:int n:int input-file output-file"]
read_wseq_i :: FilePath -> IO (T.Wseq Double (T.Event Int))
read_wseq_i :: String -> IO (Wseq Double (Event Int))
read_wseq_i = forall t n.
(Read t, Real t, Read n, Real n) =>
String -> IO (Wseq t (Event n))
T.csv_midi_read_wseq
read_wseq_r :: FilePath -> IO (T.Wseq Double (T.Event Double))
read_wseq_r :: String -> IO (Wseq Double (Event Double))
read_wseq_r = forall t n.
(Read t, Real t, Read n, Real n) =>
String -> IO (Wseq t (Event n))
T.csv_midi_read_wseq
mnd_to_mndd_i :: Int -> FilePath -> FilePath -> IO ()
mnd_to_mndd_i :: Int -> String -> String -> IO ()
mnd_to_mndd_i Int
p String
i_fn String
o_fn = do
Wseq Double (Event Int)
m <- String -> IO (Wseq Double (Event Int))
read_wseq_i String
i_fn
forall t n.
(Real t, Real n) =>
Int -> String -> Wseq t (Event n) -> IO ()
T.csv_mndd_write_wseq Int
p String
o_fn Wseq Double (Event Int)
m
mndd_transpose_r :: Int -> Double -> FilePath -> FilePath -> IO ()
mndd_transpose_r :: Int -> Double -> String -> String -> IO ()
mndd_transpose_r Int
p Double
k String
i_fn String
o_fn = do
Wseq Double (Event Double)
m <- String -> IO (Wseq Double (Event Double))
read_wseq_r String
i_fn
let f :: (a, (Double, b, c, d)) -> (a, (Double, b, c, d))
f (a
t,(Double
mnn,b
vel,c
ch,d
pr)) = (a
t,(Double
mnn forall a. Num a => a -> a -> a
+ Double
k,b
vel,c
ch,d
pr))
forall t n.
(Real t, Real n) =>
Int -> String -> Wseq t (Event n) -> IO ()
T.csv_mndd_write_wseq Int
p String
o_fn (forall a b. (a -> b) -> [a] -> [b]
map forall {a} {b} {c} {d}.
(a, (Double, b, c, d)) -> (a, (Double, b, c, d))
f Wseq Double (Event Double)
m)
csv_midi_concat_r :: FilePath -> [FilePath] -> IO ()
csv_midi_concat_r :: String -> [String] -> IO ()
csv_midi_concat_r String
o_fn [String]
i_fn = do
[Wseq Double (Event Double)]
i <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM String -> IO (Wseq Double (Event Double))
read_wseq_r [String]
i_fn
forall t n.
(Real t, Real n) =>
Int -> String -> Wseq t (Event n) -> IO ()
T.csv_mndd_write_wseq Int
4 String
o_fn (forall t a. Num t => [Wseq t a] -> Wseq t a
T.wseq_concat [Wseq Double (Event Double)]
i)
csv_midi_cli :: [String] -> IO ()
csv_midi_cli :: [String] -> IO ()
csv_midi_cli [String]
arg =
case [String]
arg of
String
"concat":String
"r":String
"-o":String
o_fn:[String]
i_fn -> String -> [String] -> IO ()
csv_midi_concat_r String
o_fn [String]
i_fn
[String
"mnd-to-mndd",String
"i",String
p,String
i_fn,String
o_fn] -> Int -> String -> String -> IO ()
mnd_to_mndd_i (forall a. Read a => String -> a
read String
p) String
i_fn String
o_fn
[String
"mndd-transpose",String
"r",String
p,String
k,String
i_fn,String
o_fn] -> Int -> Double -> String -> String -> IO ()
mndd_transpose_r (forall a. Read a => String -> a
read String
p) (forall a. Read a => String -> a
read String
k) String
i_fn String
o_fn
[String]
_ -> String -> IO ()
putStrLn ([String] -> String
unlines [String]
usage)