Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 08:40
    rvilarl commented #1105
  • 06:52
    rvilarl synchronize #1094
  • 06:46
    rvilarl synchronize #1094
  • 06:12
    rvilarl synchronize #1105
  • Dec 03 23:20
    sschmidTU commented #1105
  • Dec 03 22:45
    rvilarl commented #1105
  • Dec 03 22:37
    rvilarl synchronize #1105
  • Dec 02 17:50

    sschmidTU on develop

    comment (compare)

  • Dec 02 17:08

    sschmidTU on develop

    fix(GroupBrackets): Don't draw … (compare)

  • Dec 02 13:32
    kenboy2304 commented #1106
  • Dec 02 12:46
    sschmidTU commented #1106
  • Dec 02 12:45
    sschmidTU closed #1106
  • Dec 02 12:45
    sschmidTU commented #1106
  • Dec 02 12:44

    sschmidTU on develop

    feat(ChordSymbols): add Engravi… (compare)

  • Dec 02 12:28
    sschmidTU commented #1062
  • Dec 02 12:13
    sschmidTU commented #1062
  • Dec 02 12:06

    sschmidTU on develop

    fix(Positioning): Fix ghost not… (compare)

  • Dec 02 12:03
    sschmidTU closed #1022
  • Dec 02 12:03
    sschmidTU commented #1022
  • Dec 01 16:47
    kenboy2304 commented #1106
anseldu
@anseldu
@sschmidTU my duscord user name is anseldu,tks
Simon
@sschmidTU
@vivachenx Yes, I just added the method osmd.PlaybackManager.playFromMs(), please pull the latest version from the extended repo. I also fixed the bug where it would play notes that started before the current cursor position after you set a new position and hit play.
vivachenx
@vivachenx
@sschmidTU Thank you for your work, this is a very useful api ! Helped me solve a big problem
Luc Bonnin
@lucbonnin
Hi,
I'm using the github "explore the demo" example to parse all osmd notes using cursor.Iterator and moving note by note to fill another js array on my side.
As I'm on a given "iterator" position, I want to grab the equivalent SVGElement but I'm not able to do it so far (I guess because I'm using fixed 0 for staffEntries).
osmd.graphic.measureList[iterator.CurrentMeasureIndex][0].staffEntries[0].graphicalVoiceEntries[i].notes[j].getSVGGElement();
Is there an easy way from "iterator" or cursor instance to get the current SVGElement ? (or maybe the currentStaffEntries if it is the point missing). @sschmidTU any cue ?
Simon
@sschmidTU

@lucbonnin Hi, first of all, you can use iterator.CurrentVoiceEntries directly:
const currentTopNote = osmd.cursor.Iterator.currentVoiceEntries[0].notes[0];
To get a GraphicalNote from Note:
const gNote = osmd.rules.GNote(currentTopNote);
gnote.getSVGGElement()

It's even easier if you're using a cursor and not just an iterator:
osmd.cursor.GNotesUnderCursor()[0].getSVGGElement()

1 reply

@sschmidTU Thank you for your work, this is a very useful api ! Helped me solve a big problem

thank you very much, glad to hear! :)

1 reply
Luc Bonnin
@lucbonnin

