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

Is it possible to create an auto-harmonizer from chords in realtime in kontakt?

Discussion in 'Scripting Workshop' started by DjDick, Jun 17, 2005.

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

    DjDick Forum Member

    Messages:
    30
    Hello everybody!

    Here's the deal:

    I'd like to be able to play a solo with my right hand (one note at a time) and at the same time transmit the chords with the left hand (only the midi notes in the left hand) to create a harmonic pitchshift in the solo I'm playing with the right hand.

    You know, like those auto-harmonizer-accompaniment keyboards.

    Is this possible to do this with kontakt? thanks.
     
  2. rwillemsen

    rwillemsen NI Product Owner

    Messages:
    4
    Hi,

    Most likely this can be done with the Kontakt Script. I don't know if any such script already exists. Do you have any programming skills?

    Kind regards,
    Richard
     
  3. KevinKauai

    KevinKauai NI Product Owner

    Messages:
    182
    Indeed, the "Kontakt 2 Script Library" has several "harmonization" scripts documented (beginning on page 6 of the PDF included with your update). I've not tried any of them, so I can't attest to their usability and/or qualities, but that would be a good place to start.

    i hope this helps ... KevinKauai
     
  4. DjDick

    DjDick Forum Member

    Messages:
    30
    yes, there are several scripts, but none does the "auto-harmonizer" function, but they just work from a pre-defined chord, don't change it in realtime.

    (As far as I've been trying)
     
  5. Big Bob

    Big Bob Forum Member

    Messages:
    606
    I think you could modify one of the existing harmonizer scripts. Just replace the 'knob' variables with variables that are set when your left hand plays a chord. It ought to be an interesting challenge, anyone want to try it? Maybe we could have a contest to see who can do it? Nothing like competition to get the old creative juices flowing!
     
  6. Big Bob

    Big Bob Forum Member

    Messages:
    606
    I'm not familiar with auto-harmonizer keyboards, but if I take you literally, you want a script that generates harmony notes for your right hand lead line (with the harmony based on the chord progression 'indicated' by your left hand). If the left hand only 'specifies' the chords without actually sounding (and you don't expect to also play some kind of left-hand rhythm), I think I can write a simple script for you to get you started. I'm sorry that no one else has jumped on this because it sounds like it might be a fun project. Let me know if what I described would be useful to you (at least as a starting point).
     
  7. DjDick

    DjDick Forum Member

    Messages:
    30
    It's precisely that... :)

    I have an old yamaha psr-200 lying around (it doesn't even have midi) that does this with the auto-acompaniment function, lol.

    I guess that won't require much processing power then.

    cheers!
     
  8. Big Bob

    Big Bob Forum Member

    Messages:
    606
    OK. I'll take a crack at writing a script that you can try. This may take a week or so but I'll post the text file as soon as I get it done. In the meantime, please review the K2 manual (pages 126..128) so you will know how to paste a text file into the script editor and then save it as a preset.
     
  9. DjDick

    DjDick Forum Member

    Messages:
    30
    I will! Thanks... ;)
     
  10. Big Bob

    Big Bob Forum Member

    Messages:
    606
    I'm almost done with it, hang on for another day or so.
     
  11. DjDick

    DjDick Forum Member

    Messages:
    30
    Weeeeeeeeee! :)

    I can hardly wait! :p :p :p

    Beer is on me!
     
  12. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Hi Dick,

    I finally got a little block of time and finished your Auto-Harmonizer script. I’ve attached it to this posting so hopefully you can download it and save it somewhere. If you're running on Windows you should be able to open the file and print it out in NotePad. When your ready to install it, select all the text and copy it to the clipboard. If you’re running on a MAC, you’re on your own in this department.

    Here’s how to install the script in K2. Load some instrument (like a piano) that you want to try it with. Use Save As to save the patch under a different name so your original copy won’t be disturbed. Now open the script editor and if the patch already uses a script, click on ‘Script’ and choose ‘Empty’. This will erase any existing script. Next, click on ‘Edit’ and paste the text from the clipboard. Next, click the ‘Apply’ button which should spit out the status line message ‘script update (no errors)’. Now in the script Title Box, type in something like ‘Auto Harmonizer’ and hit enter. Next, click ‘Script’ and choose ‘Save Preset’. Navigate to and open the ‘Harmonization’ folder and save your script under a name such as ‘AutoHarmonizer’. Close the script editor and then resave the new instrument complete with script. I think that’s it, you now should be ready to play.

    The header comments pretty well describe what this script does, which is not much more
    than what you asked for. But, using this as a starting point, you should be able to have fun improving upon the function. One improvement that could be made would be to make specifying the chords easier. For example, you could add code that would recognize any single note played with the left hand as a major chord with that root. Any two keys a minor third apart could be mapped to a full minor chord, any two keys a major second apart could be mapped to a seventh chord, etc. Another improvement that would really be fun to implement would be some kind of auto left-hand rhythm, perhaps with a choice of styles, etc.

    I didn’t have a lot of time to test the program but as far as I could see, there doesn’t seem to be any bugs. However, knowing how software is, you’ll probably find some. Let me know if you have a problem getting the script installed and running. After that, you’re on your own. Enjoy!
     

    Attached Files:

  13. DjDick

    DjDick Forum Member

    Messages:
    30
    This script is so wonderful! Awesome!

    I'll try to learn something about scripts, meanwhile I just thought of some things that could be useful in it too (note: I just played with it, I'm still too scared to look at the code, lol, but I'll give it a try later):

    - The possibility of choosing the nr. of harmony voices (i.e. from 2 to 5)

    - The possibility of setting the volume for each of these harmony voices (maybe it would be easier to do this as a percentage of the velocity from the inicial note?)

    - If a note in the right hand is pressed, and after that the chords in the left hand, the harmony is not created. This also happens if you play a harmonized note, and change the chord without releasing the right hand notes (it remains in the previous chord harmony)

    Many thanks!
     
  14. Big Bob

    Big Bob Forum Member

    Messages:
    606
    I guess this means it must have at least installed OK. It's OK to 'look' at the code, it won't bite you ya know ;>) At least read the header comments since they describe what the script is supposed to do. By the way, what does 'lol' mean? I see that a lot, but it just doesn't click for me!

    That would be very easy to do, why don't you make that the first simple change you try to make (after you get the courage to 'look at the code' and study the scripting language.

    I presume you mean individually adjusting the volume rather than all harmony notes as a set (since I already provided this capability with the Blend parameter)? This is also easy to do, at least once you can state the rules. You could also easily scale the velocity rather than offsetting it, however, most synths (and K2 is no exception) tend to respond to velocity in a logrithmic or 'audio-taper' fashion. (Somewhat like a db scale). So, for example, if you wanted the harmony notes to be some number of db quieter than the lead note, you would simply subtract some number from the lead note's velocity rather than multiplying it by a fractional amount. Try it both ways and see which way you like better.


    I knew it wouldn't take long for you to discover this feature! I was aware of this complication from the get go, but, I think the solution to it is a little complex, and the time I can devote to this project is somewhat limited. What I have given you is, admittedly, a very 'bare-bones' implementation. But it should make an excellent framework on which to build. Without a doubt, this will be your first challenging problem to solve, but then I had to leave something for you to do (ha ha).

    I may come back to this from time to time just for fun and if I make any improvements that you or others might find of value, I'll try to post it. Meanwhile, I'm trying to prepare a more useful KSP Reference Guide. Once you have studied a language, all you need is a good reference section to jog your memory. But, the reference section of NI's KSP manual is not well done. It has a lot of holes in it and/or is short on needed detail. Most (but not all) of the missing info is in the manual, but it's scattered all over. I'm trying to pull it all together and to fill in some of the holes. If there is any interest in this, maybe I can post it as a pdf file. (If I can still remember how to use my ancient Acrobat 4 to convert a Word doc into pdf)

    In any case, I hope you have some fun with the script and I hope that it encourages you to study the scripting language. It really has some useful potential to provide 'Intelligent MIDI' capability.

    By the way, if anyone else is interested in looking at this script example, feel free to download it.
     
  15. kong balong

    kong balong NI Product Owner

    Messages:
    205
    thanks for such a well-commented script!

    -=craig
     
  16. Big Bob

    Big Bob Forum Member

    Messages:
    606
    And thank you Craig.

    If there seems to be enough interest in this script, I'll post it again after its next revision.
     
  17. DjDick

    DjDick Forum Member

    Messages:
    30
    Just got home now... :)

    Thanks for all your help.

    I will try to make the changes myself, even if it takes some time. When I have results, I'll post them. I'll be reading the manual in the next days in my spare time, eh eh.

    You really motivated me into this.

    By the way, "lol" is an achronimous of "Laughing Out Loud"

    Cheers!
     
  18. Big Bob

    Big Bob Forum Member

    Messages:
    606
    You learn something new everyday! Thanks to you I can now add lol to my phrase vocabulary.

    Hope you have fun with the script. I started working on V1.01 to fix the hand sync problem and I'll let you know when it's done.
     
  19. Dave Bourke

    Dave Bourke NI Product Owner

    Messages:
    142
    For Mac users, download the script text file. It'll be a TextEdit file - but DON'T open it in TextEdit. To get the correct line breaks (DOS), you MUST drop the file onto a proper text editor icon like BBEdit (commercial), BBEdit Lite (discontinued), or TextWrangler (freeware).

    Now, when the file opens in that application, you can copy and paste it into the open script window in Kontakt 2.

    Note that if you try to do this with TextEdit anyway, the script won't "compile" when you press the "Apply" button and you'll get one line errored out (marked in red).

    Now I gotta go play with Bob's script...

    Kind regards.
     
  20. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Hey Dave,

    Thanks for helping MAC users to gain access to my little scripting effort. As you can probably tell from my 'you're on your own' comment, I know nothing about the MAC world -- so, your help is much appreciated.
     
Thread Status:
Not open for further replies.