algorithmic-composition-overtones (empty) → 0.1.0.0
raw patch · 5 files changed
+111/−0 lines, 5 filesdep +algorithmic-composition-basicdep +basesetup-changed
Dependencies added: algorithmic-composition-basic, base
Files
- ChangeLog.md +5/−0
- Composition/Sound/Functional/OvertonesO.hs +59/−0
- LICENSE +20/−0
- Setup.hs +2/−0
- algorithmic-composition-overtones.cabal +25/−0
+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for algorithmic-composition-overtones++## 0.1.0.0 -- 2021-03-07++* First version. Released on an unsuspecting world.
+ Composition/Sound/Functional/OvertonesO.hs view
@@ -0,0 +1,59 @@+-- |+-- Module : Composition.Sound.Functional.OvertonesO+-- Copyright : (c) OleksandrZhabenko 2021+-- License : MIT+-- Stability : Experimental+-- Maintainer : olexandr543@yahoo.com+--+-- Some variants of the f :: 'Float' -> 'OvertonesO' function that can be used for overtones+-- (and a timbre respectively) generation.++{-# LANGUAGE BangPatterns #-}+{-# OPTIONS_HADDOCK show-extensions #-}+{-# OPTIONS_GHC -threaded #-}++module Composition.Sound.Functional.OvertonesO where++import GHC.Arr+import Composition.Sound.Functional.Basics++{-| For the given frequency of the note it generates a list of the tuples, each one of which contains the harmonics' frequency+and amplitude. Is taken from the Composition.Sound.Functional.Basics module, so it must be imported qualified to be used with+the last one. -}+overTones :: Float -> OvertonesO+overTones = overTonesKNPG 1 1 2 1.0+{-# INLINE overTones #-}++{-| A generalized variant of the 'overTones' function with just two additional control parameters (so represents a two-parameters additionally parameterized family of 'overTones' functions). -}+overTonesKN2 :: Int -> Int -> Float -> OvertonesO+overTonesKN2 k n = overTonesKNPG k n 2 1.0+{-# INLINE overTonesKN2 #-}++{-| A generalized variant of the 'overTones' and 'overTonesKN2' with the possibility to specify the additional parameters for them. -}+overTonesKNPG :: Int -> Int -> Int -> Float -> Float -> OvertonesO+overTonesKNPG k n p amplK note =+ takeWhile (\(!w,!z) -> w <= unsafeAt notes 107 && abs z > 0.001) . filter (\(_,z) -> abs z <= 1.0) . map (\i ->+ (note * abs (fromIntegral (i + k)), amplK / fromIntegral (product . replicate p $ (i + n)))) $ [1 - n..40000 * abs n]++{-| A generalized variant of the 'overTones' and 'overTonesKN2' with the possibility to specify the additional parameters for them. Otherwise than the similar 'overTonesKNPG', it can generate the higher overtones than the B8 to the 20000 Hz. -}+overTonesKNPG20k :: Int -> Int -> Int -> Float -> Float -> OvertonesO+overTonesKNPG20k = overTonesKNPG20kF id+{-# INLINE overTonesKNPG20k #-}++{-| A generalized variant of the 'overTonesKNPG20k' with the possibility to specify the additional function to control the overtones amplitudes. Otherwise than the similar 'overTonesKNPG', it can generate the higher overtones than the B8 to the 20000 Hz. The first argument, the function @f@ is intended to be a monotonic growing one though it can be not necessary. -}+overTonesKNPG20kF :: (Float -> Float) -> Int -> Int -> Int -> Float -> Float -> OvertonesO+overTonesKNPG20kF f = overTonesKNPG20kFALaClarinet f id+{-# INLINE overTonesKNPG20kF #-}++{-| Is taken from the Composition.Sound.Functional.Basics module, so it must be imported qualified to be used with+the last one. -}+overTonesALaClarinet :: Float -> OvertonesO+overTonesALaClarinet note =+ takeWhile (\(!w,!z) -> w <= unsafeAt notes 107 && abs z > 0.001) . map (\i ->+ (note * fromIntegral (2 * i + 1), 1 / fromIntegral ((i + 1) * (i + 1)))) $ [0..512]++{-| A generalized variant of the 'overTonesKNPG20k' with the possibility to specify the additional function to control the overtones amplitudes. Otherwise than the similar 'overTonesKNPG', it can generate the higher overtones than the B8 to the 20000 Hz. The first argument, the function @f@ is intended to be a monotonic growing one though it can be not necessary. The second one parameter -- the @g@ function can be simply (*2), (*4) or something else and also is intended to be monotonic. -}+overTonesKNPG20kFALaClarinet :: (Float -> Float) -> (Int -> Int) -> Int -> Int -> Int -> Float -> Float -> OvertonesO+overTonesKNPG20kFALaClarinet f g k n p amplK note =+ takeWhile (\(!w,!z) -> w <= 20000.0 && abs z > 0.001) . filter (\(_,!z) -> abs z <= 1.0) . map (\i ->+ (note * abs (fromIntegral (g i + k)), f (amplK / fromIntegral (product . replicate p $ (i + n))))) $ [1 - n..]
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2021 OleksandrZhabenko++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ algorithmic-composition-overtones.cabal view
@@ -0,0 +1,25 @@+-- Initial algorithmic-composition-overtones.cabal generated by cabal init.+-- For further documentation, see http://haskell.org/cabal/users-guide/++name: algorithmic-composition-overtones+version: 0.1.0.0+synopsis: Some variants of the overtones functions to generate a timbre.+description: Can be used with the Composition.Sound.Functional.Basics.overSoXSynthGG function or some other way.+homepage: https://hackage.haskell.org/package/algorithmic-composition-overtones+license: MIT+license-file: LICENSE+author: OleksandrZhabenko+maintainer: olexandr543@yahoo.com+copyright: Oleksandr Zhabenko+category: Sound, Audio+build-type: Simple+extra-source-files: ChangeLog.md+cabal-version: >=1.10++library+ exposed-modules: Composition.Sound.Functional.OvertonesO+ -- other-modules:+ other-extensions: BangPatterns+ build-depends: base >=4.8 && <4.15, algorithmic-composition-basic >=0.2.2 && <1+ -- hs-source-dirs:+ default-language: Haskell2010