• Jona

    Finally it works, at least to 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. "
    https://livebook.manning.com/book/webassembly-in-action/c-emscripten-macros/v-7/73

    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)
    and

    static void pdEmscriptenRunScript(std::string str)
    {
        emscripten_run_script(const_cast<char*>(str.c_str()));
    }
    

    to ofxOfeliaPdBindings.h

    Run updatePdBindings.sh in scripts/common

    Add

    {"ofEmscriptenRunScript",{{{4},{}},0}},
    

    to ofxOfeliaMaps.cpp

    and

    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')");
    

    or

    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):
    exampleSequencerA.pd
    exampleSequencerB.pd

    posted in technical issues read more
  • Jona

    @Johnny-Mauser

    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:
    timetableCalculator.pd
    ttc.png
    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
  • Jona

    @Johnny Mauser here is an attempt. The "collsion detection" is not implemented yet. I think for that you will need a list for each stageSlot with every individual visitor so that you can compare them to the new visitor (perhapps another [text] object?). You could also make an abstraction from this with parameters as arguments. You have to play with them to find a good solution.
    Perhaps you can even create some musical structures with it ;)
    timetableCalculator.pd
    timetableCalculator.PNG
    You could do the whole thing with data structures instead of [text] too, but I would say it is a bit more complicated.
    Another way to calculate the timetable with Pure Data would be to use a Lua script (Ofelia).

    posted in technical issues read more

Internal error.

Oops! Looks like something went wrong!