vulcu / dahlia

Waveshaping Polyphonic Synthesis for the Heavy Compiler Collection
GNU General Public License v3.0
4 stars 0 forks source link

Javascript/WebAudio generation requires editing HVCC python source #15

Closed vulcu closed 7 months ago

vulcu commented 10 months ago

Note: this may not be true for all systems/OS, but is true on Windows under the following conditions:

  1. HVCC is run in a virtual environment. The virtual environment is dedicated to the Dahlia project only, and only contains HVCC and its dependent packages.
  2. Only a single Python instance is installed on the system. The PATH contains only a single .../Python/Python<ver> and .../Python/Python<ver>/Scripts directory entry.
  3. The system Python version is 3.12

If HVCC returns Error c2js: [WinError 193] %1 is not a valid Win32 application when running source ./dahlia.sh js, the existing documentation suggests a hotfix by opening the Python script c2js.py located in dahlia/.venv/Lib/site-packages/hvcc/generators/c2js/. Find the three instances where subprocess.check_output() is called in that script, and append shell=True as a second argument to all of those calls. Example:

# First instance, around Line 101 in HVCC v0.9
subprocess.check_output(cmd, shell=True)

# Second instance, around Line 108 in HVCC v0.9
subprocess.check_output(cmd, shell=True)

# First instance, around Line 140 in HVCC v0.9
subprocess.check_output(  # WASM
    cmd + [  # type: ignore
        "-s", "WASM=1",
        "-s", f"EXPORT_NAME='{output_name}_Module'",
        "-o", wasm_js_path
    ], shell=True)

It may be possible to debug the issue further by adding a traceback call in an except block following the first call to subprocess.check_output(), as follows:

# First call to 'subprocess.check_output()', around Line 101 in HVCC v0.9
try:
    subprocess.check_output(cmd)  # run emscripten
except Exception:
    print(traceback.format_exc())
    return
dromer commented 10 months ago

Happy to accept a PR for this :)

vulcu commented 10 months ago

Done! https://github.com/Wasted-Audio/hvcc/pull/151

I think I found the root cause, so we can avoid using 'shell=true'