Preparing complex sketch for the Web

Hi everyone!

I'm having a little trouble understanding which is the quickest way for me to adapt my current Processing sketch for it to work on a browser. I think I have 2 options, p5.js and processing.js.

However, since my sketch uses libraries like Minim (for audio), controlP5 (user interface), ToxicLibs, etc I think I cannot use processing.js.

If I'm right, the only way I can get my sketch to work on a browser is to use p5.js, but that would mean having to go line by line and changing it manually, right? There is no way of doing this automatically?

I'm also thinking that to use audio in the browser I will have to rewrite my code that uses Minim and use the p5.js sound library instead?

Thank you for your help!


  • Actually neither p5.js nor pjs can fully run your Java Mode sketch!
    Minim can be adapted to use p5.sound instead.
    But ControlP5 needs to be completed reshaped to use DOM elements!

  • Ok, just to make sure then: - Processing.js won't work because I use libraries. - p5.js will work with sound but I will have to change controlP5.

    Is that correct?

    That means the only way of getting my sketch ready for the web would be to rewrite it in p5.js? Is there an automatic way of doing the conversion? It's quite a long sketch.

    Thank you for your help!

  • Answer ✓

    No automation! You're gonna need to re-write your Java Mode sketch as JS syntax.
    Then you're gonna need to learn how to use p5.sound library and convert Minim to it.
    And the worst part is learn how to create GUI elements using browser's DOM elements!

  • If you want to avoid refactoring all the code you'd be better off sticking with ProcessingJS - rather than p5js - and finding some raw JS libraries to replace Minim and controlP5. In JS mode you can just drop the external library code into separate tabs with a .js extension: i.e. 'myLibaryName.js'. I did that with a chess library on this unfinished project.

  • Thank you! I'll look into that also :)

Sign In or Register to comment.