Other questions. 2 easy one I guess :
1- spacingBetweenTextLines seems to not adding spaces between 2 lines of notes. (I'm using it as osmd.setOption() before rendering. (and after this setOptions I'm using a osmd.zoom = 1.2 (not sure if it is perturbing something here)

2- I've tried to use the transpose calculator from the demo sample but it seems to not work at all on my local :( Seems to not transpose anything. + while parsing the data using osmd.cursor, I got the same "pitch.toString()" displayed. Maybe I'm using the wrong data or missing something

Simon
@sschmidTU
  1. SpacingBetweenTextLines is for (text) labels like lyrics. If they are multi-line, this spacing will be used. What you're looking for is probably osmd.EngravingRules.MinimumDistanceBetweenSystems. A system in a music sheet is what you would usually call a line, and a "line break" is more properly called a system break (new-system in MusicXML)
_2. works in our local demo, you probably haven't imported or set up the TransposeCalculator correctly.
4 replies
image.png
Simon
@sschmidTU
Also for 1., if you're looking for spacing within a system, there's also BetweenStaffDistance and MinimumStaffLineDistance in EngravingRules.
Luc Bonnin
@lucbonnin
again 1000 thanks !
I'll probably have couple of dum questions later ;)
Simon
@sschmidTU
you're welcome! Haha, no problem, there are no stupid questions with OSMD.
Luc Bonnin
@lucbonnin
image.png
@sschmidTU as promess, another dum question :)
Is it possible to force (maybe via EngravingRules) the minimum width of a vf-stavenote ?
(min-width or width if min-width is not possible).
My main issue is with "attached notes" not single isolated one
Simon
@sschmidTU
I don't think that's possible, because Vexflow does the x-layout of notes (once, in the formatter function), and there's not much you can do to influence that. You can increase VoiceSpacingMultiplierVexflow or VoiceSpacingAddendVexflow in EngravingRules though to increase spacing in general.
3 replies
Luc Bonnin
@lucbonnin
it seems to be the relevant params. I'll play around with it a bit.
Luc Bonnin
@lucbonnin
@sschmidTU is there an easy way to get the real "height" (in px) of the staff line (for a current cursor note. Note the note height that could vary but the staff line that has to be the same all over the sheet svg ?
Simon
@sschmidTU
@lucbonnin Yes, one way is to get the bounding box of the GraphicalNote's SVG element.
Try this code in the public OSMD demo:
for (let i=0; i<osmd.graphic.measureList.length; i++) {
    const bbox = osmd.graphic.measureList[i][0].staffEntries[0].graphicalVoiceEntries[0].notes[0].getSVGGElement().getBBox();
    console.log(`pos: (${bbox.x}, ${bbox.y})`);
    osmd.drawer.DrawOverlayLine({x: bbox.x / 10, y: bbox.y / 10}, {x: bbox.x / 10 + 2, y: bbox.y / 10}, osmd.graphic.MusicPages[0])
}
image.png
This only works with the SVG backend of course, for Canvas you'd need to catch the values from the SkyBottomLineCalculator instead.
This is a nice showcase for Exploring the Demo, i'll add it to our Wiki :)
2 replies
Simon
@sschmidTU
by the way, most of these draw methods like DrawOverlayLine return the SVG element they were drawing, so you can save it and remove it again later, to undo the drawing:
osmd.drawer.backend.removeNode(mySvgNode)
Simon
@sschmidTU
here's the test sample: note_height_skyline_test_sample.zip
Luc Bonnin
@lucbonnin
thanks. For other people that may be interested to grab svgElem from cursor (info grabbed from a previous Simon answer) :
svgElem = osmd.cursor.GNotesUnderCursor()[0].getSVGGElement();
svgElemStaffLineHeight = svgElem.getBBox().y;
Luc Bonnin
@lucbonnin
small detail : GNotesUnderCursor() can be used when cursor is on a note. What if it is on a "silence" item ? GNotesUnderCursor() return null in this case. Is there another method to catch the SVGElement() for a "silence" ? @sschmidTU
Simon
@sschmidTU
it shouldn't return null, it should return a GraphicalNote as well. Rests are also GraphicalNotes.
Luc Bonnin
@lucbonnin
image.png
it seems to return null for this kind of graphical element :(
Simon
@sschmidTU
Oh, that's a multi-rest-measure, that's different.
Luc Bonnin
@lucbonnin
I guess it is the only exception for "graphical element" that are mapped to a duration (notes,silence, multi-rest-measure"
Simon
@sschmidTU
there is only one graphical measure for a multi-rest measure, the other graphical measures that are included in the multi-rest are undefined.
Luc Bonnin
@lucbonnin
this multi-rest-measure is parsed using cursor and iterator
but I can't get the svgElement related to it (I suppose an SVG rect)

I'm using the exploring the demo sample code to parse notes with
const iterator = osmd.cursor.Iterator;
while(!iterator.EndReached){

        const voices = iterator.CurrentVoiceEntries; // all voices of current item (1voice = 1 instrument or 1hand if piano)
        // for each voice of current cursor item
        for(var i = 0; i < voices.length; i++){
            const v = voices[i];
            const notes = v.Notes;

            // For each note of current voice item (in case of chord)
            for(var j = 0; j < notes.length; j++){
                    const note = notes[j];
                     if(note!=null && note.isRestFlag==true) {

svgElem = osmd.cursor.GNotesUnderCursor()[0].getSVGGElement(); (here I've null :(. )

Luc Bonnin
@lucbonnin
in short, I've bypassed this issue :
osmd.EngravingRules.RenderMultipleRestMeasures = false;
In my biz case I needed to grab for each note the SVGElement "id" to then parse the DOM. In the case of multi-rest-measure I do not have "id" on the svg part (nor "g" element). I dunno why but maybe it could be great to have it for this type of element ?
Simon
@sschmidTU
There is no note in a multi-rest measure, i suppose that's why you get null.
what do you want to do with a multi-rest measure?
what exactly do you want to get the svg element of in a multi-rest measure?
Simon
@sschmidTU
i don't think we can give any SVG there, because we can't give the SVG of an entire measure.
I improved the method above by the way to get the highest (or lowest) y position around a note. It just needs an OSMD update, or you'd have to re-implement the methods I just added.
Simon
@sschmidTU
Here's the code for the new method in the wiki:
https://github.com/opensheetmusicdisplay/opensheetmusicdisplay/wiki/Exploring-the-Demo#drawing-overlay-lines-over-the-score-and-getting-a-notes-position
(look for the "more sophisticated" version below the horizontal line)
image
Simon
@sschmidTU
Maybe I'll get a 1.3.1 release out tomorrow so you can use the sophisticated new functions ;)
Luc Bonnin
@lucbonnin
cool
Ansel Du
@anseldu_gitlab
@sschmidTU In the past, you could use gnote to get .getsvggelement(), but now you can't find it. What's going on?
let gNote = this.osmd.rules.GNote(note)
let el = gNote.getSVGGElement()
Simon
@sschmidTU
@anseldu_gitlab nothing changed, probably an error on your side.
Ansel Du
@anseldu_gitlab
@sschmidTU yes I fixed it. \r\n let gNote: VexFlowGraphicalNote = this.rules.GNote(note) as VexFlowGraphicalNote;
let el: SVGGElement = gNote.getSVGGElement();