moinejf/abc2svg

problems with midi-1.js and modules/MIDI.js

Closed this issue · 11 comments

bwl21 commented

It seems that there are two distinct files midi-1.js and MIDI-1.js. the first one stems from midi.js which backannotates the midi pitches to the notes. The latter one stems from modules/MIDI.js and handles %%MIDI commands.

ninja does not not build MIDI-1.js. I guess it works case insensitive.

Strange.
ninja and samurai use the file system, so, you may have problems with M$-DOS, but I don't think this is your case!
Remove MIDI-1.js and runn ninja/samu with '-d'.

bwl21 commented

i removed all MIDI-1.js and midi-1.js then performed

./ninja -d explain 1&2> x.log

I got

ninja explain: output midi-1.js doesn't exist
ninja explain: midi-1.js is dirty
ninja explain: output MIDI-1.js doesn't exist
ninja explain: MIDI-1.js is dirty
[1/2] if [ -x /usr/bin/git -a -d .git ]; then	VERSION=`git describe`;	VERSION=${VERSION#v};	DATE=`git log -1 --pretty=format:%ci HEAD | cut -d' ' -f1`;else	VERSION=`grep '"version"' package.json|cut -d'"' -f4`;	DATE=`stat --printf=%y build.ninja | cut -d' ' -f1`;fi;cp core/license MIDI-1.js;echo "// MIDI-1.js for abc2svg-$VERSION ($DATE)" >> MIDI-1.js;if [ "x$NOMIN" = "x" ]; then	uglifyjs modules/MIDI.js >> MIDI-1.js;else	cat modules/MIDI.js >> MIDI-1.js;fi
[2/2] if [ -x /usr/bin/git -a -d .git ]; then	VERSION=`git describe`;	VERSION=${VERSION#v};	DATE=`git log -1 --pretty=format:%ci HEAD | cut -d' ' -f1`;else	VERSION=`grep '"version"' package.json|cut -d'"' -f4`;	DATE=`stat --printf=%y build.ninja | cut -d' ' -f1`;fi;cp core/license midi-1.js;echo "// midi-1.js for abc2svg-$VERSION ($DATE)" >> midi-1.js;if [ "x$NOMIN" = "x" ]; then	uglifyjs util/midi.js >> midi-1.js;else	cat util/midi.js >> midi-1.js;fi

Eventually `midi-1.js" was created.

When I swap midi-$MAJOR.js and MIDI-$MAJOR.js in the all rule, then I get MIDI-1.js

When I invoke the build indiviudally:

$ ./ninja -d explain MIDI-1.js > x.log 2>&1
$ ./ninja -d explain midi-1.js > x.log 2>&1

The log of the second one says:

ninja: no work to do.

I tried to compile samurai on MacOs but this failed as well.

Strange again.
In the first log, the commands contain

  • cp core/license MIDI-1.js;
  • cp core/license midi-1.js;
    so, both files MIDI-1.js and midi-1.js must be created.

There could be a problem with your shell. Then, you could try to add 'set -x' in build.ninja:

diff --git a/build.ninja b/build.ninja
index de823e4..952668e 100644
--- a/build.ninja
+++ b/build.ninja
@@ -45,6 +45,7 @@ rule jscu
        VERSION=`grep '"version"' package.json|cut -d'"' -f4`;$
        DATE=`stat --printf=%y build.ninja | cut -d' ' -f1`;$
    fi;$
+set -x;$
    cp core/license $out;$
    echo "// $out for abc2svg-$$VERSION ($$DATE)" >> $out;$
    if [ "x$$NOMIN" = "x" ]; then$

Removing MIDI-1.js and midi-1.js should give you (end of log):

+ cp core/license midi-1.js
+ echo // midi-1.js for abc2svg-1.16.1 (2018-03-29)
+ [ x1 = x ]
+ cat util/midi.js
+ cp core/license MIDI-1.js
+ echo // MIDI-1.js for abc2svg-1.16.1 (2018-03-29)
+ [ x1 = x ]
+ cat modules/MIDI.js

(both files are created by the command 'cp core/license ...')

bwl21 commented

I tried it, but it does not help. As a pity, MacOs is by default case "insensitive" but "case preserving".

So I am afraid there is no other ways to change the name of one of the two files. It would also help on Windows.

I was wondering: do you still need midi-1.js?

bwl21 commented

Yes, I still need it. It sets the MIDI pitches in the notes. This is essential, since Zupfnoter entirely depends on this.

Of course, I am open to another solution. When creating the player events, you need to compute the MIDI pitch again ...

I will change 'midi-1.js' to 'setmidi-1.js' (the change is only in build.ninja).
Is this OK for you?

bwl21 commented

Sure, it is the fastest solution. Maybe you could have a look if we can get rid of this file and provide that function in play. This would avoid double maintenance, as I see some code duplications there.

I had a look many times, but the code is rather different. The only common code I see is the conversion note pitch to MIDI, and it is only a few lines.

bwl21 commented

Ok, then we keep it as separate file. I also saw the methods key_map and pit2midi appearing in both files. But it is pretty stable yet. So I agree to keep it.

Thanks

bwl21 commented

thanks for the rename.