sounddelay (empty) → 0.1.0.1
raw patch · 5 files changed
+169/−0 lines, 5 filesdep +WAVEdep +basedep +containerssetup-changed
Dependencies added: WAVE, base, containers, parseargs
Files
- COPYING +34/−0
- README.md +13/−0
- Setup.hs +7/−0
- sounddelay.cabal +31/−0
- sounddelay.hs +84/−0
+ COPYING view
@@ -0,0 +1,34 @@+Copyright (C) 2007 Bart Massey+ALL RIGHTS RESERVED++[This program is licensed under the "3-clause ('new') BSD License"]++Redistribution and use in source and binary forms, with or+without modification, are permitted provided that the+following conditions are met:+ * Redistributions of source code must retain the above+ copyright notice, this list of conditions and the following+ disclaimer.+ * Redistributions in binary form must reproduce the+ above copyright notice, this list of conditions and the+ following disclaimer in the documentation and/or other+ materials provided with the distribution.+ * Neither the name of Bart Massey, nor the names+ of other affiliated organizations, nor the names+ of other contributors may be used to endorse or promote+ products derived from this software without specific prior+ written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND+CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,13 @@+# sounddelay -- audio delay line+Copyright © 2008-2014 Bart Massey++This program is a simple command-line audio delay line for+WAVE format audio files. There is precious little+documentation at this point; that needs to be fixed soon.+However, I think it's a nice demo app for my+[WAVE](http://github.com/BartMassey/WAVE) library.++This program is licensed under the "3-clause 'new' BSD+License". Please see the file `COPYING` in this distribution+for license terms.+
+ Setup.hs view
@@ -0,0 +1,7 @@+--- Copyright (C) 2007 Bart Massey+--- ALL RIGHTS RESERVED+--- Please see the file COPYING in this software+--- distribution for license information.++import Distribution.Simple+main = defaultMain
+ sounddelay.cabal view
@@ -0,0 +1,31 @@+Name: sounddelay+Build-Type: Simple+Description: An audio file delay line for WAVE files.+Version: 0.1.0.1+License: BSD3+License-File: COPYING+Copyright: Copyright (c) 2008 Bart Massey+Author: Bart Massey <bart@cs.pdx.edu>+Maintainer: Bart Massey <bart@cs.pdx.edu>+Homepage: http://github.com/BartMassey/sounddelay+Stability: Alpha+Synopsis: Audio delay line+Category: Sound+Extra-Source-Files: README.md+Cabal-Version: >=1.10++Executable delay+ Default-Language: Haskell2010+ Main-Is: sounddelay.hs+ Build-Depends: base >=3&&<5, containers >=0.3&&<1,+ parseargs >=0.1&&<1,+ WAVE >=0.1&&<1++Source-Repository head+ Type: git+ Location: https://github.com/BartMassey/sounddelay.git++Source-Repository this+ Type: git+ Location: https://github.com/BartMassey/sounddelay.git+ Tag: v0.1.0.1
+ sounddelay.hs view
@@ -0,0 +1,84 @@+--- Copyright (C) 2007 Bart Massey+--- ALL RIGHTS RESERVED+--- Please see the end of this file for license information.++module Main+where++import Data.List+import Data.Maybe+import System.Environment+import System.Console.ParseArgs+import Data.WAVE+import DelayArgs+++delay :: Bool -> Int-> Int -> Double -> [[Double]] -> [[Double]]+delay forward channels delay_samples amplitude samples =+ result+ where+ samples' = map (map (* (1.0 - amplitude))) samples+ silent_frame = replicate channels 0.0+ mix = if forward+ then samples'+ else result+ mix' = replicate delay_samples silent_frame ++ mix+ mix'' = map (map (* amplitude)) mix'+ result = zipWith (zipWith (+)) mix'' samples'+++main :: IO ()+main = do+ args <- parseArgsIO ArgsComplete argd+ --- get the input+ h <- getArgStdio args OptionInputFile ReadMode+ wav <- hGetWAVE h+ let samples = map (map sampleToDouble) (waveSamples wav)+ --- figure the parameters+ let hd = waveHeader wav+ let rate = waveFrameRate hd+ let odelay = fromJust (getArgInt args OptionDelay)+ let delay_samples = rate * odelay `div` 1000+ let amplitude = fromJust (getArgDouble args OptionAmplitude) / 100+ let forward = gotArg args OptionForward+ let channels = waveNumChannels hd+ --- run delay program on the input+ let result = delay forward channels delay_samples amplitude samples+ --- write the output+ let samples' = map (map doubleToSample) result+ let wav' = WAVE { waveHeader = hd,+ waveSamples = samples' }+ h' <- getArgStdio args OptionOutputFile WriteMode+ hPutWAVE h' wav'+++ +--- Redistribution and use in source and binary forms, with or+--- without modification, are permitted provided that the+--- following conditions are met:+--- * Redistributions of source code must retain the above+--- copyright notice, this list of conditions and the following+--- disclaimer.+--- * Redistributions in binary form must reproduce the+--- above copyright notice, this list of conditions and the+--- following disclaimer in the documentation and/or other+--- materials provided with the distribution.+--- * Neither the name of Bart Massey, nor the names+--- of other affiliated organizations, nor the names+--- of other contributors may be used to endorse or promote+--- products derived from this software without specific prior+--- written permission.+--- +--- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND+--- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,+--- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF+--- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+--- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR+--- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+--- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT+--- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+--- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+--- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN+--- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR+--- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+--- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.