Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrZhabenko committed Dec 28, 2020
0 parents commit af8a007
Show file tree
Hide file tree
Showing 65 changed files with 6,978 additions and 0 deletions.
81 changes: 81 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Revision history for dobutokO-effects

## 0.1.0.0 -- 2020-06-27

* First version. Released on an unsuspecting world.

## 0.2.0.0 -- 2020-06-29

* Second version. Added a new module DobutokO.Sound.Effects.Remix to deal with the SoX "remix" effect.

## 0.3.0.0 -- 2020-06-30

* Third version. Added new modules DobutokO.Sound.Effects.Timespec and DobutokO.Sound.Effects.Delay. Some minor documentation improvements.

## 0.3.1.0 -- 2020-06-30

* Third version revised A. Fixed issue for GHC 7.8* series with ambiguous mconcat usage.

## 0.4.0.0 -- 2020-07-02

* Fourth version. Added new modules DobutokO.Sound.Effects.Specs, DobutokO.Sound.Effects.PassReject, DobutokO.Sound.Effects.BassTreble.

## 0.5.0.0 -- 2020-07-04

* Fifth version. Added new modules DobutokO.Sound.Effects.Trim, DobutokO.Sound.Effects.Repeat, DobutokO.Sound.Effects.Phaser,
DobutokO.Sound.Effects.Chorus, DobutokO.Sound.Effects.Modulation2, DobutokO.Sound.Effects.Echo, DobutokO.Sound.Effects.Misc,
DobutokO.Sound.Effects.Channels, DobutokO.Sound.Effects.Bend,Segment, DobutokO.Sound.Effects.Pitch, DobutokO.Sound.Effects.Tempo,
DobutokO.Sound.Effects.Speed.

## 0.6.0.0 -- 2020-07-06

* Sixth version. Added new modules DobutokO.Sound.ToRange, DobutokO.Sound.Effects.Biquad, DobutokO.Sound.Effects.Contrast,
DobutokO.Sound.Effects.DCShift, DobutokO.Sound.Effects.Downsample, DobutokO.Sound.Effects.Upsample, DobutokO.Sound.Effects.Hilbert,
DobutokO.Sound.Effects.Loudness, DobutokO.Sound.Effects.Overdrive, DobutokO.Sound.Effects.Tremolo.

## 0.7.0.0 -- 2020-07-09

* Seventh version. Fixed issue with DobutokO.Sound.Effects.Timespec module with timeSpecC function. Added DobutokO.Sound.One, DobutokO.Sound.Effects.Noise,
DobutokO.Sound.Effects.Pad, DobutokO.Sound.Effects.MCompand modules. Some minor code improvements.

## 0.7.1.0 -- 2020-07-09

* Seventh version revised A. Fixed issue with DobutokO.Sound.Effects.Pad module with double (ambiguous) import of mconcat.

## 0.8.0.0 -- 2020-07-11

* Eighth version. Added new modules DobutokO.Sound.Effects.Dither, DobutokO.Sound.Effects.FIR, DobutokO.Sound.Effects.Flanger, DobutokO.Sound.Effects.Gain,
DobutokO.Sound.Effects.LADSPA, DobutokO.Sound.Effects.Rate, DobutokO.Sound.Effects.Vol. Some minor code improvements.

## 0.9.0.0 -- 2020-07-13

* Ninth version. Fixed issue with being wrongly defined Show instance in the DobutokO.Sound.Effects.Rate module. Added new modules
DobutokO.Sound.Effects.Silence, DobutokO.Sound.Effects.Sinc, DobutokO.Sound.Effects.Stretch.

## 0.10.0.0 -- 2020-07-15

