Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

lolol sussman theme snake ^__^

Name: Anonymous 2008-04-27 6:58

% ghc sicp.hs && ./a.out > /dev/dsp (or | aplay for real men)
module Main where
import Data.Char
makeU8 x freq = (((sin (x * (2 * pi) * (freq / 8000))) + 1) * 128.0)
tone freq length amplitude x =
  if x >= length
    then []
    else (floor ((makeU8 x freq) * amplitude)) : tone freq length (0.99925 * amplitude) (x + 1)
tones = [("c2", 65.406), ("d2", 73.416), ("e2", 82.407), ("f2", 87.307), ("g2", 97.999), ("a2", 110.00), ("b2", 123.47), ("c3", 130.81), ("d3", 146.83), ("e3", 164.81), ("f3", 174.61), ("g3", 196.00), ("a3", 220.00), ("b3", 246.94), ("c4", 261.63), ("d4", 293.66), ("e4", 329.63), ("f4", 349.23), ("g4", 392.00)]
t x = case lookup x tones of
        Just y -> (tone y 2000 0.75 0) :: [Int]
        Nothing -> []
main = do
  putStr $ map chr $ concatMap t ["g3", "a3", "b3", "d4", "c4", "c4", "e4", "d4", "d4", "g4", "f4", "g4", "d4", "c4", "g3", "a3", "b3", "c4", "d4", "e4", "d4", "c4", "b3", "a3", "b3", "g3", "f3", "g3", "a3", "d3", "f3", "a3", "c4", "b3", "a3", "b3", "g3", "a3", "b3", "d4", "c4", "c4", "e4", "d4", "d4", "g4", "f4", "g4", "d4", "b3", "g3", "a3", "b3", "e3", "d4", "c4"]

Name: Anonymous 2008-04-29 15:38

>>40
You mean: IT SOUNDS PRETTY GODLY! *FLASH OF LIGHTNING*

Name: Anonymous 2008-04-29 19:57

>>34
It's designed to be ioctl'd, but >>35 is right

Name: Anonymous 2008-04-29 20:16

>>1
Can someone be kind enough to translate this to something more natural? I can't stand haskell. I fucking hate it.

Scheme, maybe?

Name: Anonymous 2008-04-29 23:26

>>43
Pretty simple really. You have a makeU8(x,freq) function, read it yourself.
Then tone(freq,amplitute,length) = map (lambda (x) -> floor(makeU8(x,freq)*amplitude), (0,1,2,3,..,length))
There is a map of notes to frequency. Send notes/frequencies to (tone freq 2000 0.75 0) one by one. You get a list of integers for a note. Concatenate the list. Integers to characters. Output.

Name: Anonymous 2008-04-30 2:37

>>1
I love you.

Name: Anonymous 2008-05-08 12:59

banpu pantii

Name: Anonymous 2008-05-08 13:49

Bampen Panzen.

Name: Anonymous 2008-05-08 15:26

Why not do the string → frequency mapping algorithmically instead of using a list lookup? Seems like it'd be more flexible and reduce the amount of magic numbers present in the code. I'm too lazy to do it, but it should be simple.

Name: Anonymous 2008-05-08 15:34

>>48
Give me the algorithm and I'll do it -- I couldn't find it, however, and these numbers are standardized by some committee.

Name: Anonymous 2008-05-08 15:43

>>48
Give me the algorithm and I'll do it -- I couldn't find it, however, and these numbers are standardized by some committee.

Just plotted it with gnuplot... doesn't make sense.

Name: !lISpiTOn52 2008-05-12 4:07

Name: Anonymous 2008-05-12 6:12

Lame. this isn't very nice for a haskell program...

-- ...
notes = concat [["g3", "a3", "b3", "d4", "c4", "c4", "e4", "d4", "d4", "g4", "f4", "g4", "d4", "c4", "g3", "a3", "b3", "c4", "d4", "e4", "d4", "c4", "b3", "a3", "b3", "g3", "f3", "g3", "a3", "d3", "f3", "a3", "c4", "b3", "a3", "b3", "g3", "a3", "b3", "d4", "c4", "c4", "e4", "d4", "d4", "g4", "f4", "g4", "d4", "b3", "g3", "a3", "b3", "e3", "d4", "c4"], notes]

main = do
  putStr $ map chr $ concatMap t notes

Now THAT's good haskell!

Name: Anonymous 2008-05-12 15:58

>>51
A fascinating read. Thanks.

Name: Anonymous 2008-05-12 16:58

>>51
thx mon

Name: Anonymous 2009-03-06 7:44


C You can tell   you how 661.

Name: Anonymous 2009-03-06 7:44

SORTED SUBJECT.TXT: http://noog.org/cgi-bin/prog

Name: Sgt.Kabukiman䖉 2012-05-22 23:31

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List