grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.54k stars 319 forks source link

faust2unity not working properly beyond 2.14 #390

Closed tinpark closed 4 years ago

tinpark commented 4 years ago

Hi there, firstly, Faust is an amazing development, thank you. When compiling with version 2.14.4 on my Mojave installation, I get working unity stuff in android, ios, osx -- all perfect. However, when I build with version 2.20, OSX reports that the build was successful but it doesn't work inside Unity. Your online compiler will successfully build a package for windows too, but when inserted into Unity, errors appears on windows that are the same in OSX. Is anyone working on the faust2unity stuff at the moment? Would be great to fix this issue. Here are the errors that appear; it's the GUI stuff that doesn't show up. I had hoped that this was just an OSX issue but it occours on windows 64bit compiles too: Thanks in advance of any repairs you're able to make to faust2unity... as I'd like to move beyond 2.14 to be able to use the 2.20 stuff such as route etc.. Best Martin~

NullReferenceException: Object reference not set to an instance of an object FaustUtilities_fluteSound.FaustPlugin_Editor.OnInspectorGUI () (at Assets/Scripts/FaustUtilities_fluteSound.cs:53) UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:501) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

sletz commented 4 years ago

Can you possibly post the DSP source and generated UNITY files ? Thanks.

tinpark commented 4 years ago

Hello, thank you very much for replying. Here is the DSP code as downloaded from the online IDE: dspFromFaustOnlineCompiler.zip

Here is the compiled version of the DSP code compiled from the online IDE for windows 64, ready to import into Unity via the import package compiledWin64.zip

Here is a compiled version made on my Mojave 10.14.6 using Faust 2.20.2 again ready to be imported into unity via import package: FaustPlugin_osci.unitypackage.zip, made with faust2unity -osx osci.dsp.

Alternatively, if you wish to manually add the scripts and .bundle to the assets directory, here are the sources unpacked. Made with faust2unity -osx -unpacked -source osci.dsp

FaustPlugin_osci_sources.zip

When you have them installed and drop these onto game objects, the FaustPlugin script throws an objection and the GUI that should expose the parameters fails to show up. JSON parsing could be the zone of contention, but I'm not sure.

I hope that's enough information and not overwhelming. Many thanks for your time. Martin~

sletz commented 4 years ago

The error message refers for FaustUtilities_fluteSound but I don't see any FaustUtilities_fluteSound naming in your files (which refer to osci AFAICS). Can you send me the correct code , or the error message tou would get with osci ? Thanks.

sletz commented 4 years ago

Are you able to test a possible fix (https://github.com/grame-cncm/faust/commit/5dfedf8baeef6998ac45849b9069c89b67a191d6) on master-dev branch ? Clone the GitHub repo, then in the faust folder do: make && sudo make install then faust2unity your_dsp_file.dsp and try the result.

tinpark commented 4 years ago

Hi, thanks, I cloned the latest branch and built it. I'm still not getting things to work right in unity sadly. Here's the errors I get with the same GUI issue.

FormatException: Input string was not in a correct format. System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) (at <567df3e0919241ba98db88bec4c6696f>:0) System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <567df3e0919241ba98db88bec4c6696f>:0) System.Int32.Parse (System.String s, System.IFormatProvider provider) (at <567df3e0919241ba98db88bec4c6696f>:0) System.Convert.ToInt32 (System.String value) (at <567df3e0919241ba98db88bec4c6696f>:0) FaustUtilities_osci.FaustUI.fJSONParser (System.String& fJSON, FaustUtilities_osci.FaustUI& faustUI) (at Assets/Scripts/FaustUtilities_osci.cs:381) FaustUtilities_osci.FaustPlugin_Editor.OnEnable () (at Assets/Scripts/FaustUtilities_osci.cs:29)

NullReferenceException: Object reference not set to an instance of an object FaustUtilities_osci.FaustPlugin_Editor.OnInspectorGUI () (at Assets/Scripts/FaustUtilities_osci.cs:53) UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:501) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179) Just in case I've not built things correctly, here's the version that shows up: FAUST Version 2.22.0.

Many thanks for your time.

tinpark commented 4 years ago

Good morning and for reference, just tried with the englishBell model from the IDE, I have the same problem. I export to Unity source. Then on my Mac machine, running the faust2unity script, the plugin builds, but doesn't sit right when imported into unity.

FormatException: Input string was not in a correct format. System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) (at <567df3e0919241ba98db88bec4c6696f>:0) System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <567df3e0919241ba98db88bec4c6696f>:0) System.Int32.Parse (System.String s, System.IFormatProvider provider) (at <567df3e0919241ba98db88bec4c6696f>:0) System.Convert.ToInt32 (System.String value) (at <567df3e0919241ba98db88bec4c6696f>:0) FaustUtilities_englishBell.FaustUI.fJSONParser (System.String& fJSON, FaustUtilities_englishBell.FaustUI& faustUI) (at Assets/Scripts/FaustUtilities_englishBell.cs:381) FaustUtilities_englishBell.FaustPlugin_Editor.OnEnable () (at Assets/Scripts/FaustUtilities_englishBell.cs:29) NullReferenceException: Object reference not set to an instance of an object FaustUtilities_englishBell.FaustPlugin_Editor.OnInspectorGUI () (at Assets/Scripts/FaustUtilities_englishBell.cs:53) UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:501) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179) Unity package as built by my machine and dsp code below: FaustPlugin_englishBell_sources.zip

Thanks again!

sletz commented 4 years ago

Can you explain step by step how do you get this error message ? Thanks.

sletz commented 4 years ago

The C# files parse a JSON string created for the DSP. As some point when changed the JSON format a bit (like "numerical" values correctly defined in JSON, and not as "string" anymore..) and the parser currently fails with the errors you get. So I need to be able to reproduce the error in the first place.

tinpark commented 4 years ago

Sure, and thanks for reply and for being patient:

  1. download the .zip file linked above
  2. make a new unity project
  3. import custom package in Unity and select FaustPlugin_englishBell.unitypackage from the things that get unzipped.
  4. in your Unity scene make a new game object and drop the FaustPlugin_englishBell.cs script onto the game object.
  5. you will immediately see an error show up in the console
  6. hit play, you'll get all of the errors I pasted above.
  7. Check the inspector and you'll see that the parameters that should be exposed are occluded.
  8. NOTE, I have only included a build for OSX in the .zip. But you should get the same errors if you download and import the Unity>Win64 package from Faust IDE.
unityFaustErrors

Finally, here's a link to the unity session that does all of the above, uploading to dropbox now, 38mb: LINK Best wishes Martin~

sletz commented 4 years ago

AFAICS fixed in https://github.com/grame-cncm/faust/commit/a3d5e8e94c8088ddbfae1b00f72266078c7e7310, working OK with some DSP here. Can you test also and report ? Thanks.

tinpark commented 4 years ago

YESSSS! Amazing thanks a lot, this now works! I'm delighted about this, as will the students be. Really appreciate you digging into the problem and persisting to find the solution! Will test on Windows soon as I can. Best Martin~

sletz commented 4 years ago

Coding is 50% of my work, fixing bugs created in the first 50% are the second 50% of my work ((-; Waiting for feedback on Windows before closing the issue.