gibber-cc / gibberwocky

Streamlined live coding for Ableton Live, Max/MSP/Jitter, and MIDI
http://gibberwocky.cc
MIT License
174 stars 11 forks source link

Could gibberwocky live and max be packaged as npm packages ? #16

Open JTriggerFish opened 6 years ago

JTriggerFish commented 6 years ago

I'd like to write a vscode extension to write gibberwocky in there rather than in the browser. Rather than copy the code it would be cleaner if I could require an npm package ( like the atom gibber package does ).

charlieroberts commented 6 years ago

Cool. Are you OK with the code annotations going away? I've thought about trying to abstract them so that they could be re-implemented for other editors besides CodeMirror but it would be a ton of work...

There might be a few other editor-dependent issues to look at. Did you see this project? https://www.youtube.com/watch?v=SEvG3dqVk18

JTriggerFish commented 6 years ago

Great thanks. Yes I saw that, should provide a good starting point.

That's fine for the annotations, I expected that. I'm hopeful that most of them can be done without too much effort using this: https://github.com/Microsoft/vscode-extension-samples/tree/master/decorator-sample or taking inspiration from this: https://github.com/hoovercj/vscode-power-mode

Waveform display will probably be trickier though but that will be a second step.

charlieroberts commented 6 years ago

Cool, I hadn’t seen that decorator example before. Looks promising!

CodeMirror is also getting a dramatic rewrite (which will include support for mobile devices), so I might need to refactor the annotations soon anyways; if so I could try and do a vscode implementation at the same time.

JTriggerFish commented 6 years ago

I’m struggling a bit with the window.foo global variables as these don’t work outside the browser, wouls you have a suggestion for a quick workaround ?

charlieroberts commented 6 years ago

I don't know how the global object works in vscode, but I just changed the export method in gibber.js so that it doesn't explicitly call window:

https://github.com/gibber-cc/gibberwocky.live/blob/6b8d42e736dfc3a74d53dfa376fa6c2d389d5c0f/js/gibber.js#L22

If you change the line in init that calls export and pass in whatever the global object is, maybe that will fix your problem?

JTriggerFish commented 6 years ago

Thanks ! As far as I can tell so far there isn't a global object that can be freely written to but I'm still digging.

charlieroberts commented 6 years ago

Hmmm... interesting. I guess you could declare an object (maybe even name it window, or global) and then execute all code within a with block? I know it's deprecated but it still seems to work in Chrome at least... might be good enough for now.

You'd need to add the with blocks in a couple of places:

https://github.com/gibber-cc/gibberwocky.live/blob/6b8d42e736dfc3a74d53dfa376fa6c2d389d5c0f/js/environment.js#L222

https://github.com/gibber-cc/gibberwocky.live/blob/6b8d42e736dfc3a74d53dfa376fa6c2d389d5c0f/js/clock.js#L94

JTriggerFish commented 6 years ago

Thank you! not 100% sure whether this will work yet but I've done this for now to keep moving forward with other issues. I'm getting an error on: genish.gen.memory = genish.gen.createMemory( 88200, Float64Array )

I'm guessing that the genish.js that is on npm is out of date ?

charlieroberts commented 6 years ago

Yep, exactly. I just bumped up the version on npm to fix this. Thanks!

JTriggerFish commented 6 years ago

I believe there's an issue with the package's code, it reads: createMemory( amount, type ) { const mem = MemoryHelper.create( mem, type ) },

but it should be: createMemory( amount, type ) { const mem = MemoryHelper.create( amount, type ) return mem },

?

charlieroberts commented 6 years ago

Ugh, I don't know how that even happened. Fixed.

JTriggerFish commented 6 years ago

No worries, thank you ! I also resolved the window issue by writing a dummy global module and importing it everywhere: https://github.com/JTriggerFish/vscode-gibberwocky/blob/master/gibber/global.js

hopefully should have at least the communication working soon.

JTriggerFish commented 6 years ago

Hi Charlie, Bit of a long shot but would you by any chance have a test websocket server that sends back what ableton is supposed to send back in order to test gibberwocky's communication without running ableton ? Also see my pull request on genish.js Thanks !