* Tenth version. Fixed issue with being out of range application of the toRange function in the modules: DobutokO.Sound.Effects.Dither,
DobutokO.Sound.Effects.Flanger, DobutokO.Sound.Effects.Rate, DobutokO.Sound.Effects.Reverb, DobutokO.Sound.Effects.Sinc, DobutokO.Sound.Effects.Remix.
Fixed issue with the empty list in the MscS data in the DobutokO.Sound.Effects.Misc module. Added new modules DobutokO.Sound.Effects.Spectrogram,
DobutokO.Sound.Effects.Splice, DobutokO.Sound.Effects.Stat, DobutokO.Sound.Effects.Stats, DobutokO.Sound.Effects.Vad.

## 0.10.1.0 -- 2020-07-15

* Tenth version revised. Fixed issue with being not properly defined usage of mconcat for GHC 7.8* series.

## 0.11.0.0 -- 2020-07-18

* Eleventh version. Added a new module DobutokO.Sound.Effects.Classes with classes for the data types in other modules. Some code improvements.

## 0.12.0.0 -- 2020-07-21

* Twelfth version. Splitted the module DobutokO.Sound.Effects.Classes into four modules DobutokO.Sound.Effects.Classes.FstParam,
DobutokO.Sound.Effects.Classes.SndParam, DobutokO.Sound.Effects.Classes.ThdParam, DobutokO.Sound.Effects.Classes.FourthParam.
Added new modules DobutokO.Sound.Effects.Classes.FstParamSet, DobutokO.Sound.Effects.Classes.SndParamSet, DobutokO.Sound.Effects.Classes.ThdParamSet,
DobutokO.Sound.Effects.Classes.FourthParamSet and DobutokO.Sound.Effects.Classes.ComplexParamSet. Some code changes and improvements to make
it more usable with classes.

## 0.13.0.0 -- 2020-07-25

* Thirteenth version. Added README.markdown file. Extended the Set classes (where appropriate) with setG methods to provide unambiguous usage for the instances.
Added functions for conversion to the list of the One2 data. Some code improvements.
27 changes: 27 additions & 0 deletions DobutokO/Sound/Combine.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- |
-- Module : DobutokO.Sound.Combine
-- Copyright : (c) OleksandrZhabenko 2020
-- License : MIT
-- Stability : Experimental
-- Maintainer : [email protected]
--
-- Helps to create experimental music.
-- Can be used to represent SoX combining types.
--

