Live data from Hacker News

The Music Suite

music-suite.github.io

31–39 of 39 posts

Re: The Music Suite

#31

Pretty nice. I hope future versions will allow some sort of embedded structures, eg for this segments let p1 = scat [c..c']^/4 p2 = delay (1/4) $ scat [c..c']^/4 p3 = delay (3/4) $ scat [c..c']^/4 in (accent . legato) (p1 p2 p3) I would have expected something like p2 = delay (1/4) $$ [p1] or somesuch (sorry about the notation, I've never used Haskell - my point is about the nesting). I would also love to see ways to…

I don’t know much about Haskell, but I looked up `let`’s documentation, and I think it already does support embedded structures like you ask for. You can just write `p2 = delay (1/4) $ p1` (and you can also leave out the `$` because `p1` is already atomic). I think the site’s example repeats the definition of `p1` just to make reading the example clearer, not because you are forced to code like that.

Some extra background on `$`, for the curious:

Function application in Haskell is expressed like so:

> f x

Where `f` is a function, and `x` is it's argument. Function application is left associative, so

> f x y

Is equivalent to

> (f x) y

In this case, `(f x)` yields a new function, to which `y` is then applied (see http://en.wikipedia.org/wiki/Currying).

The function `$` that you mention is just application:

> f $ x = f x

So, using `$` infix like so

> f $ x

Is equivalent to

> f x

And likewise

> delay (1/4) $ p1

is equivalent to

> (delay (1/4)) p1

with extra parenthesis to make associativity clear.

This begs the question: when is `$` ever a useful function? There are two cases that come to mind:

1) Precedence. `$` has the lowest precedence of any function, and can thus be used to omit otherwise necessary parens; this

> f (g x)

is equivalent to

> f $ g x

2) Use in higher order functions. Imagine you have a function `all` that takes a predicate function `f` and a list of values `xs` and returns `True` if `f x` returns `True` for all `x` in `xs`. So `all (> 3) [4,5,6]` returns `True`. But, imagine now that you have a list of predicates and one value: can you still make use of `all` in this case? Yes, you could do something like this:

> all (\f -> f 42) [even, (> 3), (But that's a little verbose. If we look at `(\f -> f 42)`, all it's doing is taking a function and immediately applying `42` to it - hey, that sounds like `$` if it was partially applied to `42`! Here's a simpler version of the previous expression:

> all ($ 42) [even, (> 3), (So that's pretty much all there is to `$` and why one may omit it in the original expression.

Re: The Music Suite

#33
post #25

A few tangentially-related things: If you're generally interested in this subject, a popular toolkit for computational musicology outside of Haskell is Music21, in Python: http://web.mit.edu/music21/ If you're interested in Haskell and music, you might like Renick Bell's "Conductive" for Haskell-driven live coding music performance: http://www.renickbell.net/doku.php?id=conductive (video: http://www.youtube.com/watch…

There's also Abjad: http://abjad.mbrsi.org/

Re: The Music Suite

#34
post #9
post #8

As a conservatory student and a long time user of LilyPond, it seems very impractical as a daily musical notation tool after a quick glance at the syntax. ie: octavesUp 4 c in The Music Suite vs. c'''' in LilyPond ie: Handling of staves and parts (as well as notes vertical to each other in multiple staves) as a horizontal stack in the code is very opposite of how music notation/engraver needs to think. In LilyPond (a…

c'''' is valid in The Music Suite as well. That said, I won't be switching from ABC for my day-to-day music writing. I see The Music Suite as being useful for, e.g., writing a fugue, where the music can be elegantly expressed programmatically.

Ooooo, I never knew about ABC! It looks really concise and easy to use. Does it scale well to big symphonic scores? (Or if you're not into that kind of a thing, at least bigger projects than one page melodies of single lines?)

Re: The Music Suite

#35
post #34
post #9

Earlier quoted context omitted.

c'''' is valid in The Music Suite as well. That said, I won't be switching from ABC for my day-to-day music writing. I see The Music Suite as being useful for, e.g., writing a fugue, where the music can be elegantly expressed programmatically.

Ooooo, I never knew about ABC! It looks really concise and easy to use. Does it scale well to big symphonic scores? (Or if you're not into that kind of a thing, at least bigger projects than one page melodies of single lines?)

It's a complete joy to use. I use abcm2ps, which adds a few extensions and is pretty powerful.

I mainly use it for single melody lines (albeit with complex ornamentation), but have done a few multi-part pieces. I can send you a sample when I'm not on my phone. The only downside is that it's hard to see the relationship between hhe parts--afaik you can't interleave them. But the actual typesetting works great.

It's definitely worth a try, especially if you have a technical background. (Oh! Another cool feature: it has its own version of cascading style sheets, which provides a really nice separation between content and piesentation.)

Re: The Music Suite

#36
post #34
post #9

Earlier quoted context omitted.

c'''' is valid in The Music Suite as well. That said, I won't be switching from ABC for my day-to-day music writing. I see The Music Suite as being useful for, e.g., writing a fugue, where the music can be elegantly expressed programmatically.

Ooooo, I never knew about ABC! It looks really concise and easy to use. Does it scale well to big symphonic scores? (Or if you're not into that kind of a thing, at least bigger projects than one page melodies of single lines?)

Here you go: https://gist.github.com/tsmacdonald/4175ff511ae99f862b61 for the source, and https://www.dropbox.com/s/aslypeyw5fdku4u/emperory_germany%2... for the PDF. It's still a work in progress, so the end is a bit off.

Re: The Music Suite

#38

Clojure fans should look at http://overtone.github.io/ for something similar. Of particular note is the file https://github.com/overtone/overtone/blob/master/src/overton... which is an absolute work of art.

Okay, so I'm totally new to clojure, but I'm trying to run pitch.clj that you linked. I installed leiningen and added overtone as a dependency. Then I cloned overtone to get pitch.clj. Now how in the world do I actually run the code in pitch.clj?

Re: The Music Suite

#39

Clojure fans should look at http://overtone.github.io/ for something similar. Of particular note is the file https://github.com/overtone/overtone/blob/master/src/overton... which is an absolute work of art.

Okay, so I'm totally new to clojure, but I'm trying to run pitch.clj that you linked. I installed leiningen and added overtone as a dependency. Then I cloned overtone to get pitch.clj. Now how in the world do I actually run the code in pitch.clj?

The parent poster didn't mean that you should just arbitrarily execute pitch.clj, but that it was a particularly elegant piece of code in terms of capturing pitch semantics with beautiful Clojure.
Post reply on HN