Skip to main content

Posts

Showing posts from April, 2008

functional music, honorable mention of new composer C.W. Boese

just after the previous post a talented composer (Boese) used the small framework for functional music in haskell for one of his compisitions. His work balances harmony and disharmony in an unbalanced way and thereby balances the unbalancing and balancing forces driving the excellent piece of modern algorithmic music. with his silent permission the source as well the interpretation is attached to this post. Here's the interpretation using an artifical Clarinet: play . Here's the source: boeseboese = Rest (2/4) :+: (hochlauf (-2) 3 boese) :=: (hochlauf (2) 3 boese) :+: boese boese = rpt 3 freak :=: rpt 3 ghoul :=: rpt 3 funk grund = (Note (Cis,5) 1) freak = rptm (Trans (round (abs (duration ghoul)))) 3 funk ghoul = akkord grund 0 funk = Trans terz grund :=: rptm (Trans quinte) 4 ghoul just append that to the previous program and adapt the main function. Maybe it's also worth mentioning, that this was the first piece of haskell code written by him. Haskell syntax helps to cre...

Learning Haskell, functional music

As you might have realized, I started to learn Haskell. One of the most fun things to do in any programming language is creating some kind of audible side effects with a program. Already back in the days when I started programming, I always played around with audio when toying around with a new language. I have found a wonderful set of lecture slides about haskell and multimedia programming, called school of expression. Inspired by the slides about functional music I implemented a little song. Ahh ... and yes it is intended to sound slightly strange . I used the synthesis toolkit to transform the music to real noise, simply by piping skini message to std-out. I used this command line to achieve the results audible in the table: sven@hhi1214a:~/Mukke$ ghc -o test1 test1.hs && ./test1 | stk-demo Plucked -n 16 -or -ip Sound samples: Plucked play Clarinet play Whistle(attention very crazy!) play As always the source... stueck = anfang :+: mitte :+: ende anfang = groovy :+: (Trans ...

Haskell Thread Ring Benchmark

Not as fast as the erlang version coming soon: import Control.Monad import Control.Concurrent import System.Environment import System.CPUTime fork_ring_elem prev_mvar _ = do next_mvar forkIO (ring_elem prev_mvar next_mvar) return next_mvar ring_elem :: MVar Int -> MVar Int -> IO () ring_elem prev_mv next_mv = run where run = do token putMVar next_mv (token - 1) when ( token > 0 ) run first_ring_elem :: MVar Int -> MVar Int -> IO () first_ring_elem prev_mv next_mv = run where run = do token putMVar next_mv (token - 1) putStrLn "." when ( token > 0 ) run main = do (procsArg:roundsArg:_) first_mvar t1 last_mvar t2 putStrLn ("forked processes in " ++ (show (t2 - t1)) ++ " ps") first_ring_elem last_mvar first_mvar t3 putStrLn "\n***finished***" putStrLn ("total time: " ++ (show (t3 - t1)) ++ " ps")