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

How to convert incoming volume messages into velocity?

Discussion in 'KONTAKT' started by unclepony, Nov 11, 2010.

Thread Status:
Not open for further replies.
  1. unclepony

    unclepony New Member

    Messages:
    19
    Hi

    I am working on project for a friend who works in the field of neuro-feedback. I am trying to improve his results and client experience by improving upon the cheap and poor quality general midi sound set that he is using from the computer sound chip. If all goes well I will be generating some sales for NI in the process!

    I have been provided with a piece of software that takes incoming brain waves and processes them in order to output midi notes and volume messages which correspond in some way to the pitch and amplitude of the input signal.

    I am feeding this generated midi channel into Kontakt by way of a midi loopback device.

    The problem is that in order to get a realistic and dynamic performance from Kontakt I need to somehow convert the volume data into velocity so that the sample playback is dynamic and uses the Sample sets velocity layers. Modulating the channel volume sounds rather duff as you can probably imagine.
    Unfortunately there is no way of changing this in the brain wave program.

    It seems as though this must be a simple thing to fix but I have no experience of scripting and my patch editing experience is rather limited.

    Could someone point me in the right direction and tell me if this can be done or if I am wasting my time and trying to achieve the impossible?

    Any help would be much appreciated.

    Thank you

    Unclepony
     
  2. kotori

    kotori NI Product Owner

    Messages:
    1,153
    Here is a sample script that converts midi controller #7 into velocity (if you are using some other midi CC# you can just edit that number in the script):

    Code:
    on note
      change_velo($EVENT_ID, 1 + 126 * %CC[7] / 127)
    end on
    You paste this into the script editor in Kontakt and press the apply button.
    The little formula there is for the purpose of rescaling the CC range (0-127) to the velocity range (1-127).
     
  3. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Perhaps a multiscript could do better, to do the same thing for all incoming MIDI channels, which then gets routed to any loaded instruments?
     
  4. David Das

    David Das Moderator Moderator

    Messages:
    7,060
    Hey Unclepony, I realize this is OT but this sounds like a fascinating project. Are you blogging about it anywhere or is it otherwise documented somewhere? I would love to learn more about it and follow the results, and maybe even chime in and help if there are things to help with.
     
  5. kotori

    kotori NI Product Owner

    Messages:
    1,153
    I agree with David. It seems like a really fascinating project that I am sure many would be interested reading about. I also think that many script programmers here might be willing to help out if there is any need for more advanced filtering of the incoming midi stream.

    Btw. I realized that the "velocity" in the caption of your post may actually be referring to "velocity layer" rather than the velocity of a note which is set once when the sample is started and is then fixed throughout the lifetime of each note.
    If you are interested in dynamically crossfading between different velocity layers over time you could have a look at my Crossfade script (the same thing can also be achieved without scripting).
     
  6. musicman7p

    musicman7p Forum Member

    Messages:
    339
    same here interesting stuff.... Keep us posted
     
  7. unclepony

    unclepony New Member

    Messages:
    19
    Hi Kotori
    Thankyou so much for your script, it was incredibly kind of you!
    I'm afraid I havent had much luck with it as yet so think I must be doing something wrong somewhere.
    I have pasted it into the editor and clicked apply and have saved it into the user preset folder in order to apply it to the sounds but unfortunately I still seem to be getting the volume info coming out and I can still see the volume fader going up and down.
    I don't know whether the velocity is being changed or not as the volume changes are quite dynamic.

    I presume that the script should bypass the volume information completely and send it all out as velocity?

    I am basically trying to do it using Kontakts library sounds so that it is all self contained and cost efficient for my friend to implement. I presume this script should work with them?
    Should I be putting it in the first script slot?

    I have been using the midi monitor script to see what is going on and it is just reading the incoming volume messages and note data.

    I would really appreciate any help on this.

    Also:

    Thanks to everyone for their interest and encouragement.
    I will post more info up about it as I go along.

    Cheers

    Unclepony
     
  8. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You need to paste the script in each NKI separately and resave - saving as a NKP preset won't magically reapply the script to all NKIs out there.

    Now, since a lot of factory library NKIs have all 5 script slots taken, you have a slight problem - the code should be implemented in those scripts if you don't want to lose the functionality already provided by the scripts.


    Oh, and I think you would also have to disable "Accept standard controllers for volume and pan" in Instrument Options, Controller tab.
     
  9. unclepony

    unclepony New Member

    Messages:
    19
    Thanks Evil Dragon
    I must have explained myself badly.
    I do realise that I need to save all of the patches with the script and that it is not a universal process.

    I think I may be being a bit naive and foolish. I now realise that of course velocity is not a 'cc message' and that it is part of the 'note on'.

    Am I being unrealistic to think that it could be possible to use the volume info to control the velocity of the notes as they are struck and thus bypass the constant velocity sent from the Neuro-feedback program?
    I suppose I imagine it as if the original velocity was ignored and replaced by the value of the volume cc sent at the time the note was generated.

    Sorry for the confusion and my lack of knowledge in this area!

    Cheers

    Unclepony
     
  10. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    That's exactly what kotori's script above is doing, I think. Changes the velocity of currently played notes according to current CC7 (volume) value.
     
  11. kotori

    kotori NI Product Owner

    Messages:
    1,153
    No. But if you followed EvilDragon's advice ("you would also have to disable 'Accept standard controllers for volume and pan' in Instrument Options, Controller tab") it should work I think.

    Alternatively you can use this script that I extended slightly to stop the incoming CC#7 from propagating to the instrument:

    Code:
    on note
      change_velo($EVENT_ID,1+(126*%CC[7]/127))
    end on
    
    on controller
      if ($CC_NUM=7)
        ignore_controller
      end if
    end on
    Cheers,
    Nils
     
  12. unclepony

    unclepony New Member

    Messages:
    19
    Hi Nils

    Sorry for not getting back sooner, I have been unable to do anywork on this for a while as I have been completely snowed under with work.

    I have just started using the last script you sent and it is working really well!
    All of the volume gets turned into velocity and doesn't mees with the track volume.

    Perfect!

    Thank you so much for doing this for me, it has been so helpful and kind of you.

    Now I have to start making some harmonic sense out of these brainwaves!


    Thanks Again!

    Cheers

    James
     
Thread Status:
Not open for further replies.