Southpaw 0.1.0.1 → 0.1.0.2
raw patch · 2 files changed
+3/−23 lines, 2 files
Files
- Southpaw.cabal +1/−1
- lib/Southpaw/AbbeyRoad/Capture.hs +2/−22
Southpaw.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 0.1.0.1 +version: 0.1.0.2 -- A short (one-line) description of the package. synopsis: Assorted utility modules
lib/Southpaw/AbbeyRoad/Capture.hs view
@@ -72,13 +72,8 @@ --------------------------------------------------------------------------------------------------- samplerate = 44100 :: Int -- TODO: Don't hard-code sample rate -mono8BufferSize = bufferSize 1 (undefined :: Word8) -mono16BufferSize = bufferSize 1 (undefined :: Int16) -stereo8BufferSize = bufferSize 2 (undefined :: Word8) -stereo16BufferSize = bufferSize 2 (undefined :: Int16) - --------------------------------------------------------------------------------------------------- -- Functions --------------------------------------------------------------------------------------------------- @@ -126,7 +121,7 @@ withCaptureDevice :: (Maybe String) -> Double -> (Device -> IO c) -> IO (Maybe c) withCaptureDevice specifier secs onsuccess = bracket acquire finally between where format = Mono16 - finally = maybe (return False) (\mic -> putStrLn "Closing device..." >> captureStop mic >> captureCloseDevice mic) + finally = maybe (return False) $ \mic -> captureStop mic >> captureCloseDevice mic record mic = captureStart mic >> return mic acquire = captureOpenDevice specifier (fromIntegral samplerate) format (numSamples secs) between mmic = case mmic of @@ -136,9 +131,7 @@ -- | -- TODO: Refactor --- capture :: V.Storable a => (Maybe String) -> Double -> IO (MemoryRegion a) -- capture :: Storable a => (Maybe String) -> Double -> (MemoryRegion a -> IO c) -> IO c --- capture :: (Maybe String) -> Double -> IO (V.Vector Int16) capture :: Maybe String -> Double -> (MemoryRegion CInt -> IO c) -> IO (Maybe c) -- According to GHCi capture specifier duration action = withCaptureDevice specifier duration record where num = numSamples duration @@ -163,17 +156,4 @@ checkAlcErrors :: Device -> IO [String] checkAlcErrors device = do errs <- get $ alcErrors device - return [ d | ALCError _ d <- errs ] - ---------------------------------------------------------------------------------------------------- - --- | -withFileContents :: FilePath -> (MemoryRegion a -> IO b) -> IO b -withFileContents filePath action = - bracket (openBinaryFile filePath ReadMode) hClose $ \handle -> do - numBytes <- fmap fromIntegral (hFileSize handle) - allocaBytes numBytes $ \buf -> do - bytesRead <- hGetBuf handle buf numBytes - when (bytesRead /= numBytes) $ - ioError (userError "hGetBuf") - action (MemoryRegion buf (fromIntegral numBytes))+ return [ d | ALCError _ d <- errs ]