• Jona

    I made some progress with implementing Embind and EM_ASM to Ofelia.
    EM_ASM is for calling Java Script from C++ and Embind for calling C++ from Java Script.
    The Embind functions are defined in ofApp.cpp.
    I also put an example in my fork: https://github.com/Jonathhhan/ofxOfelia/tree/master/EmscriptenEmbindEmasmExample
    I am very new to C++ programming, so I am happy if somebody wants to optimize / extend the code.
    I am also happy about suggestions.
    I wonder especially how to do two things:
    How to send arrays to Ofelia with Embind (something with std::vector?). That would be great for connecting Ofelia to webMIDI...
    And if it is possible to return a value in Ofelia with Embind (right now I can set values with Embind, but still have to call them from Ofelia). Perhaps it would be possible if Embind would be defined inside Ofelia instead of ofApp.cpp, because then it could be called directly, like it works with Open Frameworks.

    And here is a first attempt to connect Ofelia to webMIDI (there are some timing problems, perhaps because [makenote] knows no noteoff but only velocity 0?):

    posted in extra~ read more
  • Jona

    @4zz4 here is a video that explain how to use the externals folder:

    there you also have to put your compiled externals.
    You can download most of the externals from Deken.
    But if you want to compile them by yourself: In my own experience it is easier with Linux than with Windows. Mostly you have a makefile for Linux and a .sln file for Windows/Visual Studio.
    It is different from external to external, most of the time there is helpful information in the readme/install file of the external.
    If you have problems with compiling a certain library it would be good to know which library and where (which error), then it is easier to help.

    posted in technical issues read more
  • Jona

    Finally it works, at least exchanging floats, integers and strings between Ofelia and Java Script with Emscripten.
    For that I made a new Ofelia class/extension "ofEM_AMS".
    It is not officialy included, but I am happy to share it.
    Right now it is only possible to call Java Script functions from C++, I think about how to do it the other way around.
    Would be nice if it becomes kind of a library for data interaction with Emscripten. Also it should be easy now to connect Ofelia to webMIDI.
    Here is an example without MIDI, just controlling a shader with Java Script sliders: http://gles2.handmadeproductions.de/
    The Java Script functions are called every draw cicle, so it is not very efficient.

    posted in libpd / webpd read more
  • Jona

    Below is a quote about the disadvantages of emscripten_run_script, because of that it would be great to bind EM_ASM to Lua instead:

    "The emscripten_run_script series of macros will execute JavaScript code directly through the use of the JavaScript eval function. The eval function is a special JavaScript function that takes a string and turns it into JavaScript code. Using evals in JavaScript is generally frowned upon because it’s slower compared to alternatives but, more importantly because, if the string you pass in contains user supplied data, that data is being turned into code that can do anything and this poses a serious security risk. Another disadvantage of using the eval function is that, depending on the browser’s security settings, a browser may prevent eval from working altogether and your code may not work as expected.

    It’s recommended that the emscripten_run_script series of macros never be used in production code and especially never with user supplied data. "

    posted in libpd / webpd read more
  • Jona

    Actually I found a way to use emscripten_run_script() with Ofelia.
    These are the steps:

    I added

    #include "/home/jonathan/emsdk/fastcomp/emscripten/system/include/emscripten/emscripten.h"

    (not sure if I need the full path)

    static void pdEmscriptenRunScript(std::string str)

    to ofxOfeliaPdBindings.h

    Run updatePdBindings.sh in scripts/common



    to ofxOfeliaMaps.cpp


    mapper.addFunctionToRename({"pdEmscriptenRunScript", "ofEmscriptenRunScript"});

    to updateMaps.cpp

    1. Run updateMaps.sh from scripts/common

    Thats it. Not sure if something is redundant, but it works.

    1. Call the function from an Ofelia Lua script like:
    ofEmscriptenRunScript(string.format("console.log('hello world')"))

    in Open Frameworks it is written:

    emscripten_run_script("console.log('hello world')");


    ofEmscriptenRunScript(string.format("console.log(%f)", ofGetElapsedTimef()))

    in Open Frameworks it is written:

    emscripten_run_script("console.log($0)", ofGetElapsedTimef());

    A bit easier to implement than EM_ASM, EM_ASM_ and EM_ASM_INT, but I think I am at the right track (hints are still very welcome)...

    posted in libpd / webpd read more
  • Jona

    I tried to make a MIDI sequencer interface for the data with data structures
    (actually only the visualisation is made with data structures):

    posted in technical issues read more
  • Jona


    1. my error number is the number of slots that are missing so that every visitor could visit a stage every timeslot.
    2. as soon as you have a stage with a very small capacity lets say 3, 200 visitors and 10 timeslots you have 170 visitors that cannot visit this stage and, because of that, need to visit another stage again. so, with a condition like that, it is impossible.
    3. I send all visitors randomly through the first timeslot, then the second, etc., the stage is choosen randomly under the given condition.
      And the randomness is weighted, the probability to go to a stage with a capacity of 50 is 50 times bigger than to go to a stage with a capacity of 1.
      And this version simulates your case, I think it should work, at least if you can choose the size of the stages or the repetitions, there is also some data structure visualisation: example.pd

    posted in technical issues read more
  • Jona

    @Johnny-Mauser nice, so the nested data structure arrays seem to work. did you also implement the collision detection (do not go to a stage if person x is already there)? Another Idea, you could reduce the probability for going to a smaller stage. On the other hand, collision detection also would kind of do that. Also in my attempt the first visitor has the most freedom because all stages are still empty. But you could choose the order of visitors for every timeslot randomly.

    posted in technical issues read more
  • Jona

    @Johnny-Mauser wow, that looks kind of complex... nice if it is working, but i am not sure how to test it.
    yes, would be interesting to see a data structure visualisation.
    you could also use [text] with data structures: https://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/27
    i made kind of an abstraction from my attempt (and removed some bugs), perhaps something is useful for your patch:
    yes, you can change drawnumber with set. here is an example (if I understand you right): https://forum.pdpatchrepo.info/topic/10876/lissajous-midi-sequencer/5
    here i tried to map the abstraction to midi notes (does not work too well, but it was worth a try):

    posted in technical issues read more

Internal error.

Oops! Looks like something went wrong!