Sheet Music (brilliant_composer.cfdg)

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
User avatar
chris
Site Admin
Posts: 72
Joined: Wed May 04, 2005 10:57 am
Location: New York, NY
Contact:

Sheet Music (brilliant_composer.cfdg)

Post by chris »

This one generates two pages of sheet music. I made it looks as hand-drawn as possible with some randomization that you can cancel out if you like.

I actually didn't know how to read sheet music, so I had to look up the symbols for notes. I think it's "correct", but who knows.

cc

Image


Code: Select all

startshape song_book

rule song_book {
 song_page { }
 song_page {x 90}
}

rule song_page {
  song_line { }
  song_line {y -15}
  song_line {y -30}
  song_line {y -45}
  song_line {y -60}
  song_line {y -75}
}

rule song_line {
 measure_with_bars { }
 measure_with_bars {x 20}
 measure_with_bars {x 40 }
 measure_with_bars {x 60}
 thin_line {r 90 s 0.25 y -1.95 x 79}
}

rule measure_with_bars {
   measure { x 2 }
   measure_5_lines {s 0.5}
   measure_5_lines {s 0.5 x 2}
   measure_5_lines {s 0.5 x 4}
   thin_line {r 90 s 0.25 y -1.95 x 0}
   thin_line {r 90 s 0.25 y -1.95 x 20}
}

rule measure {
 halfmeasure { }
 halfmeasure {x 8}
}

rule measure {
 quartermeasure { }
 halfmeasure {x 4}
 quartermeasure {x 12 }
}

rule halfmeasure {
 r_halfnote { }
}

rule halfmeasure {
 quartermeasure { }
 quartermeasure {x 4}
}

rule quartermeasure {
 r_quarternote { }
}

rule quartermeasure {
 eighthmeasure { }
 eighthmeasure {x 2}
}

rule eighthmeasure {
  r_eighthnote { }
}

rule eighthmeasure {
  sixteenthmeasure { }
  sixteenthmeasure {x 1 }
}

rule sixteenthmeasure {
  r_sixteenthnote { }
}

rule r_halfnote 0.2 { halfnote { } }
rule r_halfnote { r_halfnote {y 0.5} }
rule r_halfnote { r_halfnote {y -0.5} }

rule r_quarternote 0.2 { quarternote { } }
rule r_quarternote { r_quarternote {y 0.5} }
rule r_quarternote { r_quarternote {y -0.5} }

rule r_eighthnote 0.2 { eighthnote { } }
rule r_eighthnote { r_eighthnote {y 0.5} }
rule r_eighthnote { r_eighthnote {y -0.5} }

rule r_sixteenthnote 0.2 { sixteenthnote { } }
rule r_sixteenthnote { r_sixteenthnote {y 0.5} }
rule r_sixteenthnote { r_sixteenthnote {y -0.5} }

rule halfnote {
 CIRCLE { }
 CIRCLE {b 1.0 s 0.5}
 vertbar {s 0.2 x 0.392 y 0.1}
}

rule quarternote {
 CIRCLE { }
 vertbar {s 0.2 x 0.392 y 0.1}
}

rule eighthnote {
 CIRCLE { }
 vertbar {s 0.2 x 0.392 y 0.1}
 twisty {y 2.1 r -20 s 0.2 x 0.375}
}

rule sixteenthnote {
 CIRCLE { }
 vertbar {s 0.2 x 0.392 y 0.1}
 twisty {y 2.1 r -20 s 0.2 x 0.375}
 twisty {y 1.6 r -20 s 0.2 x 0.375}
}

rule vertbar {
 SQUARE { }
 SQUARE {y 1}
 SQUARE {y 2}
 SQUARE {y 3}
 SQUARE {y 4 }
 SQUARE {y 5}
 SQUARE {y 6}
 SQUARE {y 7}
 SQUARE {y 8}
 SQUARE {y 9}
 SQUARE {y 10}
}

rule twisty {
 quartercircle {x 2 r 180}
 quartercircle {x 2.5 y -4}
}

rule quartercircle {
  parm1 {r 0}
  parm1 {r 10}
  parm1 {r 20}
  parm1 {r 30}
  parm1 {r 40}
  parm1 {r 50}
  parm1 {r 60}
  parm1 {r 70}
  parm1 {r 80}
  parm1 {r 90}
}

