packages feed

turing-music (empty) → 0.1

raw patch · 4 files changed

+120/−0 lines, 4 filesdep +ALUTdep +basesetup-changed

Dependencies added: ALUT, base

Files

+ LICENSE view
@@ -0,0 +1,31 @@+Copyright Péter Diviánszky 2008++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Péter Diviánszky nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+
+ Music.hs view
@@ -0,0 +1,54 @@+import Turing+import Machines++import Sound.ALUT+import Data.Maybe+import Data.List+import Data.Char++main :: IO ()+main = withProgNameAndArgs runALUT main'++main' :: String -> [String] -> IO ()+main' _progName [i]  | all isDigit i && read i<length machines   = playMachine $ machines !! read i+main' progName _ = mapM_ putStrLn $+    [ "Usage:"+    , " " ++ progName ++ " NUM"+    , "  where 0 <= NUM < " ++ show (length machines)+    , ""+    , "Hints:"+    ] ++ map (" "++) hints++playMachine :: Machine -> IO ()+playMachine m = do+    bData <- createBufferData (Sine 440 0 0.1)+    buffs <- mapM (createBuff bData) pentaton++    [source] <- genObjectNames 1+    loopingMode source $= Looping++    let play1 l@(h: _) = do+            stop [source]+            buffer source $= Just (buffs !! ((pos h + 5) `mod` length buffs))+            sourceGain source $= 0.5 + 0.5 * read [symbolAtHead h]+            play [source]+            sequence_ $ replicate (length l) $ putStr ('\n': showTape 40 h) >> sleep 0.1++    putStrLn ""+    mapM_ play1 $ groupBy eq $ run m initialState blankTape++eq :: Tape -> Tape -> Bool+eq t t' = goToMiddle t == goToMiddle t'++createBuff :: BufferData a -> Frequency -> IO Buffer+createBuff (BufferData m fmt f) x = do+    [b] <- genObjectNames 1+    bufferData b $= BufferData m fmt (x*f)+    return b++pentaton :: [Frequency]+pentaton = l ++ map (2*) l where l = [3/4, 8/9, 1/1, 9/8, 4/3]++++
+ Setup.hs view
@@ -0,0 +1,5 @@++import Distribution.Simple++main = defaultMainWithHooks defaultUserHooks+
+ turing-music.cabal view
@@ -0,0 +1,30 @@+name:           turing-music+version:        0.1+synopsis:       Plays music generated by Turing machines with 5 states and 2 symbols+description:    +    turing-music interprets 42 built-in Turing machines with 5 states and 2 symbols.+    In every 0.1 second, a motion is done and the contents of the tape is printed.+    At the same time, a sound is played. The pitch of the sound depends on the position of the last change+    on the tape.+    .+    The built-in machines are busy beaver candidates. +    A busy beaver is a Turing machine which, when given an empty tape, does a lot of work, then halts.+    Currently it is not known whether these simple machines halt or not. +category:       Game+author:         Péter Diviánszky <divip@aszt.inf.elte.hu>+maintainer:     Péter Diviánszky <divip@aszt.inf.elte.hu>+copyright:      (c) 2008 by Péter Diviánszky+license:        BSD3+license-file:   LICENSE+stability:      alpha+tested-with:    GHC == 6.8.2+build-type:     Simple+cabal-version:  >=1.2++executable turing-music+    ghc-options:    -Wall -fno-warn-name-shadowing -fno-warn-incomplete-patterns+    main-is:        Music.hs+    build-depends:+        base,+        ALUT >= 2+