Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lemol/audiohs
A library for play and record audio in haskell.
https://github.com/lemol/audiohs
Last synced: about 5 hours ago
JSON representation
A library for play and record audio in haskell.
- Host: GitHub
- URL: https://github.com/lemol/audiohs
- Owner: lemol
- License: mit
- Created: 2014-01-10T19:33:36.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-13T01:12:30.000Z (almost 11 years ago)
- Last Synced: 2023-03-23T11:58:19.289Z (over 1 year ago)
- Language: Haskell
- Homepage:
- Size: 184 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Audiohs
=======Provides functions for easily play and record sounds in haskell. It uses `Data.Vector Float` as array type.
Install
-------At background this package uses the cross platform [PortAudio] [portaudio-lib] library to play and record sounds, so first the portaudio bindings [portaudio] [portaudio-package] for haskell must be installed. See [here] [portaudio-package] for instructions.
1. Install [portaudio][portaudio-package] bindings
```shell
cabal install portaudio
```2. Download [the lastest version of audiohs] [hsaudio-master] and install it:
```shell
git clone https://github.com/lemol/audiohs.git
cd hsaudio
cabal install
```Usage
-----Just import `Sound.Audio(play, record)` and use the functions:
```haskell
play :: Double -> Vector Float -> IO ()
play fs xrecord :: Int -> Double -> Vector Float
x <- record count fs
```Examples
--------1. Playing a 3 seconds 440 Hz tone.
```haskell
import Sound.Audio (play)
import qualified Data.Vector as Vfs :: Double
fs = 44100sineWave :: V.Vector Float
sineWave = V.fromList $ map sinList [0..3*fs'-1]
where
sinList = sin . (2 * 440 * pi/fs' *)
fs' = realToFrac fsmain :: IO ()
main = play fs sineWave
```2. Record for 5 seconds and play the result.
```haskell
import Sound.Audio (play, record)fs :: Double
fs = 44100main :: IO ()
main = do
x <- record (5*44100) fs
play fs x
```Or, even better:
```haskell
main = record (5*44100) fs >>= play fs
```License
-------
(c) 2014 Leza Morais Lutonda (Lemol-C)
[MIT License] [lemolsoft-mit-license]Contribuitions
--------------
Critiques, suggestion, pull request, etc. all are wellcome!Credits
-------
This package is thanks to the [portaudio][portaudio-package] bindings for haskell.[portaudio-lib]: http://portaudio.com/
[portaudio-package]: http://hackage.haskell.org/package/portaudio
[lemolsoft-mit-license]: http://lemolsoft.mit-license.org/
[hsaudio-master]: https://github.com/lemol/audiohs/archive/master.zip