6 ms·
Printing Music with CSS Grid
- deleted 3y ago[deleted]
- spankalee 3y agoThis is very cool! Like the author, I'm pretty impressed that just CSS can get you this far. I'm very excited to see the <scribe-music> custom element too! I had an intern work on wrapping VexFlow with web components a few years back, but the summer ended before everything was finished, and it hasn't been maintained: https://github.com/PolymerLabs/vexflow-elements/blob/web-components/demo/index.html https://github.com/PolymerLabs/vexflow-elements/blob/web-com... A maintained and easy-to-use library could do a lot of good for music notation on the web.
- sonovice 3y agoThere is https://www.verovio.org/ https://www.verovio.org/ which is both easy-to-use and really well maintained.
- ivanjermakov 3y agoThis feels like a CSS benchmark haha
- thrtythreeforty 3y agoI started the article thinking "ohhh the horror, this will not go well." And I ended up being mildly impressed with the typesetting quality, especially for the relative simplicity of the approach. So kudos to the author for demonstrating the flexibility of CSS. I am concerned that there are lots of edge cases, essentially ligatures for engraving, that might not compose so well. A triad, or the author's called-out relative head spacing of 8th and 16th notes, or letting the program align different parts across different grids - would this also work well? Lilypond has proven to be exceptionally flexible for these kinds of complexities.
- stephbd 3y agoIt would be nigh-on impossible to align parts across different grids – but it's perfectly possible to generate one huge grid with multiple staves in it. I'm pretty confident that will work out.
- dsmmcken 3y ago> align parts across different grids Maybe a CSS `subgrid` would help? Subgrid is newly available. (I know nothing about music notation, and basing this entirely off that statement).
- rcarmo 3y agoPretty awesome!
- ramijames 3y agoI'm super impressed.
- MilStdJunkie 3y agoNice to have an alternative to Lilypond (lilypond.org), but given the extreme complexity of notation, I would bet that any brevity gains are short lived. For those Asciidoc freaks among you, Lilypond is fairly easy to get running in your Asciidoc toolchain of choice. I use the DocBook PDF pipeline, and the lilypond output is quite nice looking. It's awfully TeX-like.
- atonse 3y agoBut does Lilypond generate responsive sheets? That to me was the coolest part of this (apart from what others have said, the power of modern CSS)
- Tokkemon 3y agoThey can be rendered at any size.
- lukan 3y agoA PDF is still not that responsive. Clean HTML/CSS is.
- dheera 3y agoYou don't have to render to PDF, you can just have some UI that keeps re-rendering Lilypond source to your screen size and zoom level every time you zoom. Or render each measure to a separate .png file and just <img> for each measure. It will wrap and re-flow, you just have to deal with the clefs separately.
- lukan 3y ago"you can just have some UI that keeps re-rendering Lilypond source to your screen size and zoom level every time you zoom." And have you done that or seen it responsive?
- 3y ago
- vintagedave 3y agoThis is extraordinary. While JavaScript is needed now, I’d encourage the author to see what needs to be added to CSS to allow a CSS-only solution, and promote it in the CSS community. For example, repeating the clef when wrapping is akin to a sticky table header, and would have more applications than only music. Some CSS notation is wholly new to me: > .stave > [data-pitch^="A"][data-pitch$="5"] { grid-row-start: A5; } I’ve never seen CSS selectors with square brackets before. Apparently it’s an attribute selector: https://css-tricks.com/attribute-selectors/ https://css-tricks.com/attribute-selectors/
- firexcy 3y ago> CSS selectors with square brackets They are also extremely useful when it comes to adblocking. Without their partial matching capabilities it'd have been almost impossible to target ad-containing elements in most of these days' js and framework-ladden websites.
- wizzwizz4 3y agoI'd suggest a ::line pseudoelement for that. We already have ::first-line, which could perhaps be considered an abbreviated ::line:first-of-type. Though, ::first-line doesn't seem to support enough properties to be useful here, so maybe another approach is needed.
- stephbd 3y agoMy only thought on this was to have a strip down the side with a vertically repeating background of an SVG data URL with the clef in it. But I don't like it. It'll be brittle. And it wouldn't support clef / key / time changes very easily.
- mananaysiempre 3y agoI don’t know that this could be done cleanly without intertwining stlying and line breaking, which quite honestly sounds like a nightmare. (Line breaking is enough of a horror show as is, what with ligatures and bidi and ...)
- mewpmewp2 3y ago
- coldtea 3y agoLooks good, and with surprisingly clean CSS.
- Tokkemon 3y agoIt's a nifty solution. But speaking as a music engraver, it could use a lot of improvement, and I don't think there's enough tolerance in CSS to make it work. The beams, slurs, and ties, in particular have real problems visually. This is why other methods of getting notation into the browser don't use such tools. You need pinpoint precision for vector rendering, which is why almost all browser notation is done with SVG or some sort of Canvas drawing. Other than the clever solution of using CSS, why would you do this? One can already do scalable notation in the browser with other tools (Check out Adrian Holovaty's Soundslice or Sibelius Cloud Publishing).
- scop 3y agoWhat is a music engraver? I could google it, but I would appreciate a music engraver actually telling me vs some random page on the internet.
- itishappy 3y agosomeone who makes music look pretty https://en.wikipedia.org/wiki/Music_engraving https://en.wikipedia.org/wiki/Music_engraving
- Tokkemon 3y agoSure. It's an old-fashioned term for the artisans who engraved music notation onto metal plates. These were then inked for pressing. It's a highly specialized skill and requires a deep knowledge of now notation works and how musicians will respond to it. Today it is all done on computer but the artistry of knowing how the notation should look and the meaning behind it is still there. That's the basics but the work we do is quite varied and complicated. It happens that I work for Avid as a designer for Sibelius, the leading music notation program in the world. I also run the Music Engraving Tips Facebook group if you're interested in learning more.
- analog31 3y agoAs a player (jazz bassist) I'm amazed by the subtlety of making notation work. Oddly enough, most of my band's material is still not in computer readable form. A lot of it was hand copied.
- nixpulvis 3y agoJust going to remind people of https://www.musicxml.com https://www.musicxml.com and https://opensheetmusicdisplay.org https://opensheetmusicdisplay.org for a more complete solution at a much larger cost.
- rocken7 3y agoimagine a bot drone that flies around a big city like NY, and just tags walls + suitable spots with interesting gen art from various sources .. likely a lawsuit in the making but cool to see.
- consf 3y ago[dead]
- sfink 3y agoThis feels so wrong in one way, and simultaneously so right in another.
- xhevahir 3y agoThis looks really nice. I'd like to see if this could replace the janky notation functionality in Impro-Visor ( https://github.com/Impro-Visor/Impro-Visor https://github.com/Impro-Visor/Impro-Visor ).
- rdevsrex 3y agoThis is pretty cool!
- alnvdl 3y agoCSS grids are quite interesting. I once implemented a furniture designer with it (pure frontend JS, no backend): https://alnvdl.github.io/2023/01/07/designing-furniture-using-the-css-grid.html https://alnvdl.github.io/2023/01/07/designing-furniture-usin...
- bredren 3y agoHey, that's a great lightweight tool. Thanks for sharing that.
- russelg 3y agoAwesome post! I can see myself using your planner for sure.
- knighthack 3y agoThis was an interesting (and unexpectedly) practical use of CSS for non web-dev purposes. Great idea!
- ulrischa 3y agoIncreadible what css can do today. It is some kind of general purpose representation language
- adrianh 3y agoImpressive hack — kudos from a fellow sheet music software developer! I've spent more than 10 years now building Soundslice, which does web-based sheet music rendering. I believe we were the first to do "responsive" web notation (that part of the site launched in 2014). Here's a tech talk I gave with a lot of details: https://www.youtube.com/watch?v=XH5EtQge_Bg https://www.youtube.com/watch?v=XH5EtQge_Bg Here's an example of responsive Soundslice notation: https://www.soundslice.com/slices/zzNlc/ https://www.soundslice.com/slices/zzNlc/ (in the settings, set the stave width to maximum to get "Fit to screen" for the true responsive effect) We've got a whole suite of tools built around this, including an excellent web-based editor, rich practice functionality and a relatively new scanning feature (extracting the musical data from a photo or PDF). I agree with other commenters here that this CSS Grid approach could be handy for lightweight projects but it likely isn't up to snuff for the incredibly subtle and complex world of full scores. With that said, I just want to stress again that this is super cool and I'm glad it exists!
- RobKohr 3y agoThanks for promoting your software here. This is one of the reasons I come to hacker news comments - finding great projects related to the thing you were just looking at. I am currently learning some music on the violin, and this looks like something that will help me out.
- heroprotagonist 3y agoCould you perhaps elaborate about what makes it 'not up to snuff', given how much you used it as a chance to promote your own stuff?
- asddubs 3y agoMaybe the segment on engraving of Tantacruls Musescore 4 video is a good explanation of some of the things involved: https://youtu.be/Qct6LKbneKQ?t=2005 https://youtu.be/Qct6LKbneKQ?t=2005 the whole video is worth watching as well (and there are several videos on the channel focusing on the UI of notation apps, worth watching for anyone who does UI but isn't interested in music production as well)
- elijahbenizzy 3y agoThis is great!
- darepublic 3y agobeautiful music notation. The main page of the site also has a tasteful use of position sticky!
- emadda 3y agoCool, I often use grid for precise placement of items even for small widgets like toggle buttons. If you’d like an intro into grid: https://cssprinciples.com/3/grid/ https://cssprinciples.com/3/grid/
- microtherion 3y agoThe visual quality is really good. I'm not entirely convinced of making this responsive, in the particular area of Jazz leadsheets. I've found myself preferring line breaks at regular intervals (mostly every 4 bars, with exceptions for pickups and alternate endings), rather than trying to cram as many bars as possible onto each line.
- stephbd 3y agoThe beauty of the system is that a flex box rule of flex: 1 1 25%; will give you 4 bars per line (each averaging 25% of the width). The system is flexible.
- shermantanktop 3y agoHear hear. Most pop/jazz/rock music is generally built off powers of 2 at multiple levels.
- toastal 3y agoThis is a really clever use of grid & a case where the named templates is actually well done instead of overused.
- donatj 3y agoI have spent weeks recently working on a little side project converting MIDIs to colored children’s piano sheet music. I am most of the way there but have been dragging my feet on building the web ui specifically because I was unsure how to render the notes in a flexible way that could look good on multiple devices. This looks like it could be a good jumping off point, and I fully intend to give it a try. My daughter absolutely loves my Little Tikes piano from the 1980s but all the sheet music I find online, even for the newer Little Tikes pianos, have different colors associated with notes. I have built up a small library of simple MIDIs, and my intent is to have some preset toy pianos to choose from or let the end user specify colors-to-notes manually.
- hantusk 3y agoFor a shortcut, Musescore has a plugin called colornotes that does this, installable from the GUI. You can alter the color scheme by editing the .js plugin code: https://github.com/musescore/MuseScore/blob/master/share/extensions/colornotes/main.js https://github.com/musescore/MuseScore/blob/master/share/ext... It can also print note names inside of each head.
- consf 3y ago[dead]
- todotask 3y agoI utilized JavaScript to render music notation from pppp to ffff iirc that can connect to a MIDI keyboard, allowing users to practice along with the interactive notes. Initially, I experimented with Adobe Flex before transitioning to web-based solutions and yes, it can read and play any MIDI files to my SF2 soundfont. The only problem is that MuseScore community took years to fix a missing measurement in MusicXML structure, I had to patch the code on my own.
- naltroc 3y agowoah, amazing work! The interactive (transposable) at the very end should be top of the fold imo. Super impressive.
- consf 3y ago[dead]
- ssttoo 3y agoNice! I run a website with music theory exercises where the notation is pretty simple. I’d love to switch to something like this, because the vexflow (what I use now) API is a little much of a re-learning curve for my twice-a-year-let’s-add-a-new-exercise cadence