Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

The Ekdahl FAR - Command language: Difference between revisions

From KNAS Wiki
No edit summary
No edit summary
Line 19: Line 19:
If for instance we would like to start the ''bowing wheel'' and set its frequency to 82.5 Hertz we could send the Ekdahl FAR the following ''command string''<pre>FAR < 1.1:
If for instance we would like to start the ''bowing wheel'' and set its frequency to 82.5 Hertz we could send the Ekdahl FAR the following ''command string''<pre>FAR < 1.1:
bowmotorrun:1, bowcontrolfrequecy:82.5
bowmotorrun:1, bowcontrolfrequecy:82.5
FAR 1.1:
FAR 1.1:
bowingwheel.dcmotor.run:1, bowingwheel.pid.targetfrequency:82.5</pre>We could also use the ''short names'' for the commands<pre>FAR < 1.1:
bowingwheel.dcmotor.run:1, bowingwheel.pid.targetfrequency:82.5</pre>We could also use the ''short names'' for the commands<pre>FAR < 1.1:
bmr:1,bcf:82.5
bmr:1,bcf:82.5
FAR 1.1:
FAR 1.1:
bw.dcm.ru:1, bw.pid.tf:82.5</pre>Both ''bowmotorrun'' and ''bowcontrolfrequency'' takes one ''parameter'' each, ''bowmotorrun'' is ''conditional'' and unless the first ''parameter'' is equal to '1' the motor will not start. The first ''parameter'' of ''bowcontrolfrequency'' sets the frequency of the ''bowing wheel'', the instrument may not execute a ''command'' if it decides that the given ''parameters'' are outside of the working range or they are missing.
bw.dcm.ru:1, bw.pid.tf:82.5</pre>Both ''bowmotorrun'' / ''bowingwheel.dcmotor.run'' and ''bowcontrolfrequency / bowingwheel.pid.targetfrequency'' takes one ''parameter'' each, ''bowmotorrun / bowingwheel.dcmotor.run'' is ''conditional'' and unless the first ''parameter'' is equal to '1' the motor will not start. The first ''parameter'' of ''bowcontrolfrequency / bowingwheel.pid.targetfrequency'' sets the frequency of the ''bowing wheel'', the instrument may not execute a ''command'' if it decides that the given ''parameters'' are outside of the working range or they are missing.


The addition of the hierarchy in the FAR 1.1 firmware isn't just to be able to group commands, but it's also to make the FAR not limited to a single set of ''modules''. In fact, you could have 12 different bowing wheel ''modules'' for 12 different strings, these would then be addressed as ''bowingwheel[0].command, bowingwheel[1].command'' etc. Anyone familiar with C programming notices that this is the standard way of ''indexing'' an object in an array using brackets ("[ ]"). When addressing a module without ''indexing'' as above, the FAR will do one or two things; either use the first object ("[0]") or, if the object is ''selectable'' it will use the previously selected object. To make things smoother a command can be executed on several objects at once by using ranges ("[0-4]") and comma separation ("[0, 3, 5-6]").
The addition of the hierarchy in the FAR 1.1 firmware isn't just to be able to group commands, but it's also to make the FAR not limited to a single set of ''modules'' (and is the first stepping stone to a ''modular'' Ekdahl FAR). In fact, you could have 12 different bowing wheel ''modules'' for 12 different strings, these would then be addressed as ''bowingwheel[0].command, bowingwheel[1].command'' etc. Anyone familiar with C programming notices that this is the standard way of ''indexing'' an array; using brackets ("[ ]"). When addressing a module without ''indexing'' as above, the FAR will do one or two things; either use the first object ("[0]") or, if the object is ''selectable'' it will use the previously selected object. To make things smoother a command can be executed on several objects at once by using ranges ("[0-4]") and comma separation ("[0, 3, 5-6]").


