rism-digital / verovio

🎵 Music notation engraving library for MEI with MusicXML and Humdrum support and various toolkits (JavaScript, Python)
https://www.verovio.org
GNU Lesser General Public License v3.0
667 stars 183 forks source link

How to reduce the number of bars in each line of a score #3156

Closed Duanle closed 1 year ago

Duanle commented 1 year ago

Describe the problem With the same version and option, why do I get different results on Android and Mac. The music score rendered on the mac will reduce the number of bars in each line with the "pageWidth" parameter, but not on android. I have tried to modify many "option", which can't achieve the effect。I've tried many other versions, but none of them works。Are there any configuration options I don't know?

Expected behavior I expect the results of running on Android will be the same as those on the Mac

Input data xml/musicxml

*Verovio information

Environment information (as appropriate)

This is the screenshot on android Screenshot_20221209_044801

This is the music score rendered by mac CMD : verovio xxxxxxxx.musicxml -p 1 --page-width 1080 --page-height 1920 mac

Additional context

craigsapp commented 1 year ago

Normally this sort of thing is controlled by spacingLinear and spacingNonLinear options.

But this case is different since those parameters cannot produce the overlapping elements seen in the Android example by themselves.

It seems that the Android version is typesetting the music to something wider than pageWidth (probably the default value of 2100) and then compressing the width of the music to 1080 after the castoff process (which it should not be doing). One idea is that this is related to an uninitialized variable that is set to 0 in MacOS and left to a more random state in Android.

craigsapp commented 1 year ago

Also the cross-staff stems/beams are incorrect. This could be a result of the master branch version being too old and maybe try the develop version instead to see if there is a difference.

The stems and beams are aligning vertically in 3.13.0-dev-1629c71:

