Skip to content

Commit

Permalink
Fixes other small bugs in the Lua generator for VCV-Prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
modlfo committed Apr 16, 2020
1 parent 42152cb commit 10d7729
Show file tree
Hide file tree
Showing 61 changed files with 71 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ let builtin_table extensions =
; [ "cos" ], Scope.Function, Typ.Const.freal_freal (), false
; [ "floor" ], Scope.Function, Typ.Const.freal_freal (), false
; [ "tanh" ], Scope.Function, Typ.Const.freal_freal (), false
; [ "pow" ], Scope.Function, Typ.Const.real_real_real (), false
; [ "pow" ], Scope.Function, Typ.Const.freal_freal_freal (), false
; [ "cosh" ], Scope.Function, Typ.Const.freal_freal (), false
; [ "sinh" ], Scope.Function, Typ.Const.freal_freal (), false
; [ "tan" ], Scope.Function, Typ.Const.freal_freal (), false
Expand Down
5 changes: 5 additions & 0 deletions src/core/typ.ml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ module Const = struct
t |-> t


let freal_freal_freal () =
let t = freal_type () in
t |-> (t |-> t)


let real_real () = real_type |-> real_type

let real_real_real () = real_type |-> (real_type |-> real_type)
Expand Down
1 change: 1 addition & 0 deletions src/generators/codeJs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module Templates = struct
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
11 changes: 7 additions & 4 deletions src/generators/codeLua.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down Expand Up @@ -113,7 +114,7 @@ config = { inputs = <#nprocess_inputs#i>, outputs = <#nprocess_outputs#i>, noteo
in
let readInputs inputs =
match inputs with
| [] -> Pla.string "processor"
| [] -> Pla.unit
| IContext :: args ->
let args =
Pla.string "processor"
Expand Down Expand Up @@ -143,14 +144,16 @@ config = { inputs = <#nprocess_inputs#i>, outputs = <#nprocess_outputs#i>, noteo
let bindings =
List.mapi
(fun i _ ->
let i = i + 1 in
{pla| block.outputs[<#i#i>][i] = 10.0 * processor.process_ret_<#i#i>|pla})
let li = i + 1 in
{pla| block.outputs[<#li#i>][i] = 10.0 * processor.process_ret_<#i#i>|pla})
outputs
in
Pla.unit, Pla.join_sep_all Pla.newline bindings
in
let process_inputs = readInputs config.process_inputs in
let process_lhs, bindings = bindOutputs config.process_outputs in
let update_inputs = readInputs config.update_inputs in

{pla|
local global_block = {}

Expand Down Expand Up @@ -213,7 +216,7 @@ config.bufferSize = 32
function process(block)
global_block = block

<#module_name#s>_update()
<#module_name#s>_update(<#update_inputs#>)

for i=1,block.bufferSize do
<#process_lhs#><#module_name#s>_process(<#process_inputs#>)
Expand Down
1 change: 1 addition & 0 deletions src/generators/defaultReplacements.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ module Default = struct
; ("cosh", "float"), "coshf"
; ("sinh", "float"), "sinhf"
; ("sqrt", "float"), "sqrtf"
; ("pow", "float"), "powf"
; ("clip", "float"), "float_clip"
; ("clip", "int"), "int_clip"
; ("set", "float"), "float_set"
Expand Down
2 changes: 1 addition & 1 deletion src/version.ml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let version = "\nv0.4.5\n"
let version = "\nv0.4.8\n"
1 change: 1 addition & 0 deletions test/code/ad.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/adsr.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/af_f.js.base.browser
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function vultProcess() {
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
1 change: 1 addition & 0 deletions test/code/af_f.js.base.webaudio
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
1 change: 1 addition & 0 deletions test/code/aff_f.js.base.browser
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function vultProcess() {
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
1 change: 1 addition & 0 deletions test/code/aff_f.js.base.webaudio
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
1 change: 1 addition & 0 deletions test/code/aff_ff.js.base.browser
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function vultProcess() {
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
1 change: 1 addition & 0 deletions test/code/aff_ff.js.base.webaudio
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
1 change: 1 addition & 0 deletions test/code/afi_fi.js.base.browser
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function vultProcess() {
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
1 change: 1 addition & 0 deletions test/code/afi_fi.js.base.webaudio
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
1 change: 1 addition & 0 deletions test/code/ahr.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/array_defined_type.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/bitcrush.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/blit.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/defined_types.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/delay.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/gates.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/kick.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/ladder.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/lfo.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/log.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/monocv.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/noise.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/phase.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/phasedist.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/phd.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/polycv.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/rescomb.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/saturate.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/saturate_soft.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/saw_eptr.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/saw_ptr1.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/saw_ptr2.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/saw_r.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/sawcore.lua.base
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function exp(x) return math.exp(x); end
function floor(x) return math.floor(x); end
function tan(x) return math.tan(x); end
function tanh(x) return math.tanh(x); end
function pow(a,b) return math.pow(a,b); end
function sqrt(x) return x; end
function set(a, i, v) a[i+1]=v; end
function get(a, i) return a[i+1]; end
Expand Down
1 change: 1 addition & 0 deletions test/code/sf_f.js.base.browser
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function vultProcess() {
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
1 change: 1 addition & 0 deletions test/code/sf_f.js.base.webaudio
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
this.floor= function(x) { return Math.floor(x); };
this.tan = function(x) { return Math.tan(x); };
this.tanh = function(x) { return Math.tanh(x); };
this.pow = function(a,b) { return Math.pow(a,b); };
this.sqrt = function(x) { return x; };
this.set = function(a, i, v) { a[i]=v; };
this.get = function(a, i) { return a[i]; };
Expand Down
Loading

0 comments on commit 10d7729

Please sign in to comment.