There are many pre-made articulation and phrase presets for each instrument made easily accessible via the main interface windows.
There have been a lot of mixed reviews and surrounding this style of sample library that NI seems to be focused on right now, but much of it is actually misunderstanding how the programming tools work and what they are actually capable of. There are many, many, many sample libraries showcasing strings available nowadays, but there are a few things that really set the newly released Native Instruments Action Strings for Kontakt. Whats passed in is known as a 'Method Group'.This is a brilliant hour-long in-depth overview of the new Native Instruments Action Strings sample library for Kontakt. Where you are passing in the name of the method to encapsulate instead of passing in a lambda. You have access to the variables specified in the parentheses inside the scope of this body.Īltogether this is a quick way to create an anonymous function on the fly that essentially is equivalent to the following: public void SetLine()Īs such you could also create that Action object by doing: var action = new Action(SetLine) Whatever follows the '=>' expression is essentially the body of the function. In this case the function it points to is the lambda expression: () => Invoke() method takes the Action delegate and runs the function it points to. These are alot like a function pointers in C++ - essentially a reference to a function ie a way to encapsulate behavior. Specifically an Action encapsulates a function that returns void, whereas for instance a Func would encapsulate a function with a return value. label1.Invoke(new Action(() =>Īn Action is a delegate type, in other words it encapsulates a function.
#MASCHINE WITH ACTION STRINGS CODE#
Now, because the lambda method has no return value (but must execute a statement) we need to surround the code we want to execute on the UI thread in curly braces: label1.Invoke(new Action(() =>Ĭlose up the remaining parenthesis, and you have the full, finished statement. An empty set of parenthesis will denote that the lambda function takes no parameters, and an "arrow" afterwards shows that we want to start the method: label1.Invoke(new Action(() => First, we specify the delegate type: label1.Invoke(new Action(
Using lambda expressions, we can create an Action delegate inline. That's where the System.Action delegate type comes in: public delegate void Action() What that means is that you give it a reference to a method to call, and Control.Invoke will make sure it gets called on the UI thread (which will prevent cross-threading exceptions while updating the UI.) It takes a default Delegate as a parameter, which means you need to pass it a method that takes no parameters and has no return value. Here's how it's defined: public Object Invoke(Delegate method) Įxecutes the specified delegate on the thread that owns the control's underlying window handle. The syntax that is really holding me up is ()=> the new action is pointing to the code below or something? I am sure it is nothing to complicated, just that I have never seen anything like it before. The code snip that I am really having trouble understanding is: label1.Invoke(new Action(() =>Ĭan someone break down what this is doing. Private void Port1_DataReceived(object sender, SerialDataReceivedEventArgs e) Port1.DataReceived += new SerialDataReceivedEventHandler(Port1_DataReceived) SerialPort Port1 = new SerialPort("COM11", 57600, Parity.None, 8, StopBits.One) Can anyone elaborate on why I need to do this? public Form1()
From my understanding in Port1_DataReceived, I have to create an action because I am in a new tread. I am new to c# and do not understand the syntax of invoking a new action or even what an action is.