how to make a button or KNOB or SWICHE POLY mode

Elad A
Elad A Member Posts: 3 Member
edited October 2022 in Scripting Workshop

hello

Someone may know how to make a button or KNOB or SWICHE

Play for POLY mode with one click

the same program + POLY mode



on init

declare const $pitch_change_interval := 100

declare $glide_on

declare $currentnote_id

declare $newnote_id

declare $oldnote1_id

declare $oldnote2_id

declare $oldnote3_id

declare $current_pitch

declare $target_pitch

declare $pitch_shift

declare $actual_glide

declare $interval_cents

declare polyphonic $this_id

declare ui_knob $Glide(1000, 1000000, 1000000)

declare ui_knob $Start(0, 1000000, 1000000)

declare ui_knob $Scaling(100, 1000, 100)

declare ui_value_edit $Threshold(0, 127, 1)

$Glide := 120000

$Start := 5000

$Scaling := 125

$Threshold := 12

move_control($Glide,1,1)

move_control($Start,2,1)

move_control($Scaling,3,1)

move_control($Threshold,4,1)

make_persistent($Start)

make_persistent($Glide)

make_persistent($Scaling)

make_persistent($Threshold)

message("")

end on


on note

if ($glide_on=1)

ignore_event($EVENT_ID)

$newnote_id := play_note($EVENT_NOTE,$EVENT_VELOCITY,$Start,-1)

$this_id := $newnote_id

change_tune($newnote_id,$current_pitch-($EVENT_NOTE*100000),0)

$target_pitch := $EVENT_NOTE*100000

$interval_cents := abs($target_pitch/1000-($current_pitch/1000))

if ($interval_cents>($Threshold*100))

$interval_cents := $Threshold*100

end if

$actual_glide := $Glide+($Glide*$interval_cents/1200*($Scaling-100)/100)

fade_out($newnote_id,0,1)

fade_in($newnote_id,$actual_glide)

fade_out($currentnote_id,$actual_glide,1)

note_off($oldnote3_id)

$oldnote3_id := $oldnote2_id

$oldnote2_id := $oldnote1_id

$oldnote1_id := $currentnote_id

$currentnote_id := $newnote_id

$pitch_shift := ($target_pitch-$current_pitch)/($actual_glide/$pitch_change_interval)

wait($pitch_change_interval)

while (abs($target_pitch-$current_pitch)>abs($pitch_shift))

if ($currentnote_id=$this_id)

change_tune($currentnote_id,$pitch_shift,1)

change_tune($oldnote1_id,$pitch_shift,1)

change_tune($oldnote2_id,$pitch_shift,1)

change_tune($oldnote3_id,$pitch_shift,1)

$current_pitch := $current_pitch+$pitch_shift

wait($pitch_change_interval)

else

exit

end if

end while

if ($currentnote_id=$this_id)

$pitch_shift := $target_pitch-$current_pitch

change_tune($currentnote_id,$pitch_shift,1)

change_tune($oldnote1_id,$pitch_shift,1)

change_tune($oldnote2_id,$pitch_shift,1)

change_tune($oldnote3_id,$pitch_shift,1)

$current_pitch := $target_pitch

end if

else

$currentnote_id := $EVENT_ID

$current_pitch := $EVENT_NOTE*100000

$glide_on := 1

end if

end on


on release

if ($EVENT_ID=$currentnote_id)

$glide_on := 0

note_off($oldnote3_id)

note_off($oldnote2_id)

note_off($oldnote1_id)

$current_pitch := $target_pitch

end if

if ($glide_on=1 and ($EVENT_ID # $oldnote3_id))

ignore_event($EVENT_ID)

wait($Glide)

note_off($EVENT_ID)

end if

end on

Comments

  • Kaiwan_NI
    Kaiwan_NI Administrator Posts: 2,523 admin

    Hi @EvilDragon can you please help Elad out? 🙏

  • Gablux
    Gablux Member Posts: 71 Member
    edited October 2022

    Going from monophonic glide to polyphonic is not a linear step, it is one or two orders of magnitude more.

    First because you may play one note and in a second moment you may play 2. Or you could have played 2 notes then you play other 2. Or you play 3 notes then you play 2. There are lots of possible scenarios involved.

    You would have to come up with a system, which has no necessarily scientific truth to it, it would be something that you are happy with its behaviors and make your program based on that.

    The basic idea is to take into account the first scenario (1 or more notes came in) and compare with the next scenario (1 or more notes came in, while the first notes were being held or not) and how you would like to treat that. So note buffer comparisons. From there you would stablish the rules for note movement. Start from small examples and work your way up to a more general example, or an example that is large enough so users can have fun using your instrument.

  • Elad A
    Elad A Member Posts: 3 Member
    Does anyone know how to change it and send me a file here?
    


  • Gablux
    Gablux Member Posts: 71 Member
    edited October 2022

    I do, but I would not do it for free. And I don't believe anyone here or anywhere else in the world would give you this kind of work for free.

    However, have you tried the Unison - Portamento factory script?

    Maybe it is exactly what you are looking for.

  • Elad A
    Elad A Member Posts: 3 Member
    Does anyone know how to change it and send me a file here?
    

    Of course I tried very nice

    Unison - Portamento

    But anyway I prefer to play if it's Portamento

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    So just disregard the Unison part. Portamento in that script is already polyphonic.

Back To Top