Discussion:
[haskell-art] Review request
CK Kashyap
2013-03-04 12:18:02 UTC
Permalink
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
Hudak, Paul
2013-03-05 05:34:26 UTC
Permalink
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:***@yahoo.com]
Sent: Monday, March 04, 2013 7:18 AM
To: haskell-***@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
CK Kashyap
2013-03-05 11:10:19 UTC
Permalink
Wow ... it looks much better now!!!

Thank you so much for your feedback Professor Hudak.

I have not been able to figure out the way to dump the output into a midi file though.

Regards,
Kashyap
________________________________
Sent: Tuesday, March 5, 2013 11:04 AM
Subject: RE: [haskell-art] Review request
 
·         “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’ ”.
“takeM (2*n) (repeatM (gs 3 en))”
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 
 
Sent: Monday, March 04, 2013 7:18 AM
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
Donya Quick
2013-03-05 16:55:49 UTC
Permalink
Post by CK Kashyap
I have not been able to figure out the way to dump the output into a midi file though.
Euterpea has a function called "test" that writes a Music value to a MIDI
file called "test.mid" in the working directory. However, to do this,
Euterpea uses Codec.Midi from the HCodecs library to first create a Midi
value and then write a .mid file. Unfortunately, Codec.Midi seems to have
some bugs in the .mid file conversion, and, as a result, the .mid files are
readable by some programs but not others. If you are on Windows, SynthFont
(free) is usually able to open the files without problems.

-----Donya Quick
Post by CK Kashyap
Wow ... it looks much better now!!!
Thank you so much for your feedback Professor Hudak.
I have not been able to figure out the way to dump the output into a midi file though.
Regards,
Kashyap
------------------------------
*Sent:* Tuesday, March 5, 2013 11:04 AM
*Subject:* RE: [haskell-art] Review request
Hi Kashyap. Glad to see someone using Euterpea! Here are some comments
· “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’ ”.
“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.
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
*Sent:* Monday, March 04, 2013 7:18 AM
*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
CK Kashyap
2013-03-06 09:58:07 UTC
Permalink
Thank you Donya ...

I tried SynthFont ... it seems to work to some extent. The instruments go a little haywire though.

Regards,
Kashyap
________________________________
Sent: Tuesday, March 5, 2013 10:25 PM
Subject: Re: [haskell-art] Review request
 I have not been able to figure out the way to dump the output into a midi file though.
Euterpea has a function called "test" that writes a Music value to a MIDI file called "test.mid" in the working directory. However, to do this, Euterpea uses Codec.Midi from the HCodecs library to first create a Midi value and then write a .mid file. Unfortunately, Codec.Midi seems to have some bugs in the .mid file conversion, and, as a result, the .mid files are readable by some programs but not others. If you are on Windows, SynthFont (free) is usually able to open the files without problems.
-----Donya Quick
Wow ... it looks much better now!!!
Thank you so much for your feedback Professor Hudak.
I have not been able to figure out the way to dump the output into a midi file though.
Regards,
Kashyap
________________________________
Sent: Tuesday, March 5, 2013 11:04 AM
Subject: RE: [haskell-art] Review request
 
·         “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’ ”.
“takeM (2*n) (repeatM (gs 3 en))”
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 
 
Sent: Monday, March 04, 2013 7:18 AM
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
Loading...