Thanks for that update, Christian and for dealing with my inane feedback.
Got a compile error on the latest cvs release:
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../.. -Wreturn-type
-ffast-math -g -O2 -pthread -MT parser.lo -MD -MP -MF .deps/parser.Tpo -c
parser.cpp -fPIC -DPIC -o .libs/parser.o
In file included from parser_shared.h:16:0,
from parser.y:14:
tree.h: In member function ‘virtual void
LinuxSampler::ExecContext::resetPolyphonicData()’:
tree.h:715:84: error: ‘memset’ was not declared in this scope
memset(&polyphonicIntMemory[0], 0, polyphonicIntMemory.size() *
sizeof(int));
^
Makefile:532: recipe for target 'parser.lo' failed
make[5]: *** [parser.lo] Error 1
make[5]: Leaving directory
'/home/andrew/Desktop/Linuxsampler/linuxsampler/src/scriptvm'
Andrew.
On Thu, May 25, 2017 at 12:17 PM, Christian Schoenebeck <
schoeneb...@linuxsampler.org> wrote:
> On Thursday, May 25, 2017 04:29:01 you wrote:
> > > Your variable $alt is declared "polyphonic". That means each time your
> > > note
> > > event handler is executed, it is using a completely separate instance
> of
> > > your
> > > variable $alt (which is always initialized with 0 by the way). Hence
> $alt
> > > is
> > > always 0 and thus your case 1 is never executed.
> >
> > Actually, with the above script, case 1 is executed if i press the same
> key
> > multiple times, or other keys multiple times on a per note basis. Cool
> > stuff :D
>
> You actually found a bug. The polyphonic data was not reset to zero. I
> never
> stumbled over this bug since so far I always initialized polyphonic
> variables
> with some data at the beginning of the event handler like:
>
> on init
> declare polyphonic $foo
> end on
>
> on note
> $foo := 4
> ...
> end on
>
> I just fixed that bug now. They are now automatically reset to 0.
>
> However the rest of what I said about polyphonic variables was true. In
> your
> case you were just "lucky" that the exact same memory portion was used for
> the
> polyphonic variable, which was due to the fact that your script was quite
> simple and only one event handler instance was executed at a time. For
> example
> the following simple script:
>
> on init
> declare polyphonic $foo
> end on
>
> on note
> { increment variable by 1 }
> inc($foo)
> { print value to terminal }
> message("foo is " & $foo)
> { sleep for 3 seconds }
> wait(3000000)
> end on
>
> Would have behaved differently there when you trigger multiple notes in
> short
> time. Because with that example (due to the wait() call) several instances
> of
> the event handler would have been executed, each one with its own $foo
> variable instance.
>
> > The case logic works, but yeah, the benefit of having a 'per key'
> > transposition is up for debate.. Unless I'm doing avant-garde! :D
>
> Like I said, you would not use a polyphonic variable for your specific
> example. And if you wanted a alternating value per key, you would do it
> with
> array variable instead:
>
> on init
> declare %alt[128] { not polyphonic ! a global, shared array variable }
> end on
>
> on note
> ...
> %alt[$EVENT_NOTE] := 0
> ...
> %alt[$EVENT_NOTE] := 1
> ...
> end on
>
> > Just to better highlight the issue I'm having with the above script, I
> > wrote this small snippet:
> >
> > on note
> > ignore_event($EVENT_NOTE)
> > ignore_event($EVENT_VELOCITY)
>
> That's not how ignore_event() works. ignore_event() expects an "event ID".
> An
> event ID is neither a MIDI note number, nor a MIDI velocity value, an
> event ID
> is like a sampler internal time stamp which identifies exactly one specific
> event in time. So usually you call ignore_event() like this:
>
> ignore_event($EVENT_ID)
>
> $EVENT_ID is a built-in variable reflecting the event which cause the
> current
> event handler to be executed. So in a note handler it is the event ID of
> the
> note-on event, in a release handler it is the event id of the note-off
> event,
> in a controller handler it is the event ID of the MIDI CC event, etc.
>
> Maybe I have to make that more clear in the docs of that function.
>
> CU
> Christian
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxsampler-devel mailing list
Linuxsampler-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel