getChannels :: Rawdio -> IO Integer
getChannels raw = case raw of
  Silence _ c -> return c
  File f -> fmap read $ readProcess "soxi" ["-c", f] ""
  Pad    _ _ raw' -> getChannels raw'
  Trim   _ _ raw' -> getChannels raw'
  Cutoff _ _ raw' -> getChannels raw'
  Concatenate pairs -> getChannels $ snd $ head pairs
  Merge       pairs -> fmap sum $ mapM (getChannels . snd) pairs
  Mix         pairs -> getChannels $ snd $ head pairs
  Resample _ r -> return r

-- | Checks that the sample rate and channel count of the expression
-- match the type it is being cast to. If not, returns 'Nothing'.
getChannels :: Rawdio -> IO Integer
getChannels raw = case raw of
  Silence _ c -> return c
  File f -> fmap read $ readProcess "soxi" ["-c", f] ""
  Pad    _ _ raw' -> getChannels raw'
  Trim   _ _ raw' -> getChannels raw'
  Cutoff _ _ raw' -> getChannels raw'
  Concatenate pairs -> getChannels $ snd $ head pairs
  Merge       pairs -> fmap sum $ mapM (getChannels . snd) pairs
  Mix         pairs -> getChannels $ snd $ head pairs
  Resample _ r -> return r

-- | Checks that the sample rate and channel count of the expression
-- match the type it is being cast to. If not, returns 'Nothing'.
getChannels raw = case raw of
  Silence _ c -> return c
  File f -> fmap read $ readProcess "soxi" ["-c", f] ""
  Pad    _ _ raw' -> getChannels raw'
  Trim   _ _ raw' -> getChannels raw'
  Cutoff _ _ raw' -> getChannels raw'
  Concatenate pairs -> getChannels $ snd $ head pairs
  Merge       pairs -> fmap sum $ mapM (getChannels . snd) pairs
  Mix         pairs -> getChannels $ snd $ head pairs
  Resample _ r -> return r

-- | Checks that the sample rate and channel count of the expression
-- match the type it is being cast to. If not, returns 'Nothing'.