i-love-emily

21 views
Skip to first unread message

Hans Höglund

unread,
Aug 10, 2014, 6:49:22 PM8/10/14
to apfe...@quantentunnel.de, simon....@gmail.com, music-sui...@googlegroups.com
Hi Heinrich and Simon,

I just discovered i-love-emily, which puts this conversation [1] in a whole new light. After looking at your code I think you are setting on a path do duplicate a lot of the structures in Music Suite, which probably benefits no one.

I now realise that it is not obvious from the Music Suite documentation how to get started with a *simple* representation. For example this code:

---------

data Note = Note
    { pitch    :: Int
    , start    :: Time
    , duration :: Time
    , channel  :: Int
    } deriving (Eq,Read,Show)

type Notes    = [Note]

type Metadata = [(String,String)]
type Score    = (Metadata, Notes)

---------
could be rewritten as:
---------

import Music.Prelude.Basic hiding (Score, Note)
import qualified Music.Prelude.Basic as M

type Pitch = Int
type Channel = Int
newtype Note = Note { getNote :: (Pitch, Channel) }
type Score = M.Score Note

-- To get access to pitch and part combinators:

instance Wrapped where
  type Unwrapped = Note (Pitch, Channel)
  _Wrapped' = iso Note getNote

type instance Pitch Note = Pitch
type instance Part Note = Channel
instance HasPitch Note where
  pitch = _Wrapped . _1
instance HasPitch Note where
  pitch = _Wrapped . _2

---------

Of course this is not exactly shorter, but consider the benefits: you get all the Music Suite combinators for manipulating time, pitch, meta-data, import and export. I spent a lot of time developing this and you probably don't want to waste time on low-level concepts that have already been implemented, especially since you already seem dedicated to depend on the Suite (for its notation output, I assume).

I would really like to make the Suite more accessible:  in part by improving its design, but also (perhaps more importantly) its documentation and I could really use your (informal) feedback for this. In turn I'd be happy to help you navigate around any problems you run into.

Heinrich Apfelmus

unread,
Aug 13, 2014, 10:10:56 AM8/13/14
to Hans Höglund, simon....@gmail.com, music-sui...@googlegroups.com
Hello Hans,

thanks for having a look. I didn't realize that I could take a custom data type and make it an instance of the various type classes in the music-suite; I always thought that the music-suite would offer a default data type ("free type") which I would have to convert to and from.

However, I'm not sure if we will be using music-suite extensively. The current focus of the project -- as I see it -- is a more or less direct translation of David Cope's LISP code to Haskell 2010, using a beginner-friendly Prelude style. This may duplicate some structures and functionality, but I very much like the list functions from the Prelude. This style also works well with the HCodecs library for MIDI input and output.


Then again, I don't understand the music-suite very well, so I don't know what we're missing out on. Lilypond output seems great. I tried to convert our custom data type directly, but the `events` combinator didn't work as expected, so I gave up on that for now.


Best regards,
Heinrich Apfelmus
Reply all
Reply to author
Forward
0 new messages