hydra-synth / hydra-examples

Examples for using hydra within atom
83 stars 17 forks source link

Variables not declared? #1

Closed carltesta closed 5 years ago

carltesta commented 5 years ago

When I attempt to run this simplified code:

// uses argument as variables in hydra
freq = 10

msg.on('/test', (args) => {
 freq = args[0]
 console.log(args[0])
})

osc(() => freq)
.out()

from the osc.js example I get the following error:

Uncaught ReferenceError: freq is not defined
    at Array.osc (eval at _eval (main.js? [sm]:4), <anonymous>:1:11)
    at Object.typedArg.value (/Volumes/500GB/Users/carltesta/.atom/packages/atom-hydra/node_modules/hydra-synth/src/GeneratorFactory.js:63)
    at Object.draw (eval at compile (/Volumes/500GB/Users/carltesta/.atom/packages/atom-hydra/node_modules/regl/dist/regl.js:5549), <anonymous>:345:11)
    at Object.REGLCommand [as draw] (/Volumes/500GB/Users/carltesta/.atom/packages/atom-hydra/node_modules/regl/dist/regl.js:9435)
    at passes.forEach (/Volumes/500GB/Users/carltesta/.atom/packages/atom-hydra/node_modules/hydra-synth/src/output.js:158)
    at Array.forEach (<anonymous>)
    at Output.tick (/Volumes/500GB/Users/carltesta/.atom/packages/atom-hydra/node_modules/hydra-synth/src/output.js:158)
    at HydraSynth.tick (/Volumes/500GB/Users/carltesta/.atom/packages/atom-hydra/node_modules/hydra-synth/index.js:303)
    at Engine.<anonymous> (main.js? [sm]:187)
    at emitOne (events.js:116)
    at Engine.emit (events.js:211)
    at Engine.tick (/Volumes/500GB/Users/carltesta/.atom/packages/atom-hydra/node_modules/raf-loop/index.js:42)

What am I missing?

carltesta commented 5 years ago

And when I restart ATOM after a force quit I get the following error from the osc-loader:

osc-loader.js? [sm]:105 events.js:173
      throw er; // Unhandled 'error' event
      ^

Error: bind EADDRINUSE 0.0.0.0:57101
    at state.handle.lookup (dgram.js:300:18)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)
    at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:51:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:804:11)
    at internal/main/run_main_module.js:21:11
Emitted 'error' event at:
    at state.handle.lookup (dgram.js:301:14)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)
    [... lines matching original stack trace ...]
    at internal/main/run_main_module.js:21:11
ojack commented 5 years ago

@carltesta ctrl + enter runs a block of code (separated by line breaks) make sure you run the line with freq = 10 before running the rest of the code, or combine all of the code into a single block

carltesta commented 5 years ago

Of course, so sorry for the simple mistake. I tried CTRL-SHIFT-ENTER to run the whole file, but I think I still got the same error because they weren't in a block. Thank you, I'm excited to try and interface Hydra with SuperCollider via OSC.