1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

K2-Script: change_pan doesn't work correctly

Discussion in 'Scripting Workshop' started by crowning, Jan 31, 2006.

Thread Status:
Not open for further replies.
  1. crowning

    crowning NI Product Owner

    Messages:
    55
    Hi guys,
    I've made a script that repeats a played note a couple of times,
    each time the panning is changed from left to right.
    Lets say when I repeat the note 3 times, the panning is
    set to -1000, 0 and then 1000 (I've verified this with the 'message'
    function right before the call of 'change_pan').

    But instead of playing left -> middle -> right it plays
    left -> middle -> middle

    Has anyone succesfully done different pannings in one 'on note'
    event?

    Tom
     
  2. kotori

    kotori NI Product Owner

    Messages:
    1,153
    Hi Tom,
    I think you got the last parameter to change_pan wrong.
    relative-bit=0 <--> absolute
    relative-bit=1 <--> relative

    I think the script manual's explanation of the relative-bit would be more clear if they replaced the wording "actual pan value" with "current pan value". After having just skimmed the documentation I made the same mistake as you did :)

    Cheers,
    Nils
     
  3. crowning

    crowning NI Product Owner

    Messages:
    55
    Hi Nils,
    actually that was the first thing I've thought of, but no matter
    how I set this bit, the result is the same :(
    I've even tried a polyphonic variable just in case the 'on note'
    event is triggered from within the script to not re-initialze
    it again...

    Anyway, thanks for the answer.
    Tom
     
  4. kotori

    kotori NI Product Owner

    Messages:
    1,153
    Hi again Tom,
    sorry for pointing out the obvious.

    Have you tried a really simple script like this one:
    Code:
    on note
      change_pan($EVENT_ID, -1000, 0)
      wait(500000)
      change_pan($EVENT_ID, 0, 0)
      wait(500000)
      change_pan($EVENT_ID, 1000, 0)
    end on
    This script does the job for me.
    Could it be a problem specific to a certain K2 instrument?

    Best,
    Nils
     
  5. crowning

    crowning NI Product Owner

    Messages:
    55
    Nils, thanks for your help.
    Could you try out the following script on your system?
    Thanks in advance.
    Tom

    Code:
    on note
      change_pan($EVENT_ID, -1000, 0)
      play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
      wait(1000000)
      change_pan($EVENT_ID, 0, 0)
      play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
      wait(1000000)
      change_pan($EVENT_ID, 1000, 0)
      play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
    end on
    
     
  6. kotori

    kotori NI Product Owner

    Messages:
    1,153
    Hi again Tom,
    now I see. The $EVENT_ID variable represents the note that triggered the 'on init' callback. Even if you generate your own notes with play_note, $EVENT_ID will still refer to the same tone. So your script only modifies the panning of the triggering note, not the ones that you generate.

    The play_note function returns a new note ID for each generated note, so if you want to change such a note you have to save the return value in a variable and use that instead of $EVENT_ID, like this:
    Code:
    $my_id := play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
    change_pan($my_id, 1000, 0)
    Best,
    Nils
     
  7. crowning

    crowning NI Product Owner

    Messages:
    55
    Hi Nils,
    thanks for this information, I didn't know that play_note
    returns the new event id (it's not mentioned in the manuals
    reference, so I thought the id would stay the same).

    Now it works perfectly :)

    Thanks a lot.
    Tom
     
Thread Status:
Not open for further replies.