Giter Club home page Giter Club logo

bowery's Issues

`clockdiv.lua`: bad argument #2 to 'clock_schedule_sync' (number expected, got nil) error on input 2 updates

When attempting to run clockdiv.lua, I am getting this error on any voltage change at input 2:

> r clockdiv.lua                                                       
running clockdiv.lua                                                   
^^pub("_clear")Running: clock divider                                  
bad argument #2 to 'clock_schedule_sync' (number expected, got nil)    
stack traceback:                                                       
  [C]: in function 'clock_schedule_sync'                               
  ?: in function 'clock_resume_handler'                                
  ?: in field 'run'                                                    
  ?: in method 'clock'                                                 
  userscript:26: in function 'init'                                    
^^ready()

I spent some time debugging - as far as I can tell, what is causing the error for me is that windows[win_ix][n] within the newdiv() function is undefined/nil.

I was able to get the script to work by replacing windows[win_ix][n] with public["win" .. win_ix][n], but that feels hacky to me:

--- clock divider
-- in1: clock input
-- in2: division selector (see divs)
-- out1-4: divided outputs

function newdiv()
  for n=1,4 do
    output[n].clock_div = public["win" .. win_ix][n]  -- this is the changed line!
  end
end

-- choose your clock divisions
windows = {
  public{win1 = {5, 7, 11, 13}}:action(newdiv),
  public{win2 = {3, 5, 7 , 11}}:action(newdiv),
  public{win3 = {2, 3, 5 , 7 }}:action(newdiv),
  public{win4 = {2, 4, 8 , 16}}:action(newdiv),
  public{win5 = {4, 8, 16, 32}}:action(newdiv),
}
win_ix = 3

function init()
  input[1].mode('clock',1/4)
  input[2].mode('window', {-3,-1,1,3})
  for n=1,4 do
    output[n]:clock(public.win3[n])
  end
end

input[2].window = function(win, dir)
  win_ix = win
  newdiv(windows[win])
end

can anyone else reproduce this / what is the correct way to fix it?

`snippets/acquaintances.lua`: frequency does not update

within the update_speeds function, I am seeing freq remain a static value (7.389056, which is equal to math.exp(2)) no matter what voltage is present at input 1.

I think this is due to some issue with line 21. math.exp() seems to expect one argument according to the Lua docs I am seeing (example) and replit.com. the second argument is being ignored in the current script.

maybe this should be using a different math function?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.