Solved "force Octave" Script

Discussion in 'Scripting Workshop' started by IvanThaDriver, Sep 7, 2017.

  1. IvanThaDriver

    IvanThaDriver New Member

    Messages:
    15
    Hi everyone!

    I have a kind request to anybody who has scripting experience - could you make a script which forces an instrument to play in one specified octave? (upright bass or piccolo flute are typical examples). So all the midi in the world is played automatically only in this octave.

    Thanks in advance!
    All the best
     
  2. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    19,485
    You mean like rounding every note played in whatever octave, to just one particular octave?
     
  3. IvanThaDriver

    IvanThaDriver New Member

    Messages:
    15
    Yes, like all notes are snapped to this one octave. If note is 3 octaves higher than the specified it's "dragged" 3 octaves down, if it's 2 below it's "dragged" 2 up etc etc
     
  4. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    19,485
    That should be fairly simple.

    Code:
    on init
       declare const $SNAP_OCTAVE := 3   { -2 to 8 }
    end on
    
    on note
       change_note($EVENT_ID, (12 * ($SNAP_OCTAVE + 2)) + ($EVENT_NOTE mod 12))
    end on

    This code snaps all notes to the middle C octave. Change the constant value to change the octave (this is using the naming convention that Kontakt uses, namely, C3 being middle C).
     
    • Like Like x 1
  5. IvanThaDriver

    IvanThaDriver New Member

    Messages:
    15
    Thanks a lot! I've read some tutorials and changed the code so you can choose the octave via knob

    Code:
    on init
        declare ui_knob $force_octave_knob (-2,8,1)
        set_text($force_octave_knob,"Octave")
        $force_octave_knob := 3
        set_control_help($force_octave_knob,"Snaps incoming MIDI notes to the specified octave.")
        move_control ($force_octave_knob,3,2)
    end on
    
    on note
       change_note($EVENT_ID, (12 * ($force_octave_knob + 2)) + ($EVENT_NOTE mod 12))
    end on
     
  6. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    19,485
    Yep, that's a neat solution.

    You will also want to add make_persistent($force_octave_knob) in the init callback.
     
  7. IvanThaDriver

    IvanThaDriver New Member

    Messages:
    15
    Great, thanks again! Here is the final version

    Code:
    on init
    	declare ui_knob $force_octave_knob (-2,8,1)
    	set_text($force_octave_knob,"Octave")
    	$force_octave_knob := 3
    	set_control_help($force_octave_knob,"Snaps incoming MIDI notes to the specified octave.")
    	make_persistent($force_octave_knob) 
    	move_control ($force_octave_knob,3,2)
    end on
    
    on note
       change_note($EVENT_ID, (12 * ($force_octave_knob + 2)) + ($EVENT_NOTE mod 12))
    end on
     
    Last edited: Nov 10, 2017
  8. IvanThaDriver

    IvanThaDriver New Member

    Messages:
    15
    Do you think it's possible to create a kind of "octave loop" (more advanced force octave), I mean that let's say we have a midi instrument which sounds good in two/three octaves, I play lowest string guitar with fishman tripleplay and midi is also it's lowest octave (this case concerns simultaneous playing normal audio guitar and fishman's midi output). Octave higher is midi octave higher too. But then going yet one octave up on guitar makes midi go back to first octave. In simplest version I would like midi instrument to force midi octave 1 for uneven guitar octaves and octave 2 for even octaves. So

    input octave 1 3 5 7 9 is always midi octave 1
    input octave 2 4 6 8 is always midi octave 2

    etc
     
    Last edited: Mar 15, 2020
  9. Rido staff

    Rido staff New Member

    Messages:
    2
    Good afternoon all,
    I have a little problem, how to add octave to the microtonal in the drawing, with all due respect I ask for your help
    Thank You
     

    Attached Files: