Draw a music staff in C#

JeffJak picture JeffJak · Oct 29, 2010 · Viewed 11k times · Source

I am looking to draw a music staff on a .NET (C#) form. I am using Microsoft Visual C# 2010 Express. I was wondering if anyone knew of existing code or existing free .NET libraries that can help with that. I am looking at drawing both the treble and bass clef staff and adding one quarter note to some where in the staff. I am making a Piano Tester app using C# for my son. If I code it myself, I will proably just override the onPaint method. But I thought I would see if anyone has seen some free code or library available to get me started.

Answer

bgporter picture bgporter · Oct 29, 2010

There are the required primitives to generate musical output in the Unicode code set (starting at U+1D100). For example, U+1D11A is a 5-line staff, U+1D158 is a closed notehead.

See http://www.unicode.org/charts/PDF/U1D100.pdf

..then the issue becomes making sure that you have a typeface with the appropriate glyphs included (and dealing with the issues of spacing things correctly, etc.)

IF you're looking to generate printed output, you should look at Lilypond, which is an OSS music notation package that uses a text file format to define the musical content and then generates gorgeous output.