vexflow icon indicating copy to clipboard operation
vexflow copied to clipboard

How to set repeat at beginning of bar w/o stave's start/left barline

Open nitzanrh opened this issue 2 years ago • 6 comments

I'm trying to achieve the following: https://en.wikipedia.org/wiki/Repetition_(music)#/media/File:Au_clair_de_la_lune_repetition.png

ie have a left/start repeat sign but without having the stave's left/begin barline. Is this possible?

When i set the stave's begin barline to repeat (stave.setBegBarType(4)) it automatically adds a barline in the beginning of the stave (ie left side).

Cheers, Nitzan

nitzanrh avatar Mar 31 '22 11:03 nitzanrh

ie have a left/start repeat sign but without having the stave's left/begin barline

I don't see that in the image you linked. But I guess what you wrote is what you want to achieve.

sschmidTU avatar Mar 31 '22 15:03 sschmidTU

Sorry, here is a decent screenshot :) Screen Shot 2022-03-31 at 18 11 53

nitzanrh avatar Mar 31 '22 15:03 nitzanrh

@nitzanrh could you provide the code and a screenshot of what you are actually getting?

rvilarl avatar Apr 01 '22 08:04 rvilarl

Yup, here is a jsfiddle: https://jsfiddle.net/j5asuce8/

code:

VF = Vex.Flow;

// Create an SVG renderer and attach it to the DIV element named "boo".
var div = document.getElementById("boo")
var renderer = new VF.Renderer(div, VF.Renderer.Backends.SVG);

// Configure the rendering context.
renderer.resize(500, 500);
var context = renderer.getContext();
context.setFont("Arial", 10, "").setBackgroundFillStyle("#eed");

// Create a stave of width 400 at position 10, 40 on the canvas.
var stave = new VF.Stave(10, 40, 400);
stave.setBegBarType(4)

// Add a clef and time signature.
stave.addClef("treble").addTimeSignature("4/4");

// Connect it to the rendering context and draw!
stave.setContext(context).draw();

SS: Screen Shot 2022-04-01 at 11 23 54

nitzanrh avatar Apr 01 '22 08:04 nitzanrh

@nitzanrh I have been reviewing issues and I realised that I missed this one. Thaks for the jsfiddle! It helped a lot. The behaviour is hard coded:

      case BarlineType.REPEAT_BEGIN:
        // If the barline is shifted over (in front of clef/time/key)
        // Draw vertical bar at the beginning.
        this.drawRepeatBar(stave, this.x, true);
        if (stave.getX() !== this.x) {
          this.drawVerticalBar(stave, stave.getX());
        }
        break;

I could add a REPEAT_BEGIN_NONE removing the bar at the beginning:

      case BarlineType.REPEAT_BEGIN_NONE:
        this.drawRepeatBar(stave, this.x, true);
        break;

would that help? Please note that you would still get the repeat bar after the time signature and not before (as shown in the example you provide)

rvilarl avatar Jun 25 '22 07:06 rvilarl

Hi @rvilarl, thanks for your reply :) Yeah I believe that would help. Personally I find the name REPEAT_BEGIN_NONE slightly confusing, but as long as the documentation is clear then that shouldn't be a problem.

Regarding the time signature; personally I wouldn't cause any problems with my usage for Vexflow, however I think that if you follow the strict "rules" of music notation then the barlines should appear before the time signature.

Cheers, Nitzan

nitzanrh avatar Jun 27 '22 10:06 nitzanrh