To test out a ''command'' you can send it directly to the Ekdahl FAR using the ''Console'' in the ''Configuration utility''.
To test out a ''command'' you can send it directly to the Ekdahl FAR using the ''Console'' in the ''Configuration utility''.
Line 34: Line 36:
What makes the ''Command language'' truly powerful is the concept of ''variables, functions'' and ''equations''. All ''parameters'' that take numerical values can use any combination of ''variables, functions'' or ''equations.''
What makes the ''Command language'' truly powerful is the concept of ''variables, functions'' and ''equations''. All ''parameters'' that take numerical values can use any combination of ''variables, functions'' or ''equations.''


For instance, we can use the previous example and instead write our ''command string'' as follows<pre>
For instance, we can use the previous example and instead write our ''command string'' as follows<pre>FAR < 1.1:
bowmotorrun:1,bowcontrolfrequency:82.5+note*20
bowmotorrun:1, bowcontrolfrequency:82.5+note*20
</pre>This example requires of course that the ''variable'' ''note'' exists in the current context.  
 
FAR 1.1:
bowingwheel.dcmotor.run:1, bowingwheel.pid.targetfrequency:82.5+note*20</pre>This example requires of course that the ''variable'' ''note'' exists in the current context.  


===== Variables =====
===== Variables =====
Line 43: Line 47:
''Global variables'' are variables that are always available and will exist in any context. The ''global variables'' that are incorporated in the ''firmware'' as of this writing (2025-01-21) are:
''Global variables'' are variables that are always available and will exist in any context. The ''global variables'' that are incorporated in the ''firmware'' as of this writing (2025-01-21) are:


* notecount - Contains the number of ''MIDI'' keys that are being held down, i.e. all ''Note on messages'' received that haven't gotten a paired ''Note off message'' yet
* '''notecount''' - Contains the number of ''MIDI'' keys that are being held down, i.e. all ''Note on messages'' received that haven't gotten a paired ''Note off message'' yet
* uv0 - uv9 - These are ''user variables'' and can be set at any point using the ''globaluservariable command'' with the first ''parameter'' being which variable to set (0-9) and the second ''parameter'' being the value (float).
* '''uv0''' - '''uv9''' - These are ''user variables'' and can be set at any point using the ''globaluservariable command'' with the first ''parameter'' being which variable to set (0-9) and the second ''parameter'' being the value (float).
* e - Contains the constant ''[[wikipedia:E_(mathematical_constant)|e]]''
* '''e''' - Contains the constant ''[[wikipedia:E_(mathematical_constant)|e]]''
* pi - Contains the constant ''[[wikipedia:Pi|pi]]''  
* '''pi''' - Contains the constant ''[[wikipedia:Pi|pi]]''  


''Event variables'' are variables that are set by certain ''MIDI messages'' or when a new value is read on one of the jacks or knobs on the ''Control box''. The ''Event variables'' that are incorporated in the ''firmware'' as of this writing (2025-01-21) are:
''Event variables'' are variables that are set by certain ''MIDI messages'' or when a new value is read on one of the jacks or knobs on the ''Control box''. The ''Event variables'' that are incorporated in the ''firmware'' as of this writing (2025-01-21) are:


* channel - Set by the ''Note on, Note off, Continuous Controller, Poly after touch, Pitch bend, Channel after touch'' and ''Program change MIDI messages''
* '''channel''' - Set by the ''Note on, Note off, Continuous Controller, Poly after touch, Pitch bend, Channel after touch'' and ''Program change MIDI messages''
* note - Set by the ''Note on, Note off'' and ''Poly after touch MIDI messages''
* '''note''' - Set by the ''Note on, Note off'' and ''Poly after touch MIDI messages''
* velocity - Set by the ''Note on'' and ''Note off MIDI messages''
* '''velocity''' - Set by the ''Note on'' and ''Note off MIDI messages''
* pressure - Set by the ''Poly after touch'' and ''Channel after touch MIDI messages''
* '''pressure''' - Set by the ''Poly after touch'' and ''Channel after touch MIDI messages''
* value - Set by the ''Continuous Controller MIDI message'' and by the ''Control box''
* '''value''' - Set by the ''Continuous Controller MIDI message'' and by the ''Control box''
* pitch - Set by the ''Pitch bend MIDI message''
* '''pitch''' - Set by the ''Pitch bend MIDI message''
* program - Set by the ''Program change MIDI message''
* '''program''' - Set by the ''Program change MIDI message''
These variables will contain whatever data is relevant to the <u>last midi message sent</u> and will not stay relevant beyond the reception of the last message.