Screen Shot 2022-12-08 at 4 30 55 PM
Click to view MEI data for above example ```xml </titleStmt> <pubStmt /> </fileDesc> <encodingDesc> <appInfo> <application isodate="2022-12-08T16:30:58" version="3.13.0-dev-1629c71"> <name>Verovio</name> <p>Transcoded from Humdrum</p> </application> </appInfo> </encodingDesc> <workList> <work> <title /> </work> </workList> <extMeta> <frames xmlns="http://www.humdrum.org/ns/humxml"> <metaFrame n="8" token="!!!RDF**kern: < = below" xml:id="L9"> <frameInfo> <startTime float="2" /> <frameType>reference</frameType> <referenceKey>RDF**kern</referenceKey> <referenceValue>< = below</referenceValue> </frameInfo> </metaFrame> </frames> </extMeta> </meiHead> <music> <body> <mdiv xml:id="mwyteua"> <score xml:id="s15r0olt"> <scoreDef xml:id="sy5o51x"> <staffGrp xml:id="s9tjjiu" bar.thru="true" symbol="brace"> <staffDef xml:id="staffdef-L1F2" n="1" lines="5"> <clef xml:id="clef-L2F2" shape="G" line="2" /> </staffDef> <staffDef xml:id="staffdef-L1F1" n="2" lines="5"> <clef xml:id="clef-L2F1" shape="F" line="4" /> </staffDef> </staffGrp> </scoreDef> <section xml:id="section-L1F1"> <measure xml:id="measure-L1"> <staff xml:id="staff-L1F2" n="1"> <layer xml:id="layer-L1F2N1" n="1"> <beam xml:id="beam-L3F2-L6F2"> <note xml:id="note-L3F2" type="placed" dur="8" oct="5" pname="c" stem.dir="down" accid.ges="n" /> <note xml:id="note-L4F2" type="placed" dur="8" oct="4" pname="g" stem.dir="up" accid.ges="n" /> <note xml:id="note-L5F2" dur="8" staff="2" oct="3" pname="e" stem.dir="up" accid.ges="n" /> <note xml:id="note-L6F2" dur="8" staff="2" oct="2" pname="c" stem.dir="up" accid.ges="n" /> </beam> </layer> </staff> <staff xml:id="staff-L1F1" n="2"> <layer xml:id="layer-L1F1N1" n="1"> <space xml:id="space-L3F1" dur="2" /> </layer> </staff> </measure> </section> </score> </mdiv> </body> </music> </mei> ``` </details> <p>In your example they are not aligning properly (in both Android and MacOS):</p> <img width="45" alt="Screen Shot 2022-12-08 at 4 35 39 PM" src="https://user-images.githubusercontent.com/3487289/206595892-8d5c93fd-9cc2-4451-b832-4dcc2c2ba3bf.png"> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Duanle"><img src="https://avatars.githubusercontent.com/u/6520982?v=4" />Duanle</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <p>Thank you for your reply, About the problem of "steps/teams" I will update to the new version later.I have tried the "spacingLinear" and "spacingNonLinear" parameters just now, and they really have no effect. Is there any other good solution to the Android problem? Or will you fix it later? Because my application runs on a mobile device, I need this function because the screen is small. Thanks again</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/lpugin"><img src="https://avatars.githubusercontent.com/u/689412?v=4" />lpugin</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <p>Please send the file.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/rettinghaus"><img src="https://avatars.githubusercontent.com/u/7693447?v=4" />rettinghaus</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <p>I think the toolkit is not available in the Android binding?</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Duanle"><img src="https://avatars.githubusercontent.com/u/6520982?v=4" />Duanle</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <blockquote> <p>I think the toolkit is not available in the Android binding?</p> </blockquote> <p>Probably not,I can use it to output svg and midi this is my jni code</p> <pre><code> extern "C" JNIEXPORT jobjectArray JNICALL renderSvgFile(JNIEnv *env, jobject, jstring jResourcePath, jstring jInputFilePath, jstring jOptionJson) { const char *resourcePath = env->GetStringUTFChars(jResourcePath, NULL); const char *inputFilePath = env->GetStringUTFChars(jInputFilePath, NULL); const char *optionJson = env->GetStringUTFChars(jOptionJson, NULL); std::string fileSuffix; std::string fileName; std::string folderPath; getInputFileSuffix(inputFilePath, fileSuffix); getInputFileName(inputFilePath, fileName); getInputFolderPath(inputFilePath, folderPath); vrv::Toolkit toolkit(false); toolkit.SetResourcePath(resourcePath); toolkit.LoadFile(inputFilePath); toolkit.ResetOptions(); int count = toolkit.GetPageCount(); auto jArray = (jobjectArray) env->NewObjectArray( count, env->FindClass("java/lang/String"), env->NewStringUTF("")); toolkit.SetOptions(optionJson); for (int p = 1; p < count + 1; p++) { std::string cur_outfile = fileName; cur_outfile += vrv::StringFormat("_%03d", p); cur_outfile += ".svg"; std::string svgPath = vrv::StringFormat("%s%s", folderPath.c_str(), cur_outfile.c_str()); toolkit.RenderToSVGFile(svgPath, p); env->SetObjectArrayElement(jArray, p - 1, env->NewStringUTF(svgPath.c_str())); } return jArray; }</code></pre> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Duanle"><img src="https://avatars.githubusercontent.com/u/6520982?v=4" />Duanle</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <blockquote> <p>Please send the file.</p> </blockquote> <p><strong>this is xml</strong> <a href="https://github.com/rism-digital/verovio/files/10193240/BrahWiMeSample.txt">BrahWiMeSample.txt</a></p> <p><strong>this is svg</strong> <img src="https://user-images.githubusercontent.com/6520982/206662660-5ddf652f-2ecd-4321-b160-39e670ff5e32.svg" alt="BrahWiMeSample_001" /></p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/lpugin"><img src="https://avatars.githubusercontent.com/u/689412?v=4" />lpugin</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <p>The problem is that you set the options <strong>after</strong> loading the file. That can work, but you need to call <code>RedoLayout()</code> if you do so.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Duanle"><img src="https://avatars.githubusercontent.com/u/6520982?v=4" />Duanle</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <blockquote> <p>The problem is that you set the options <strong>after</strong> loading the file. That can work, but you need to call <code>RedoLayout()</code> if you do so.</p> </blockquote> <p>That's exactly what you said,The display is normal</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/ahankinson"><img src="https://avatars.githubusercontent.com/u/163183?v=4" />ahankinson</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <p>What happens if you change the order of calls:</p> <pre><code>... vrv::Toolkit toolkit(false); toolkit.SetResourcePath(resourcePath); toolkit.ResetOptions(); // not really necessary because you've just initialized, but OK toolkit.LoadFile(inputFilePath); toolkit.SetOptions(optionJson); int count = toolkit.GetPageCount(); auto jArray = (jobjectArray) env->NewObjectArray( count, env->FindClass("java/lang/String"), env->NewStringUTF("")); ...</code></pre> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Duanle"><img src="https://avatars.githubusercontent.com/u/6520982?v=4" />Duanle</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <blockquote> <p>What happens if you change the order of calls:</p> <pre><code>... vrv::Toolkit toolkit(false); toolkit.SetResourcePath(resourcePath); toolkit.ResetOptions(); // not really necessary because you've just initialized, but OK toolkit.LoadFile(inputFilePath); toolkit.SetOptions(optionJson); int count = toolkit.GetPageCount(); auto jArray = (jobjectArray) env->NewObjectArray( count, env->FindClass("java/lang/String"), env->NewStringUTF("")); ...</code></pre> </blockquote> <p>thanks ,the problem has been solved</p> <img width="988" alt="image" src="https://user-images.githubusercontent.com/6520982/206722043-f784c009-ffce-4780-a3a4-a5a49729ea2b.png"> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>