{-# OPTIONS_GHC -threaded #-}

module DobutokO.Sound.Combine where

data Combine = C | S | MX | MP | MG | ML deriving Eq

instance Show Combine where
show C = "--combine concatenate"
show S = "--combine sequence"
show MX = "--combine mix"
show MP = "--combine mix-power"
show MG = "--combine merge"
show ML = "--combine multiply"

showC1 :: Combine -> [String]
showC1 = words . show
113 changes: 113 additions & 0 deletions DobutokO/Sound/Effects/BassTreble.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
-- |
-- Module : DobutokO.Sound.Effects.BassTreble
-- Copyright : (c) OleksandrZhabenko 2020
-- License : MIT
-- Stability : Experimental
-- Maintainer : [email protected]
--
-- Helps to create experimental music.
-- Can be used for applying the SoX \"bass\" or \"treble\" effects with the needed specifications.
--

{-# OPTIONS_GHC -threaded #-}
{-# LANGUAGE CPP, FlexibleInstances #-}

module DobutokO.Sound.Effects.BassTreble where

#ifdef __GLASGOW_HASKELL__
#if __GLASGOW_HASKELL__>=710
/* code that applies only to GHC 7.10.* and higher versions */
import GHC.Base (mconcat)
#endif
#endif
import Numeric (showFFloat)
import DobutokO.Sound.Effects.Specs hiding (Width(..),Width1)
#ifdef __GLASGOW_HASKELL__
#if __GLASGOW_HASKELL__==708
/* code that applies only to GHC 7.8.* */
mconcat = concat
#endif
#endif

data WidthS a = H a | K a | O a | Q a | S a deriving Eq

instance Show (WidthS Float) where
show (H x) = showFFloat Nothing x "h"
show (K x) = showFFloat Nothing x "k"
show (O x) = showFFloat Nothing x "o"
show (Q x) = showFFloat Nothing x "q"
show (S x) = showFFloat Nothing x "s"

type WidthS1 = WidthS Float

data FreqWidthS a b = FrS1 a | FrWS2 a b deriving Eq

instance Show (FreqWidthS Freq1 WidthS1) where
show (FrS1 x) = show x
show (FrWS2 x y) = mconcat [show x," ",show y]

type FreqWS2 = FreqWidthS Freq1 WidthS1

freqWidthSC :: FreqWidthS a b -> String
freqWidthSC (FrS1 _) = "FrS1"
freqWidthSC (FrWS2 _ _) = "FrWS2"

freqWidthS1 :: FreqWidthS a b -> a
freqWidthS1 (FrS1 x) = x
freqWidthS1 (FrWS2 x _) = x

freqWidthS2 :: FreqWidthS a b -> Maybe b
freqWidthS2 (FrS1 _) = Nothing
freqWidthS2 (FrWS2 _ y) = Just y

freqWidthSSet1 :: a -> FreqWidthS a b -> FreqWidthS a b
freqWidthSSet1 x (FrS1 _) = FrS1 x
freqWidthSSet1 x (FrWS2 _ y) = FrWS2 x y

freqWidthSSet2 :: b -> FreqWidthS a b -> FreqWidthS a b
freqWidthSSet2 y (FrS1 x) = FrWS2 x y
freqWidthSSet2 y (FrWS2 x _) = FrWS2 x y

data Bass a b = Bs a b deriving Eq

instance Show (Bass Float FreqWS2) where
show (Bs x y) = mconcat ["bass ",showFFloat Nothing x " ",show y," "]

type Bass1 = Bass Float FreqWS2

bass1 :: Bass a b -> a
bass1 (Bs x _) = x

bass2 :: Bass a b -> b
bass2 (Bs _ y) = y

bassSet1 :: a -> Bass a b -> Bass a b
bassSet1 x (Bs _ y) = Bs x y

bassSet2 :: b -> Bass a b -> Bass a b
bassSet2 y (Bs x _) = Bs x y

showBsQ :: Bass1 -> [String]
showBsQ = words . show

data Treble a b = Tr a b deriving Eq

instance Show (Treble Float FreqWS2) where
show (Tr x y) = mconcat ["treble ",showFFloat Nothing x " ",show y," "]

type Treble1 = Treble Float FreqWS2

treble1 :: Treble a b -> a
treble1 (Tr x _) = x

treble2 :: Treble a b -> b
treble2 (Tr _ y) = y

trebleSet1 :: a -> Treble a b -> Treble a b
trebleSet1 x (Tr _ y) = Tr x y

trebleSet2 :: b -> Treble a b -> Treble a b
trebleSet2 y (Tr x _) = Tr x y

showTrQ :: Treble1 -> [String]
showTrQ = words . show
130 changes: 130 additions & 0 deletions DobutokO/Sound/Effects/Bend.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
-- |
-- Module : DobutokO.Sound.Effects.Bend
-- Copyright : (c) OleksandrZhabenko 2020
-- License : MIT
-- Stability : Experimental
-- Maintainer : [email protected]
--
-- Helps to create experimental music.
-- Can be used for applying the \"bend\" SoX effect.
--

{-# OPTIONS_GHC -threaded #-}
{-# LANGUAGE FlexibleInstances #-}

module DobutokO.Sound.Effects.Bend where

import Numeric (showFFloat)
import DobutokO.Sound.Effects.Timespec

data BendTrio a b = Bend3 a b a deriving Eq

instance Show (BendTrio FirstTSpec Float) where
show (Bend3 x y z) = mconcat [show x, ",", showFFloat Nothing y ",", show z]

type BendTr3 = BendTrio FirstTSpec Float

bendTrio1 :: BendTrio a b -> a
bendTrio1 (Bend3 x _ _) = x

bendTrio2 :: BendTrio a b -> b
bendTrio2 (Bend3 _ y _) = y

bendTrio3 :: BendTrio a b -> a
bendTrio3 (Bend3 _ _ z) = z

bendTrioSet1 :: a -> BendTrio a b -> BendTrio a b
bendTrioSet1 x (Bend3 _ y z) = Bend3 x y z

bendTrioSet2 :: b -> BendTrio a b -> BendTrio a b
bendTrioSet2 y (Bend3 x _ z) = Bend3 x y z

bendTrioSet3 :: a -> BendTrio a b -> BendTrio a b
bendTrioSet3 z (Bend3 x y _) = Bend3 x y z

data FrameRate a = FR a deriving Eq

instance Show (FrameRate Float) where
show (FR x)
| compare x 10.0 /= LT && compare x 80.0 /= GT = "-f " ++ showFFloat Nothing x " "
| otherwise = ""

type FrRate = FrameRate Float

frameRate1 :: FrameRate a -> a
frameRate1 (FR x) = x

frameRateSet1 :: a -> FrameRate a
frameRateSet1 = FR

data OverSample a = OS a deriving Eq

instance Show (OverSample Float) where
show (OS x)
| compare x 4.0 /= LT && compare x 32.0 /= GT = "-o " ++ showFFloat Nothing x " "
| otherwise = ""

type OvSample = OverSample Float

overSample1 :: OverSample a -> a
overSample1 (OS x) = x

overSampleSet1 :: a -> OverSample a
overSampleSet1 = OS

data Bend a b c = Bnd c | Bnd1 a c | Bnd2 b c | Bnd12 a b c deriving Eq

instance Show (Bend FrRate OvSample BendTr3) where
show (Bnd z) = mconcat ["bend ",show z]
show (Bnd1 x z) = mconcat ["bend ",show x,show z]
show (Bnd2 y z) = mconcat ["bend ",show y,show z]
show (Bnd12 x y z) = mconcat ["bend ", show x, show y, show z]

type BendE = Bend FrRate OvSample BendTr3

bend1 :: Bend a b c -> Maybe a
bend1 (Bnd1 x _) = Just x
bend1 (Bnd12 x _ _) = Just x
bend1 _ = Nothing

bend2 :: Bend a b c -> Maybe b
bend2 (Bnd2 y _) = Just y
bend2 (Bnd12 _ y _) = Just y
bend2 _ = Nothing

bendE1 :: BendE -> FrRate
bendE1 (Bnd1 x _) = x
bendE1 (Bnd12 x _ _) = x
bendE1 _ = FR 25.0

bendE2 :: BendE -> OvSample
bendE2 (Bnd2 y _) = y
bendE2 (Bnd12 _ y _) = y
bendE2 _ = OS 16.0

bend3 :: Bend a b c -> c
bend3 (Bnd z) = z
bend3 (Bnd1 _ z) = z
bend3 (Bnd2 _ z) = z
bend3 (Bnd12 _ _ z) = z

bendSet1 :: a -> Bend a b c -> Bend a b c
bendSet1 _ (Bnd z) = Bnd z
bendSet1 x (Bnd1 _ z) = Bnd1 x z
bendSet1 x (Bnd2 y z) = Bnd12 x y z
bendSet1 x (Bnd12 _ y z) = Bnd12 x y z

bendSet2 :: b -> Bend a b c -> Bend a b c
bendSet2 y (Bnd z) = Bnd2 y z
bendSet2 y (Bnd1 x z) = Bnd12 x y z
bendSet2 y (Bnd2 _ z) = Bnd2 y z
bendSet2 y (Bnd12 x _ z) = Bnd12 x y z

bendSet3 :: c -> Bend a b c -> Bend a b c
bendSet3 z (Bnd _) = Bnd z
bendSet3 z (Bnd1 x _) = Bnd1 x z
bendSet3 z (Bnd2 y _) = Bnd2 y z
bendSet3 z (Bnd12 x y _) = Bnd12 x y z

showBndQ :: BendE -> [String]
showBndQ = words . show
Loading

0 comments on commit af8a007

Please sign in to comment.