1 changed files with 23 additions and 7 deletions
@ -1,15 +1,31 @@
@@ -1,15 +1,31 @@
|
||||
-- Создан: Ср 28 сен 2016 10:18:53 |
||||
-- Изменен: Чт 29 сен 2016 09:53:59 |
||||
-- Изменен: Чт 29 сен 2016 11:18:07 |
||||
|
||||
import Data.List |
||||
import System.Environment |
||||
import Data.WAVE |
||||
-- import Data.List |
||||
|
||||
n = 48000 |
||||
--Выбор канала из пары |
||||
chL :: [a] -> a |
||||
chL pair = pair!!0 |
||||
|
||||
chL (l:r) = l |
||||
chR (l:r) = r |
||||
chR :: [a] -> a |
||||
chR pair = pair!!1 |
||||
|
||||
audioread :: String -> String -> [Char] -> IO () |
||||
audioread samples file ch = do |
||||
w <- getWAVEFile file |
||||
mapM_ print (map (sampleToDouble . channel) (take (read samples::Int) $ waveSamples w)) where |
||||
channel (xs) |
||||
| ch == ['R'] = chR xs |
||||
| ch == ['L'] = chL xs |
||||
| otherwise = chL xs |
||||
|
||||
main :: IO () |
||||
main = do |
||||
w <- getWAVEFile "000.wav" |
||||
mapM_ print (map chL (take n $ waveSamples w)) |
||||
cmd <- getArgs |
||||
case cmd of |
||||
[samples, file, ch] -> audioread samples file ch |
||||
[samples, file] -> audioread samples file ['L'] |
||||
_ -> putStrLn "Usage: audioread [samples] [file.wav] [L/R]" |
||||
|
||||
|
Loading…
Reference in new issue