All new 3D wavetable wf display

Discussion in 'Scripting Workshop' started by Lovechld2000, Apr 15, 2019.

  1. Lovechld2000

    Lovechld2000 NI Product Owner

    Messages:
    237
    I set this up with a listener based cursor and it's working in 2d. I tried adding the 3d option and I get the error
    attach_zone() zone not found. Has anyone got this working? there is a working wavetable in my k inst group 0.

    Code:
    on init
        make_perfview
        set_ui_height_px(200)
        set_listener($NI_SIGNAL_TIMER_BEAT,24)   
    
        declare wfcursor
    
        declare ui_waveform wf_test(1,1)
        wf_test -> POS_X := 50
        wf_test -> POS_Y := 50
        set_control_par(get_ui_id(wf_test),$CONTROL_PAR_WIDTH,500)
        set_control_par(get_ui_id(wf_test),$CONTROL_PAR_HEIGHT,100)
        set_control_par(get_ui_id(wf_test),$CONTROL_PAR_WT_VIS_MODE,$NI_WT_VIS_3D)
        set_control_par(get_ui_id(wf_test),CONTROL_PAR_PARALLAX_X,0)
        set_control_par(get_ui_id(wf_test),CONTROL_PAR_PARALLAX_Y,1000000)
    end on
    
    
    on note         
        while ($NOTE_HELD = 1)
            wfcursor := get_event_par($EVENT_ID,$EVENT_PAR_PLAY_POS)
            attach_zone($wf_test, get_event_par($EVENT_NOTE,EVENT_PAR_ZONE_ID),$UI_WAVEFORM_USE_SLICES .or. $UI_WAVEFORM_USE_TABLE)
            wait (10000)
        end while
    end on
    
    
    on listener
        set_ui_wf_property(wf_test,$UI_WF_PROP_PLAY_CURSOR,0,wfcursor)
    end on
    
     
  2. Lovechld2000

    Lovechld2000 NI Product Owner

    Messages:
    237
    ah ok i just went to vi control forum. i'll go thru all that
     
  3. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,982
    Attaching zone in that while loop is probably not a good idea. :) This is usually done with a very short blip note, then wait(1), then getting the zone ID of that event ID by using get_event_par($event_ID, $EVENT_PAR_ZONE_ID).

    Also, for attaching wavetable waveforms to ui_wavetable you don't use attach_zone(), but $CONTROL_PAR_WT_ZONE within set_control_par() instead.
     
  4. Lovechld2000

    Lovechld2000 NI Product Owner

    Messages:
    237
    right ok i remember the blip method. thanks.
     
  5. Lovechld2000

    Lovechld2000 NI Product Owner

    Messages:
    237
    ok came up with this 3d adaptation from the VIC forum. Pretty cool and works. The wavetable is assigned to the screen by zone ID, so If you want to try it , your group number (0,1,2,3) must equal your zone ID ( assigned by KT and not changeable by you and found in the expert/zones submenu) so if the zone id doesn't equal the group number it's in, you will not get it to work properly, or at all if you keep swapping out zones. for this demo make a new inst and drag 1 WT zone into each group without changing them and it should be ok


    Code:
    on init
      make_perfview
      set_ui_height_px(200)
     
      declare $i
      declare ui_menu $Wave
      make_persistent($Wave)
      declare ui_knob $Pos (0, 1000, 10)
      make_persistent($Pos)
      set_knob_unit($Pos, $KNOB_UNIT_PERCENT)
      move_control_px($Pos, 500, 100)
    
      fancy3dWT(test,200,5,400,150,10,1e087e,ff4400,f49e00,1eff09,-1000000,1000000)
     
      $i := 0
      while ($i < $NUM_GROUPS)
        add_menu_item($Wave, "Group " & $i + 1, $i)
        inc($i)
      end while
     
    end on
    
    
    function LoadWT()
      set_control_par(get_ui_id($wt_test), $CONTROL_PAR_WT_ZONE, $Wave)
    end function
    
    on persistence_changed
      call LoadWT()
    end on
    
    on ui_control ($Wave)
      $i := 0
      while ($i < $NUM_GROUPS)
        purge_group($i, 0)
        inc($i)
      end while
      purge_group($Wave, 1)
     
      call LoadWT()
    end on
    
    
    on ui_control ($Pos)
      $i := 0
      while ($i < $NUM_GROUPS)
        set_engine_par($ENGINE_PAR_WT_POSITION, $Pos * 1000, $i, -1, -1)
        inc($i)
      end while
    end on
    
    
    macro fancy3dWT(#name#,x,y,width,height,alpha,#bgcolor#,#wfcolor#,#wecolor#,#cscolor#,pxx,pxy)
      declare ui_wavetable $wt_#name#
      $wt_#name# -> POS_X := x
      $wt_#name# -> POS_Y := y
      set_control_par(get_ui_id($wt_#name#),$CONTROL_PAR_WT_VIS_MODE,$NI_WT_VIS_3D)
      set_control_par(get_ui_id($wt_#name#),$CONTROL_PAR_WIDTH,width)
      set_control_par(get_ui_id($wt_#name#),$CONTROL_PAR_HEIGHT,height)
      set_control_par(get_ui_id($wt_#name#),$CONTROL_PAR_BG_ALPHA,alpha)
      set_control_par(get_ui_id($wt_#name#),$CONTROL_PAR_BG_COLOR,9#bgcolor#h)
      set_control_par(get_ui_id($wt_#name#),$CONTROL_PAR_WAVE_COLOR,9#wfcolor#h)
      set_control_par(get_ui_id($wt_#name#), $CONTROL_PAR_WAVE_END_COLOR, 9#wecolor#h)
      set_control_par(get_ui_id($wt_#name#),CONTROL_PAR_PARALLAX_X,pxx)
      set_control_par(get_ui_id($wt_#name#),CONTROL_PAR_PARALLAX_Y,pxy)  
    end macro