===== Functions =====
===== Functions =====
Line 63: Line 68:
The ''arithmetic functions'' that are incorporated in the ''firmware'' as of this writing (2025-01-21) are:
The ''arithmetic functions'' that are incorporated in the ''firmware'' as of this writing (2025-01-21) are:


* abs(x) - Returns the ''[[wikipedia:Absolute_value|absolute value]]'' of ''x''
* '''abs'''(x) - Returns the ''[[wikipedia:Absolute_value|absolute value]]'' of ''x''
* acos(x), asin(x), atan(x), atan2(x, y) - Returns the [[wikipedia:Inverse_trigonometric_functions|''arc-cos, -sin, -tan'' and ''-tan2'']] of ''x''
* '''acos'''(x), '''asin'''(x), '''atan'''(x), atan2(x, y) - Returns the [[wikipedia:Inverse_trigonometric_functions|''arc-cos, -sin, -tan'' and ''-tan2'']] of ''x''
* atan2(x,y) - Returns the ''[[wikipedia:Atan2|arctan2]]'' of ''x, y''
* '''atan2'''(x,y) - Returns the ''[[wikipedia:Atan2|arctan2]]'' of ''x, y''
* floor(x), ceil(x) - Returns the [[wikipedia:Floor_and_ceiling_functions|''floor'' and ''ceiling'']] of ''x''
* '''floor'''(x), ceil(x) - Returns the [[wikipedia:Floor_and_ceiling_functions|''floor'' and ''ceiling'']] of ''x''
* exp(x) - Returns the ''[[wikipedia:Exponential_function|exponent]]'' of ''x''
* '''exp'''(x) - Returns the ''[[wikipedia:Exponential_function|exponent]]'' of ''x''
* fac(x) - Returns the ''[[wikipedia:Factorial|factorial]]'' of x
* '''fac'''(x) - Returns the ''[[wikipedia:Factorial|factorial]]'' of x
* ln(x) - Returns the ''[[wikipedia:Natural_logarithm|natural logarithm]]'' of ''x''
* '''ln'''(x) - Returns the ''[[wikipedia:Natural_logarithm|natural logarithm]]'' of ''x''
* log10(x), log20(x) - Returns the ''[[wikipedia:Logarithm|logarithm]]'' of ''x'' using base 10 and 20 respectively
* '''log10'''(x), '''log20'''(x) - Returns the ''[[wikipedia:Logarithm|logarithm]]'' of ''x'' using base 10 and 20 respectively
* ncr(x,y), npr(x,y) - Functions to calculate ''[[wikipedia:Combination|combinations]]'' and ''[[wikipedia:Permutation|permutations]]''
* '''ncr'''(x,y), '''npr'''(x,y) - Functions to calculate ''[[wikipedia:Combination|combinations]]'' and ''[[wikipedia:Permutation|permutations]]''
* pow(x,y) - Returns ''x^y''
* '''pow'''(x,y) - Returns ''x^y''
* sqrt(x) - Returns the ''[[wikipedia:Square_root|square root]]'' of ''x''
* '''sqrt'''(x) - Returns the ''[[wikipedia:Square_root|square root]]'' of ''x''
* cos(x), sin(x), tan(x) - Returns the [[wikipedia:Trigonometric_functions|''cos, sin'' and ''tan'']] of ''x''
* '''cos'''(x), '''sin'''(x), '''tan'''(x) - Returns the [[wikipedia:Trigonometric_functions|''cos, sin'' and ''tan'']] of ''x''
* cosh(x), sinh(x), tanh(x) - Returns the ''[[wikipedia:Hyperbolic_functions|hyperbolic cos, sin and tan]]'' of ''x''
* '''cosh'''(x), '''sinh'''(x), '''tanh'''(x) - Returns the ''[[wikipedia:Hyperbolic_functions|hyperbolic cos, sin and tan]]'' of ''x''
The ''specialized functions'' that are incorporated in the ''firmware'' as of this writing (2025-01-21) are:
The ''specialized functions'' that are incorporated in the ''firmware'' as of this writing (2025-01-21) are:


* bool(x) - Returns 1 if ''x'' is more than 0
* '''bool'''(x) - Returns 1 if ''x'' is more than 0
* ibool(x) - Returns 0 if ''x'' is more than 0
* '''ibool'''(x) - Returns 0 if ''x'' is more than 0
* deadband(x,y) - Returns ''x + y '' if ''x < y'' or ''x - y'' if ''x > y''. If neither of these statements is true it returns ''0'' - used to create a [[wikipedia:Deadband|deadband]] of ''x'' with the threshold of ''y''
* '''deadband'''(x,y) - Returns ''x + y '' if ''x < y'' or ''x - y'' if ''x > y''. If neither of these statements is true it returns ''0'' - used to create a [[wikipedia:Deadband|deadband]] of ''x'' with the threshold of ''y''


''Functions'' can be readily used in a ''command string''<pre>
''Functions'' can be readily used in a ''command string''<pre>
bmr:1,bcf:"8.17579875 * pow(2, (1/12 * note))"
FAR < 1.1:
bowmotorrun:1, bowcontrolfrequency:"8.17579875 * pow(2, (1/12 * note))"
 
FAR 1.1:
bowingwheel.dcmotor.run:1, bowingwheel.pid.targetfrequency:"8.17579875 * pow(2, (1/12 * note))"
</pre>The previous statements starts the ''bowing wheel'' and sets the frequency of the wheel to ''8.17579875 * 2^(1/12 * note)''. A middle 'C' according to ''MIDI'' has a ''note value'' of 36, meaning if we substitute ''note'' with 36 we get the equation ''8.17579875 * 2^(1/12 * 36)'' which comes out to ''~65.4'' Hertz.
</pre>The previous statements starts the ''bowing wheel'' and sets the frequency of the wheel to ''8.17579875 * 2^(1/12 * note)''. A middle 'C' according to ''MIDI'' has a ''note value'' of 36, meaning if we substitute ''note'' with 36 we get the equation ''8.17579875 * 2^(1/12 * 36)'' which comes out to ''~65.4'' Hertz.


Note that the first ''parameter'' for ''bcf'' is put in between double quotes ("). This is because the ''pow''-function requires the use of a comma (",") in order to separate in between its two require inputs ''x'' and ''y'' and we need to make sure that the Ekdahl FAR doesn't mistake that comma for meaning that a new ''command'' is being sent. Single (') and double (") quotes can be used and nested in all ''parameters'' and are <u>required</u> in a lot of circumstances, improper nesting or not using quotes can lead to the instrument not parsing the ''command string'' correctly.
Note that the first ''parameter'' for ''bowcontrolfrequency / bowingwheel.pid.targetfrequency'' is put in between double quotes ("). This is because the ''pow''-function requires the use of a comma (",") in order to separate in between its two required inputs; ''x'' and ''y''. In order for the Ekdahl FAR to know that this comma does not signal the beginning of a new ''command,'' we use quotes. Single (') and double (") quotes can be used and nested in all ''parameters'' and are <u>required</u> in a lot of circumstances, improper nesting or not using quotes can lead to the instrument not understanding the ''command string'' correctly.


== Return messages ==
== Return messages ==