Code Monkey home page Code Monkey logo

Comments (4)

otsob avatar otsob commented on August 29, 2024

Unfortunately there are no examples yet, they would definitely be useful so I will aim to create some at some point. Wmn4j is mainly intended for handling the content of music notation, e.g., for analysis, so there is no rendering and probably will not be in the near future. The idea is that with being able to output MusicXML, the rendering could be taken care of by any SW able to render notation from MusicXML.

from wmn4j.

Erhannis avatar Erhannis commented on August 29, 2024

Ah, ok; thank you. Would you happen to know any good MusicXML renderers?

Also, I made some test code; lemme know if I'm doing something wrong, and if not, feel free to copy it into an example file or the README or whatever, if you want.

ScoreBuilder sb = new ScoreBuilder();
sb.addPart(new PartBuilder("melody")
        .add(new MeasureBuilder()
                .setClef(Clef.of(Symbol.G, 2)) // I don't know which line this is supposed to center on
                .setTimeSignature(TimeSignature.of(4, 4))
                .addToVoice(0, new RestBuilder(Duration.of(1, 4)))
                .addToVoice(0, new NoteBuilder(Pitch.of(Pitch.Base.C, Pitch.Accidental.NATURAL, 4), Duration.of(1, 4)))
                .addToVoice(0, new ChordBuilder(Arrays.asList(
                        new NoteBuilder(Pitch.of(Pitch.Base.C, Pitch.Accidental.NATURAL, 4), Duration.of(1, 2)),
                        new NoteBuilder(Pitch.of(Pitch.Base.E, Pitch.Accidental.NATURAL, 4), Duration.of(1, 2)),
                        new NoteBuilder(Pitch.of(Pitch.Base.G, Pitch.Accidental.NATURAL, 4), Duration.of(1, 2))
                )))
        )
);
Score score = sb.build();
try {
    MusicXmlWriter.writerFor(score, new File("example.xml").toPath()).write();
} catch (IOException ex) {
    Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
}

from wmn4j.

otsob avatar otsob commented on August 29, 2024

I think you can render MusicXML with MuseScore and LilyPond. The code snippet looks right, except the G-clef line would typically be 2 when counting from bottom line upwards.

from wmn4j.

Erhannis avatar Erhannis commented on August 29, 2024

Ok, thanks. And ah - I've figured out that should be "xml" rather than "mxl", or few things will read it. Also I got the note durations wrong. I've edited both things (and the clef) in my previous comment.

from wmn4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.