I have scripted a scene with only one trigger, but many cursors running through it on their respective paths. I want the trigger to transmit a MIDI note number (I have to use midi instead of OSC because Reaktor won’t accept osc when run as a plugin) based on cursor running through it. For some reason, the note number is mapped between 0-1 and not 0-127. This is where i’m stuck:
run("add trigger 1020");
run("setpos current 0 0 0");
run("setmessage current 1, midi://midi_out/notef 1 "+ (cursor_id/127));
You can see i’ve tried to map note number to 0-1 range by dividing it by 127. This doesn’t work though. Strangely I get output with note number 63: midi://from_iannix/notef 1 63 (Eb4) 12 1 (1 s.).
I’ve also tried plain and simple run("setmessage current 1, midi://midi_out/notef 1 cursor_id");
but it gives me always note number 127 since my cursor id’s go from 1-24.
I don’t get it. How do I perform calculations with cursor_id?
Hi!
Great job for now ; just a little mistake in the setmessage. You can use “+” operator to concatenate, but it will only work when the script is computed (at loading). To perform it in real time, you may use the {} (braces with javascript inside) :
run("setmessage current 1, midi://midi_out/notef 1 {cursor_id/127}");
Be aware that you’re using /notef in floating format (‘f’ => needs values between 0. and 1.). You can also use the /note that uses integers (between 0 and 127). So it could look like:
run("setmessage current 1, midi://midi_out/note 1 cursor_id");
Hope it is clear!
Thanks for the prompt reply! That was it. Now it works just like I wanted, thank you!
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |