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

Solved Display waveform of selected group

Discussion in 'Scripting Workshop' started by franto, Oct 29, 2019.

  1. franto

    franto NI Product Owner

    Messages:
    43
    I have multiple groups and I would like to display the waveform when group selection is changed before the user actually starts to play. I know how to display waveform and that it should be done within "on note" callback.... is it possible to work around this somehow?
     
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You just need to collect one zone ID from every group into an array and use that to show the waveform via attach_zone(), when you change the soundsource (I assume through dropdown menu etc.).
     
  3. soundtrax

    soundtrax NI Product Owner

    Messages:
    301
    Could you maybe give an example how this actually works? I never got it working even with only one group. When I script something like this (and my group has zone ID 0):
    Code:
    on init
        declare ui_waveform $Waveform(6,6)
        attach_zone ($Waveform,find_zone(0),0)
    end on
    I get a script warning: “attach_zone(): zone not found!
    It only works when I use an actual zone names instead of the ID, but zone IDs would be more flexible.
     
  4. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You don't use find_zone() in this context. Just a straight zone ID number, which you can see on Expert->Zones panel. Just select your group first, then select a zone from that group, you will see that zone highlighted in the list, along with its ID.
     
  5. soundtrax

    soundtrax NI Product Owner

    Messages:
    301
    yes I know about the zone IDs in the expert tab. I just can't find the right command to display the waveform of these zone IDs in the KSP manual... is it something with "get_ui_ID"?
     
  6. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    No, it's literally just typing in the zone ID number, like so: attach_zone($Waveform, 10, 0). This will show zone ID 10 on ui_waveform widget called $Waveform.
     
  7. soundtrax

    soundtrax NI Product Owner

    Messages:
    301
    ah okay...yep now it works. Thanks!!
     
  8. franto

    franto NI Product Owner

    Messages:
    43
    it works nicely! Thank you!
     
  9. Smac88

    Smac88 New Member

    Messages:
    16
    Hi, I have the same problem and with the simple code

    attach_zone($waveform, 28, 0)

    I'm able to see the waveform for the ID 28, but loading more than one group each of it has a different ID, is there a simple code to tell the script "read from ID 0 to ID 100"?

    PS: I have already placed on note, note held, etc. it works fine.
     
  10. soundtrax

    soundtrax NI Product Owner

    Messages:
    301
    you could do something like this for a nki with two zones (0 and 1):
    (of course you could add more zones to the menu)
    Code:
    on init
    declare ui_waveform $Waveform(4,4)
    attach_zone ($Waveform,0,0)
    declare ui_menu $zone_select
    add_menu_item ($zone_select, "Zone 0", 0)
    add_menu_item ($zone_select, "Zone 1", 1)
    end on
    
    on ui_control ($zone_select)
    attach_zone ($Waveform,$zone_select,0)
    end on
     
  11. Smac88

    Smac88 New Member

    Messages:
    16
    I will try that, thx