VictorCMiraldo / hs-fragem

Haskell Fractal Geometry of Music
MIT License
4 stars 0 forks source link

Write our own "synthetiser" #2

Closed VictorCMiraldo closed 6 years ago

VictorCMiraldo commented 6 years ago

We need a better way of representing music for creating hand-crafted examples.

Midi is horrible; half the files don't parse. Half the parser doesn't work.

Potential Solution 1:

music = synth 
          $ Piece (TimeSig 4 4)
          [ [ Hole C , Half Pause , Half D , Half E , Dot (Hole G)]
          , ...
          ]

And the value returned by that call to the synth function looks something like:

music = Section (TimeSig 4 4) 240
          $ [ [ Note 0 240 (midiPitch C)
             , Note 360 120 (midiPitch D)
             , Note 480 120 (midiPitch D)
            ,  Note 600 360 (midiPitch G)
            ], ... ]

Potential Solution 2:

Write something that already outputs some regular or random things in our own Fragem.Syntax datatype.

irisyupingren commented 6 years ago

Good point! I was thinking that too.

Potential solution 1 is perhaps better for readability and specifying little tunes we know and would like to investigate.

Potential solution 2 is perhaps better for scalability. For example, it would be nice to have something which can generate:

Where do you suggest we put the script? /Fragem?

irisyupingren commented 6 years ago

The random synthesiser based on quickcheck will be in the Midi folder as we discussed today.

I have added types and functions as we worked on it today. But I couldn't resolve two type errors on Gen. I wonder how I could understand this type better...

And would a folder name like GenMidi makes it clearer?

irisyupingren commented 6 years ago

Battling with generation. Hope to have something like this but not working yet:

createrandom :: FilePath -> Int -> IO() createrandom f n = flip map [0..n] $ exportFile f $ midiSkeleton $ concat $ map playnote genMelody

Would be great to have some help... @VictorCMiraldo

(Also forgetting also to run the Example.hs didn't help... was it also something like stack exec Example.hs ? )

VictorCMiraldo commented 6 years ago

What exactly is not working?

Make sure you got the generation of a single file working, then you just mapM that very function.

irisyupingren commented 6 years ago

Thanks! It's working now!! Still need to clean the code though...