rule parm1 {
  arm1 {r 0}
  arm1 {r 1}
  arm1 {r 2}
  arm1 {r 3}
  arm1 {r 4}
  arm1 {r 5}
  arm1 {r 6}
  arm1 {r 7}
  arm1 {r 8}
  arm1 {r 9}
}

rule arm1 {
   CIRCLE {x 2}
}

rule measure_line {
 thin_line {s 0.25}
 thin_line {s 0.25 x 4}
 thin_line {s 0.25 x 8}
 thin_line {s 0.25 x 12}
 thin_line {s 0.25 x 16}
 thin_line {s 0.25 x 20}
 thin_line {s 0.25 x 24}
 thin_line {s 0.25 x 28}
}

rule thin_line {
 SQUARE { }
 SQUARE {x 1 }
 SQUARE {x 2 }
 SQUARE {x 3  }
 SQUARE {x 4 }
 SQUARE {x 5 }
 SQUARE {x 6 }
 SQUARE {x 7 }
 SQUARE {x 8 }
 SQUARE {x 9 }
 SQUARE {x 10}
 SQUARE {x 11}
 SQUARE {x 12}
 SQUARE {x 13}
 SQUARE {x 14}
 SQUARE {x 15}
}

rule measure_5_lines {
  measure_line { }
  measure_line {y 2}
  measure_line {y 4}
  measure_line {y -2}
  measure_line {y -4}
}

/****** LINES TO RANDOMIZE ***************/
/* COMMENT TO STRAIGHTEN */

rule measure 50 { measure {r 0.1} }
rule measure 50 { measure {r -0.1} }
rule song_line 50 {song_line {r 0.1 }}
rule song_line 50 {song_line {r -0.1 }}
rule thin_line 10 { thin_line {r -0.4 } }
rule thin_line 10 { thin_line {r 0.4 } }
rule quarter_note 10 { quarter_note {b 0.3 } }
rule quarter_note 10 { quarter_note {b -0.3 } } /* */
[/img]
Last edited by chris on Thu Jul 07, 2005 5:01 pm, edited 1 time in total.
Current Project: I'm creative director of OKCUPID at http://www.okcupid.com

User avatar
LaT3x
Posts: 68
Joined: Wed Jul 06, 2005 3:11 pm
Location: Madrid, Spain

Post by LaT3x »

wwwwoooooooowww :shock:

User avatar
aaronstj
Posts: 66
Joined: Wed Jul 06, 2005 11:34 am
Location: Seattle

Re: Sheet Music (brilliant_composer.cfdg)

Post by aaronstj »

chris wrote: I actually didn't know how to read sheet music, so I had to look up the symbols for notes. I think it's "correct", but who knows.
Heh. Looks good to me. :)

jldugger
Posts: 1
Joined: Thu Jul 07, 2005 5:23 pm
Contact:

Post by jldugger »

It looks okay, but if you've studied music for a bit, it's very rudimentary. And if you've studied computer science for a bit, you'd probably eventually realize that sheet music is actually a contextual language, when you draw it out. I forget the term, I think it's called engraving or something similar, but basically eighth notes or faster get grouped together, and there's very little solid rules for when the stems go up or down. I recall reading more about this in a developer interview for a OSS sheet music renderer. Basically the challenge is difficult, to reproduce something difficult for musicians to distinguish from regular hand created pieces. And that has very little to do with the music itself!

Great job, I just disoovered this today and I hope that inspiration hits me soon. :wink:

romulusnr
Posts: 13
Joined: Wed Jul 06, 2005 2:50 pm
Location: Seattle

Post by romulusnr »

someone play it! :) j/k

t3knomanser
Posts: 21
Joined: Wed Jul 06, 2005 4:53 pm

Post by t3knomanser »

The notes that go way above or below the staff would need ledger lines to technically be playable (a set of lines that extend the staff up or down so we can place how that note is pitched). If you tweak the code to trim it so that the notes don't leave the staff then it'd be all good.

Turtle
Posts: 1
Joined: Fri Jul 08, 2005 4:22 pm
Contact:

Post by Turtle »

Wow, that's really incredible.

One thing that you could do to make it more "correct" is make the stems of the notes point the right direction. I believe that the general rule is notes on the upper half of the ledger line have their stems pointing down, while the rest point up. Not sure if that applies to all music, but that's how I learned it.

Excellent work though.

Post Reply