Skip to content

Instantly share code, notes, and snippets.

View leftaroundabout's full-sized avatar

Justus Sagemüller leftaroundabout

  • KTH Royal Institute of Technology
  • Stockholm
View GitHub Profile

Cofree (Const c) ~~ Writer c

Given

data Const c a = Const c

we have

data Cofree (Const c) a

= a :< Const c

@leftaroundabout
leftaroundabout / PiMelody.hs
Last active January 2, 2023 00:54
An automatic accompaniment generator for infinite melodies, applied to a simple mapping of the decimal digits of π to an A–harmonic-minor scale.
module PiMelody where
import Data.List
data MelodyNote = Gs | A | B | C' | D' | E' | F' | Gs' | A' | B'
deriving (Eq, Show, Enum)
type Melody = [MelodyNote] -- Assume simple all-quavers rythm.
piMelody :: Melody
import Graphics.Dynamic.Plot.R2
import Data.Function
type Time = Double
type Duration = Time
type RMS = Double
pianoShape :: Duration -> Time -> RMS
pianoShape len t
| t<0 = 0
import Codec.Picture
import qualified Diagrams.Prelude as Dia
import Diagrams.Prelude ((^&))
import qualified Diagrams.Backend.Cairo as Dia
type = Double
horizContourLine ::
((,) -> ) -- ^ The topography/height function
-> (,) -- ^ x-interval on which to render the path
import Diagrams.Prelude
import Diagrams.Backend.Cairo
import Data.Colour.RGBSpace.HSV
import Data.Colour.SRGB.Linear
import Data.Numbers.Primes
import Control.Monad
import Graphics.Dynamic.Plot.R2
import Data.Function
main :: IO ()
main = do
plotWindow $
[ plotLatest
[plotMultiple
[ signalPlot (fmap (*μ) $ initSignal) & legendName "clean"

Well, ultimately music is always subjective. You can't really argue with someone who likes some particular music – they like what they like, and it would be dogmatism to condemn some composition just because it violates the theoretical frameworks that you happen to know.

That said, I personally would probably agree with your assessment. I don't think much of music that's just too arbitrary – not because it's bad to violate the standard theory, but because music should have a purpose. This is regardless of whether that purpose can be explained within Common Practice theory, with deliberately violating the common rules, with providing a completely new theoretical framework, or something else.

In other words, “Why it couldn't go there anyways?” is just not the right question to ask to rebut criticism. The right rebuttal is to give a reason why it would go there.

If he picked that particular harmony for a reason – whatever reason – then there's that. In doubt, the reason could simply be “I li

{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
{-# LANGUAGE DataKinds, KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables, UnicodeSyntax #-}
{-# LANGUAGE TypeFamilies, GADTs #-}
{-# LANGUAGE ConstraintKinds #-}
import Data.Singletons.TH -- http://hackage.haskell.org/package/singletons-2.7/
import Data.Singletons (sing, Sing, SingI)
import Control.Category.Constrained (Category(..)) -- http://hackage.haskell.org/package/constrained-categories-0.4.1.0
{-# LANGUAGE OverloadedLists #-}
import qualified Data.Vector.Unboxed as VU
import Data.Vector.Unboxed (Vector, (!))
import Data.MemoTrie (memo2)
import Graphics.Dynamic.Plot.R2
import Text.Printf
newtype Knots = Knots {getIncreasingKnotsSeq :: Vector Double}
@leftaroundabout
leftaroundabout / Main.hs
Last active August 16, 2020 20:06
ContinAbsvalParametrisation.hs
import Graphics.Dynamic.Plot.R2
import Data.Semigroup
import Control.Monad (join)
f, g :: Double -> Double
g t = t^2
f t
| t<0 = -t^2
| otherwise = t^2