Hi Kashyap. Glad to see someone using Euterpea!  Here are some comments that 
may help you to simplify and clarify your code:


*         "Modify (Instrument Percussion) m" can be written "instrument 
Percussion m".

*         Similarly, "Modify (Phrase [Dyn (Loudness 50)] m" can be written 
"phrase [Dyn (Loudness 50)] m".

*         When using a percussion instrument, instead of writing, for example, 
"gs 3 en", you can write "perc PedalHiHat en", which, although longer, is 
certainly more readable.

*         "line []" is the same as "rest 0".

*         There is a function "timesM" in Euterpea, so "base n" can be 
eliminated, and you can just write "timesM n base' ".

*         There are also function "takeM" and "repeatM", so that:
"(line (take (n * 16) (cycle [gs 3 en])))" can be written:
"takeM (2*n) (repeatM (gs 3 en))"

*         I also wonder if you can take advantage of infinite music values in 
Euterpea.  There is a parallel composition operator (/:=) that gives a result 
with duration equal to the shortest of its two arguments.  So, for example:
rhythm = instrument Percussion (repeat (gs 3 en) :=: repeat (c 3 en :+: rest en 
:+: e 3 en :+: rest en))
... <something similar for base>
music = (bnr :+: rhythm) /=: (rest 4 :+: t1 :+: t2) /=: base

I haven't tested any of this, but I hope it's helpful.

Best wishes,    -Paul

Paul Hudak
Professor of Computer Science
Yale University, PO Box 208285
New Haven, CT 06520-8285, 203-432-1235

From: CK Kashyap [mailto:ck_kash...@yahoo.com]
Sent: Monday, March 04, 2013 7:18 AM
To: haskell-art@lurk.org
Subject: [haskell-art] Review request

Hi,
I tried my hands at composition using Euterpea. It can be found here - 
https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/haskore/drums.hs

I'd appreciate it very much if I get some feedback around the level of 
abstraction that I am using.

Also, I have a quick question on how I could emit a midi file. I am using 
windows.

Regards,
Kashyap
_______________________________________________
haskell-art mailing list
haskell-art@lurk.org
http://lists.lurk.org/mailman/listinfo/haskell-art

Reply via email to