Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nitzanrh opened this issue Mar 31, 2022 · 6 comments
Open

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

nitzanrh opened this issue Mar 31, 2022 · 6 comments

Comments

@nitzanrh
Copy link

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

@sschmidTU
Copy link
Contributor

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.

@nitzanrh
Copy link
Author

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

@rvilarl
Copy link
Collaborator

rvilarl commented Apr 1, 2022

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

@nitzanrh
Copy link
Author

nitzanrh commented Apr 1, 2022

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

@rvilarl
Copy link
Collaborator

rvilarl commented Jun 25, 2022

@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)

@nitzanrh
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants