AlbertHart / ahlbapps_old

osmd_transpose is a .js file, (and .htm for testing) to transpose MusicXML files. osmd_transpose is a function to be used with OSMD - Open Sheet Music Display - an Open Source JavaScript engine to display and MusicXML using VexFlow.
https://alhartapps.com/osmd_transpose/transpose/transpose.htm
2 stars 3 forks source link

latest changes - accidentals #11

Open AlbertHart opened 4 years ago

AlbertHart commented 4 years ago

I think I put in all my latest changes for accidentals, etc.

ice6 commented 4 years ago

Thanks for the effort :)

It seems that the latest change make the function broken.

I test it here.

And I sync the latest code to ice6/opensheetmusicdisplay https://ice6.github.io/opensheetmusicdisplay/build/ and the transpose function breaks.

Found that the text before and after <fifths></fifths>missed.

Maybe we can use DOMParser https://developer.mozilla.org/en-US/docs/Web/API/DOMParser to deal with the xml in transpose_xml function.

It can help reduce the effort to handle edge case in the raw xml.

AlbertHart commented 4 years ago

I just tried a file here:

https://alberthart.github.io/osmd_transpose/transpose/transpose.htm

And it seems to work OK.

But this URL does not seem to have a place to past the code.

https://ice6.github.io/opensheetmusicdisplay/build/

So I am confused.

But it is time for sleep now in Denver.

Let me know if you get it working.

AlbertHart commented 4 years ago

If something is failing, try to give me a more concrete example. For example, send me the MusicXML file which os failing, the URL you are working from, and a picture of the output xml which is wrong.

On Sun, May 17, 2020 at 9:21 PM ice6 notifications@github.com wrote:

It seems that the latest change make the function broken.

I test it here https://alberthart.github.io/osmd_transpose/transpose/transpose.htm.

Found that the text before and after missed.

Maybe we can use DOMParser https://developer.mozilla.org/en-US/docs/Web/API/DOMParser to deal with the xml in transpose_xml function.

It can help reduce the effort to handle edge case in the raw xml.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AlbertHart/osmd_transpose/issues/11#issuecomment-629924285, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACEMZ2DWGZXY6G5SIDEY6KDRSCSUPANCNFSM4NDG4HLQ .

-- Al

AlbertHart commented 4 years ago

Maybe we can use DOMParser https://developer.mozilla.org/en-US/docs/Web/API/DOMParser to deal with the xml in transpose_xml function.

I spent a lot of time trying to use a DOM parser to parse the XML, and decided to stick with reading the ASCII myself.

Especially because i wanted to be able to write the transposed XML back to the disk, or pass it on.

One thing, I was worried that many musicxml files may not be properxml.

I read and write most lines without changes, so that I will not introduce errors into the musicxml file because something was not read properly.

So i only change certain parts - , , etc. But pass other things like the lines below without alteration.

single It's On Sun, May 17, 2020 at 9:21 PM ice6 wrote: > It seems that the latest change make the function broken. > > I test it here > . > > Found that the text before and after missed. > > Maybe we can use DOMParser > https://developer.mozilla.org/en-US/docs/Web/API/DOMParser to deal with > the xml in transpose_xml function. > > It can help reduce the effort to handle edge case in the raw xml. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > -- Al
ice6 commented 4 years ago

steps to reproduce the error:

  1. open https://alberthart.github.io/osmd_transpose/transpose/transpose.htm

  2. upload the musicxml file Amazing Grace.txt .(Since Github does not support .musicxml, I changed the file extension to .txt)

  3. do as following: image

  4. then I got this: image

ice6 commented 4 years ago

@AlbertHart it was fixed in this commit

and https://ice6.github.io/opensheetmusicdisplay/build/ works agian.

AlbertHart commented 4 years ago

I grabbed these changes and will repost a new version today with them in it.

I moved "<note-" to just before "<note" to keep them closer together"

            // skip <note-size , conflicts with note element
            if (sline.indexOf('<note-') > -1) {
                str_out += sline;
                str_out += "\n";
                continue;
            }

            if (sline.indexOf("<note") >= 0)
            {
                in_note = true;
AlbertHart commented 4 years ago

Transpose direction is also very important. Especially when you are moving by several half steps.

image

ice6 commented 4 years ago

I added the Transpose direction to the demo

image

check it out :)

It is 23:33 at ShangHai, I have to sleep.

Have a good day!

AlbertHart commented 4 years ago

Great, thanks.

But I still cannot figure out how to paste a score to the page and get it to translate.

image

ice6 commented 4 years ago

@AlbertHart I did not handle the paste case. Let me to try to fix this.

AlbertHart commented 4 years ago

how else do you pass it a file - in the URL?

ice6 commented 4 years ago

Great, thanks.

But I still cannot figure out how to paste a score to the page and get it to translate.

image

solved :) btw, a small bug had been fixed in this commit.

how else do you pass it a file - in the URL?

Restriced to the CORS , we'd better not support it :)

AlbertHart commented 4 years ago

OK. I there a reason your demo does not have the select score stuff?

image

ice6 commented 4 years ago

@AlbertHart

Is it this one?

image

AlbertHart commented 4 years ago

Yes. I didn't see it.

What would you think about adding "Select from disk" below it.

The way I do that is to load a xml file from disk into a string, and then reload the whole page with the string in localeStorage, and read it from the local storage. (I could not find a good way to load a file into a string without then reloading the page)

Or we could get this done and approved and add load from disk to the OSMD Demo later.

On Mon, May 18, 2020 at 8:14 PM ice6 notifications@github.com wrote:

@AlbertHart https://github.com/AlbertHart

Is it this one?

[image: image] https://user-images.githubusercontent.com/889040/82277008-66bec800-99b9-11ea-95fd-3c22b9dde325.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AlbertHart/osmd_transpose/issues/11#issuecomment-630535991, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACEMZ2D2GWA3OUBONDGE5LTRSHTRNANCNFSM4NDG4HLQ .

-- Al

ice6 commented 4 years ago

Yes. I didn't see it.

command + shift + R to reload the page?

What would you think about adding "Select from disk" below it.

drag and drop file on the page is equivliant to select from disk

AlbertHart commented 4 years ago

Drag and drop, requires that I load MAC FInder in one window, load the demo in a second window and drag the file to the DEMO page. Load from disk would be done entirely from the Demo page - like I do in my transpose.htm page.

Also, load from disk lets us grab the name of the loaded file and display it on the page somewhere. I know we display the title, but the file name is often important as well. People may have several scores with the same title, but different information in them.

I would like to see if we can work on the Demo page and add more functionality to it. Either as a "Demo", or as a different useful page - perhaps "Sample" - for people who want to display pages, chamge even more paramters, and print them.

There are a lot of things I would like to see - such as the ability to resize the display to match the screen window automatically - not by having to use Zoom in and Out - which does not shrink the pixel width of the output.

Also, if i try to print the page, it tries to print the top of the page and not the contents.

image

I think a better DEMO could make OSMD looklike a better product for people to use.