Last active
October 19, 2020 17:59
-
-
Save solomon-b/49262bf97faf635246270a8508952762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Notes on comonadic signal generation | |
time :: Store Double Double | |
time = store id 0 | |
sineStore :: Double -> Store Double Double | |
sineStore freq = store sine 0 | |
where | |
sine :: Double -> Double | |
sine t = sin (2 * pi * t * freq) | |
sawtoothStore :: Double -> Store Double Double | |
sawtoothStore freq = store saw 0 | |
where | |
saw :: Double -> Double | |
saw t = ((t * freq) - fromIntegral (floor (t * freq))) | |
triangleStore :: Double -> Store Double Double | |
triangleStore = fmap asin . sineStore | |
squareStore :: Double -> Store Double Double | |
squareStore = fmap signum . sineStore | |
amMod :: Store (First Double) Double -> Store (First Double) Double -> Store (First Double) Double | |
amMod cv sig = (*) <$> cv <@> sig | |
window :: Double -> Double -> Store Double Double -> [Double] | |
window interval size store = experiment (\s -> [s, s+interval..s+size]) store | |
--windowAvg :: Int -> Store Int Int -> Double | |
--windowAvg size = (/ fromIntegral size) . fromIntegral . sum . window size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment