Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WebAssembly (wasm) target for scsynth #5309

Closed
wants to merge 44 commits into from

Commits on Dec 21, 2020

  1. first step -- "fix" make files

    - introduce a hypothetical new audio api 'openal'
    - some EMSCRIPTEN conditionals
    - ignore missing boost pthreads for now
    
    The cmake command for now is:
    
        $ emcmake cmake -DSC_WII=no -DSC_EL=no -DSUPERNOVA=no -DSC_HIDAPI=no -DNO_LIBSNDFILE=yes -DSC_QT=no -DNO_AVAHI=yes -DSC_ABLETON_LINK=no -DCMAKE_BUILD_TYPE="Release" -Wno-dev -s USE_PTHREADS=1 -DPTHREADS_LIBRARY=ignore --target scsynth ..
    Sciss committed Dec 21, 2020
    Configuration menu
    Copy the full SHA
    008892c View commit details
    Browse the repository at this point in the history
  2. step: some ugens compile (?)

    - until the missing audio API is detected
    Sciss committed Dec 21, 2020
    Configuration menu
    Copy the full SHA
    05a9834 View commit details
    Browse the repository at this point in the history

Commits on Dec 22, 2020

  1. step

    - add some more preprocessor conditionals
    - now we get an initial list of undefined symbols
      (mostly: initialization of audio API, some pthread, some file system)
    Sciss committed Dec 22, 2020
    Configuration menu
    Copy the full SHA
    4a2a73f View commit details
    Browse the repository at this point in the history
  2. disable boost shared memory

    Sciss committed Dec 22, 2020
    Configuration menu
    Copy the full SHA
    dcf0664 View commit details
    Browse the repository at this point in the history
  3. pretend the file system is unix

    Sciss committed Dec 22, 2020
    Configuration menu
    Copy the full SHA
    a801d5d View commit details
    Browse the repository at this point in the history
  4. update readme

    Sciss committed Dec 22, 2020
    Configuration menu
    Copy the full SHA
    fc7e8d8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    fa4882b View commit details
    Browse the repository at this point in the history
  6. step. add blank SC_WebAudio.cpp ; change 'openal' to 'webaudio'

    - we have unstaged commits in `external_libraries/nova-tt`; thus
      next step will be to commit them in a fork of nova-tt
    Sciss committed Dec 22, 2020
    Configuration menu
    Copy the full SHA
    5ee1823 View commit details
    Browse the repository at this point in the history
  7. update submodules

    - use nova-tt fork (branch wasm)
    - I ran `update --remote`; was this a good idea?
    Sciss committed Dec 22, 2020
    Configuration menu
    Copy the full SHA
    613ff99 View commit details
    Browse the repository at this point in the history

Commits on Dec 23, 2020

  1. step: dummy impl of SC_WebAudio.cpp

    - make succeeds now
    Sciss committed Dec 23, 2020
    Configuration menu
    Copy the full SHA
    92ef16d View commit details
    Browse the repository at this point in the history
  2. add HTML target

    Sciss committed Dec 23, 2020
    Configuration menu
    Copy the full SHA
    14f3815 View commit details
    Browse the repository at this point in the history
  3. try to run scsynth with args

    - seems we had flags on emcmake that were never passed to emcc
    - we have a strange linker error regarding shared memory
    - now with shared memory actually enabled, we cannot run in Firefox
      without user adjustments
    - in Chromium, there is an error enumerating audio/video devices
    - some problem now in boost
    
        at boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>::priv_add_segment(void*, unsigned long) (http://0.0.0.0:8000/scsynth.wasm:wasm-function[4452]:0xceebe)
    
    This may be a problem due to assuming _no_ shared memory in previous
    preprocessor tuning; perhaps we need to remove those diversions again
    Sciss committed Dec 23, 2020
    Configuration menu
    Copy the full SHA
    48bd2b7 View commit details
    Browse the repository at this point in the history
  4. the hairy stuff starts

    ```
    abort @ scsynth.js:1475
    ___assert_fail @ scsynth.js:2082
    boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>::priv_add_segment(void*, unsigned long) @ scsynth.wasm:1
    boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>::rbtree_best_fit(unsigned long, unsigned long) @ scsynth.wasm:1
    boost::interprocess::segment_manager_base<boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul> >::segment_manager_base(unsigned long, unsigned long) @ scsynth.wasm:1
    boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index>::segment_manager(unsigned long) @ scsynth.wasm:1
    boost::interprocess::ipcdetail::basic_managed_memory_impl<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index, 16ul>::create_impl(void*, unsigned long) @ scsynth.wasm:1
    boost::interprocess::ipcdetail::create_open_func<boost::interprocess::ipcdetail::basic_managed_memory_impl<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index, 16ul> >::operator()(void*, unsigned long, bool) const @ scsynth.wasm:1
    void boost::interprocess::ipcdetail::managed_open_or_create_impl<boost::interprocess::shared_memory_object, 16ul, true, false>::priv_open_or_create<boost::interprocess::ipcdetail::create_open_func<boost::interprocess::ipcdetail::basic_managed_memory_impl<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index, 16ul> > >(boost::interprocess::ipcdetail::create_enum_t, char const* const&, unsigned long, boost::interprocess::mode_t, void const*, boost::interprocess::permissions const&, boost::interprocess::ipcdetail::create_open_func<boost::interprocess::ipcdetail::basic_managed_memory_impl<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index, 16ul> >) @ scsynth.wasm:1
    boost::interprocess::ipcdetail::managed_open_or_create_impl<boost::interprocess::shared_memory_object, 16ul, true, false>::managed_open_or_create_impl<boost::interprocess::ipcdetail::create_open_func<boost::interprocess::ipcdetail::basic_managed_memory_impl<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index, 16ul> > >(boost::interprocess::open_or_create_t, char const* const&, unsigned long, boost::interprocess::mode_t, void const*, boost::interprocess::ipcdetail::create_open_func<boost::interprocess::ipcdetail::basic_managed_memory_impl<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index, 16ul> > const&, boost::interprocess::permissions const&) @ scsynth.wasm:1
    boost::interprocess::basic_managed_shared_memory<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index>::basic_managed_shared_memory(boost::interprocess::open_or_create_t, char const*, unsigned long, void const*, boost::interprocess::permissions const&) @ scsynth.wasm:1
    detail_server_shm::server_shared_memory_creator::server_shared_memory_creator(unsigned int, unsigned int) @ scsynth.wasm:1
    World_New @ scsynth.wasm:1
    ```
    Sciss committed Dec 23, 2020
    Configuration menu
    Copy the full SHA
    6ccfb25 View commit details
    Browse the repository at this point in the history
  5. fix linker/boost problem

    Sciss committed Dec 23, 2020
    Configuration menu
    Copy the full SHA
    f3fe089 View commit details
    Browse the repository at this point in the history

Commits on Dec 26, 2020

  1. giving up on cmake

    Sciss committed Dec 26, 2020
    Configuration menu
    Copy the full SHA
    8e35ca5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d305c2d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    df2f452 View commit details
    Browse the repository at this point in the history
  4. store audio context

    Sciss committed Dec 26, 2020
    Configuration menu
    Copy the full SHA
    d4d82b4 View commit details
    Browse the repository at this point in the history

Commits on Dec 27, 2020

  1. step. allow omission of -u, -t; set em main loop

    - somehow it hangs if we call `EventLoop::run([world]() { World_WaitForQuit(world, true); });`
      so skip that for now
    Sciss committed Dec 27, 2020
    Configuration menu
    Copy the full SHA
    470ab94 View commit details
    Browse the repository at this point in the history
  2. explicit UI boot

    - add a 'boot' button so we don't run into the problem of
      having an AudioContext that doesn't start
    Sciss committed Dec 27, 2020
    Configuration menu
    Copy the full SHA
    50c1db9 View commit details
    Browse the repository at this point in the history

Commits on Dec 29, 2020

  1. add print-error-to-console hook

    Sciss committed Dec 29, 2020
    Configuration menu
    Copy the full SHA
    d04827e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    cca695c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    745eac4 View commit details
    Browse the repository at this point in the history

Commits on Dec 30, 2020

  1. Configuration menu
    Copy the full SHA
    b0b670f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    552bfa8 View commit details
    Browse the repository at this point in the history
  3. audio and osc basically (almost) working. shared-array-buffer prob

    - so all pieces are in place, OSC messages seem to be correctly encoded
    - audio driver start/stop now in place
    - but we get these errors:
    
    Uncaught TypeError: Failed to execute 'copyToChannel' on 'AudioBuffer': The provided ArrayBufferView value must not be shared.
        at ScriptProcessorNode.ad.proc.onaudioprocess (scsynth.js:1688)
    ad.proc.onaudioprocess @ scsynth.js:1688
    
    It seems that because of `-pthread`, the HEAP is now backed by
    `SharedArrayBuffer`, and that in turn cannot be used in `copyToChannel`.
    
    Hopefully, we can just make one additional copy. If not, we're f*cked
    :-O
    Sciss committed Dec 30, 2020
    Configuration menu
    Copy the full SHA
    e6381ed View commit details
    Browse the repository at this point in the history
  4. example OSC messages; UGens are not 'installed'!

    - for example, trying to d_recv analog-bubbles,
      the first UGen encountered, 'Control' is apparently not
      installed
    - probably we need to include some binary file for the
      emscripten virtual file system
    Sciss committed Dec 30, 2020
    Configuration menu
    Copy the full SHA
    3c189a6 View commit details
    Browse the repository at this point in the history
  5. plugins are statically linking!

    - DiskIO is disabled because we currently don't build with libsndfile
      (perhaps it's possible -- I don't remember why I had to disable it)
    Sciss committed Dec 30, 2020
    Configuration menu
    Copy the full SHA
    6002639 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    0adb2b7 View commit details
    Browse the repository at this point in the history

Commits on Dec 31, 2020

  1. improve README_WASM.md; continue with SC_WebPortIn reply

    - we need to understand how to allocate (and free) the
      memory for OSC replies. is web_reply_func called from
      different threads? Can we just use malloc, or should we
      use rt memory?
    Sciss committed Dec 31, 2020
    Configuration menu
    Copy the full SHA
    761c29a View commit details
    Browse the repository at this point in the history
  2. thought on web_reply_func

    Sciss committed Dec 31, 2020
    Configuration menu
    Copy the full SHA
    7ac6e18 View commit details
    Browse the repository at this point in the history
  3. implement OSC replies

    Sciss committed Dec 31, 2020
    Configuration menu
    Copy the full SHA
    39abd35 View commit details
    Browse the repository at this point in the history

Commits on Jan 1, 2021

  1. audio input works

    - noticed a bug in `NumOutputBuses`
    Sciss committed Jan 1, 2021
    Configuration menu
    Copy the full SHA
    153e963 View commit details
    Browse the repository at this point in the history
  2. typo

    Sciss committed Jan 1, 2021
    Configuration menu
    Copy the full SHA
    0c88d87 View commit details
    Browse the repository at this point in the history
  3. fix bug in several DelayUGens Ctors

    - extraneous constructor argument `int inNumSamples` was causing crashes
    Sciss committed Jan 1, 2021
    Configuration menu
    Copy the full SHA
    8107ca5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    676ccbb View commit details
    Browse the repository at this point in the history
  5. Format with clang-format

    - wasm/configure.sh : use release build type
      (we're still catching exceptions, though)
    Sciss committed Jan 1, 2021
    Configuration menu
    Copy the full SHA
    d5e5154 View commit details
    Browse the repository at this point in the history
  6. clang-format-8 instead of -9

    Sciss committed Jan 1, 2021
    Configuration menu
    Copy the full SHA
    109dbee View commit details
    Browse the repository at this point in the history
  7. fork of nova-tt no longer needed

    - probably the originally missing symbols were due to
      wrong pthread linker settings
    - go back to timblechmann's repo
    Sciss committed Jan 1, 2021
    Configuration menu
    Copy the full SHA
    f781268 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    dab9ab6 View commit details
    Browse the repository at this point in the history
  9. reenable boost assertion (no longer failing)

    - seems the assertion in rbtree_best_fit.hpp
      does hold now
    Sciss committed Jan 1, 2021
    Configuration menu
    Copy the full SHA
    1e1e6fe View commit details
    Browse the repository at this point in the history
  10. remove todo comments from CMakeLists.txt

    - build file seems ok for now
    Sciss committed Jan 1, 2021
    Configuration menu
    Copy the full SHA
    15e1f5c View commit details
    Browse the repository at this point in the history

Commits on Jan 2, 2021

  1. more symmetric OSC interface

    - Module.oscDriver is now a dictionary from
      virtual port number to an object that at least
      defines the property `receive`, a function taking
      two arguments: sender's port, and Uint8Array raw OSC packet.
    Sciss committed Jan 2, 2021
    Configuration menu
    Copy the full SHA
    9f3d9e5 View commit details
    Browse the repository at this point in the history

Commits on Feb 4, 2021

  1. increase static heap size

    - needed to do anything more involving like allocating larger buffers
    Sciss committed Feb 4, 2021
    Configuration menu
    Copy the full SHA
    89c431a View commit details
    Browse the repository at this point in the history