Playing notes with independent rhythms

moosmahna
moosmahna Member Posts: 8 Member
edited October 2024 in Scripting Workshop

Hy,

I try to write a script where I can play vor example C0 and 2 notes are played with different rhythms at the same time. The 2 notes are the note numbers from the knobs. I can not figure out how to start them at the same time with the length and rhythm.

on init
make_perfview
set_ui_height_px (200)

declare $actual_note_01

declare $actual_note_02

declare ui_table %steps16

declare ui_table %steps_0216

declare ui_knob $Steps (1, 16, 1)

make_persistent ($Steps)

read_persistent_var ($Steps)

declare ui_knob $Steps_02 (1, 16, 1)

make_persistent ($Steps_02)

read_persistent_var ($Steps_02)

declare ui_knob $Noten_01(0,36,1)

make_persistent ($Noten_01)

read_persistent_var ($Noten_01)

declare ui_knob $Noten_02(0,36,1)

make_persistent ($Noten_02)

read_persistent_var ($Noten_02)

declare ui_menu $length
add_menu_item ($length, "1/4 Note", $DURATION_QUARTER)
add_menu_item ($length, "1/8 Note", $DURATION_EIGHTH)
add_menu_item ($length, "1/16 Note", $DURATION_SIXTEENTH)
add_menu_item ($length, "1/4 / Note", $DURATION_QUARTER_TRIPLET)
add_menu_item ($length, "1/8 T Note", $DURATION_EIGHTH_TRIPLET)
add_menu_item ($length, "1/16 T Note", $DURATION_SIXTEENTH_TRIPLET)
$length := $DURATION_SIXTEENTH
make_persistent ($length)
read_persistent_var ($length)

declare ui_menu $length_02
add_menu_item ($length_02, "1/4 Note", $DURATION_QUARTER)
add_menu_item ($length_02, "1/8 Note", $DURATION_EIGHTH)
add_menu_item ($length_02, "1/16 Note", $DURATION_SIXTEENTH)
add_menu_item ($length_02, "1/4 / Note", $DURATION_QUARTER_TRIPLET)
add_menu_item ($length_02, "1/8 T Note", $DURATION_EIGHTH_TRIPLET)
add_menu_item ($length_02, "1/16 T Note", $DURATION_SIXTEENTH_TRIPLET)
$length_02 := $DURATION_SIXTEENTH
make_persistent ($length_02)
read_persistent_var ($length_02)

declare ui_menu $length_notes_01
add_menu_item ($length_notes_01, "1/4 Note", $DURATION_QUARTER)
add_menu_item ($length_notes_01, "1/8 Note", $DURATION_EIGHTH)
add_menu_item ($length_notes_01, "1/16 Note", $DURATION_SIXTEENTH)
add_menu_item ($length_notes_01, "1/4 / Note", $DURATION_QUARTER_TRIPLET)
add_menu_item ($length_notes_01, "1/8 T Note", $DURATION_EIGHTH_TRIPLET)
add_menu_item ($length_notes_01, "1/16 T Note", $DURATION_SIXTEENTH_TRIPLET)
$length_notes_01 := $DURATION_SIXTEENTH
make_persistent ($length_notes_01)
read_persistent_var ($length_notes_01)

declare ui_menu $length_notes_02
add_menu_item ($length_notes_02, "1/4 Note", $DURATION_QUARTER)
add_menu_item ($length_notes_02, "1/8 Note", $DURATION_EIGHTH)
add_menu_item ($length_notes_02, "1/16 Note", $DURATION_SIXTEENTH)
add_menu_item ($length_notes_02, "1/4 / Note", $DURATION_QUARTER_TRIPLET)
add_menu_item ($length_notes_02, "1/8 T Note", $DURATION_EIGHTH_TRIPLET)
add_menu_item ($length_notes_02, "1/16 T Note", $DURATION_SIXTEENTH_TRIPLET)
$length_notes_02 := $DURATION_SIXTEENTH
make_persistent ($length_notes_02)
read_persistent_var ($length_notes_02)

declare ui_knob $divisor(1,4,1)

$divisor :=1

make_persistent ($divisor)

read_persistent_var ($divisor)

declare ui_knob $divisor_02(1,4,1)

$divisor_02 :=1

make_persistent ($divisor_02)

read_persistent_var ($divisor_02)

declare $counter

declare $counter_02

end on

on note

ignore_event ($EVENT_ID)

if ($EVENT_NOTE =0)

$counter := 0

$counter_02 := 0

$actual_note_01 := $Noten_01

$actual_note_02 := $Noten_02

while ($NOTE_HELD =1)

play_note($actual_note_01,%steps[$counter],0,$length/$divisor)
play_note($actual_note_02,%steps_02[$counter_02],0,$length_02/$divisor_02)

wait($length_notes_01)
wait($length_notes_02)

$counter := $counter+1
if ($counter >= $Steps)
$counter := 0
end if

$counter_02 := $counter_02+1
if ($counter_02 >= $Steps_02)
$counter_02 := 0
end if

end while

end if

end on

on ui_control ($Steps)

set_table_steps_shown(%Steps, $Steps)

end on

on ui_control ($Steps_02)

set_table_steps_shown(%Steps_02, $Steps_02)

end on

Thanks a lot for your help.

Comments

  • corbo-billy
    corbo-billy Member Posts: 108 Helper

    I corrected for the table settings:

    declare ui_table %steps[16] (5, 2, 100)
    declare ui_table %steps_02[16] (5, 2, 100)
    

  • moosmahna
    moosmahna Member Posts: 8 Member

    No need for changing this. But thanks anyway

This discussion has been closed.
Back To Top