Search Unity

Amplitude for WebGL

Discussion in 'Assets and Asset Store' started by Crazy-Minnow-Studio, Dec 7, 2017.

  1. Jeps66

    Jeps66

    Joined:
    Jun 23, 2015
    Posts:
    9
    Thanks for your quick reply. Your solution is very easy to implement and after setting the boost everything works fine in the editor. The audio source is removed from the Salsa2D component, and audio and Salsa animation plays. So I thought I was done, but unfortunately I still don't get the Salsa animations in WebGL (tested in Edge and Chrome). I left all Amplitude settings at default except boost which is set at 0.4.
    So I have to ask for your input again. Before your fix I could understand why it didn't work, but now everything is set according to the manual and I'm puzzled why the WebGL doesn't work.
    Again thanks for your assistance.

    Jeppe
     
  2. Jeps66

    Jeps66

    Joined:
    Jun 23, 2015
    Posts:
    9
    Just found out some more. It's only the first time a dialogue is played that the Salsa animations don't play in WebGL. If I play the dialogue again the animations are there.
     
    Crazy-Minnow-Studio likes this.
  3. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    That's helpful, that means it's probably an issue with loading and attempting to play the audio file before it's ready. Keep in mind that Amplitude is 100% using your web browsers underlying audio framework (Web Audio API), and not the FMOD framework Unity uses on all other platforms, so the rules are a bit different. Web Audio API will typically output errors about being unable to find the analyzer if you try to play a clip before it's fully loaded. Are you getting errors in the javascript console in your browsers developer tools?
     
  4. Jeps66

    Jeps66

    Joined:
    Jun 23, 2015
    Posts:
    9
    Yes, that is exactly the error I'm getting in the console. "Could not find analyzer (-6536)". It appears thousands of times while the audio is playing the first time. Even the interruption of starting the JS console (or activating another tab) and going back in game will stop the errors and the animations start working.
    I'm not sure how to get this fixed. I'm starting the audio with the sequencer Audio command in Dialogue System (as you suggested), so I don't have control over the loadstate of the AudioClip (if that is what is needed). I tried changing the import settings (the Load type) on the Audio Clip but nothing I tried made any difference.
    I hope you have some ideas. I really appreciate your help.

    Jeppe
     
  5. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Good, now we know exactly what the problem is, we definitely need control over the load state. This could probably be solved by leveraging our WebAudio URL's add-on, but it would likely require some custom integration to hook that process into the Audio(clip) sequencer command source code. Give us some time to research and contemplate an easier more universal way to solve this. In the meantime, please send your Amplitude invoice number to assetsupport@crazyminnow.com.

    Thanks,
    Michael
     
  6. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    For anyone else using SALSA, Amplitude, and Dialogue System on WebGL, the solution is to use Amplitude v1.2.0 (submitted to the Asset Store on 05/23/2019) and the Dialogue System Audio(clip) sequence command to direct audio clip changes directly to the AudioSource instead of the SALSA(clip) sequence command.
     
  7. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    We have updated and published AmplitudeSALSA for SALSA LipSync v2. This allows SALSA LipSync v2 to produce lip-synchronization on WebGL platforms.

    NOTE: The minimum requirement for using this updated Amplitude add-on with SALSA LipSync v2 is Unity version 2017.2+.

    For information, please see this blog post.
     
    wetcircuit likes this.
  8. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    In a tutorial video you mention that Amplitude does not work in Safari…. Is that still true?
     
  9. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    The last time we tested Safari was in May. I've looked through Apples Safari release notes and don't see anything about Web Audio API, so I suspect it's the same. It's currently supported in Google Chrome, Firefox, Opera, Microsoft Edge, and Vivaldi, but not supported in IE or Safari.
     
    wetcircuit likes this.
  10. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    Well that explains why I never got it to work. :rolleyes:

    (WebGL is all over the place)
     
    Crazy-Minnow-Studio likes this.
  11. sergiosoba

    sergiosoba

    Joined:
    Apr 28, 2017
    Posts:
    8
    Hi,

    My target is WebGL and I know that I should use SALSA with Amplitude. If I also want to compile for Android, should I make any modifications to the project?
     
  12. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Hi sergiosoba,

    Amplitude for WebGL is only compatible with WebGL, and only necessary to make SALSA work on WebGL.

    Michael
     
  13. sergiosoba

    sergiosoba

    Joined:
    Apr 28, 2017
    Posts:
    8
    If I compile to Android too, gives Amplitude problems or I have to modify it?

    I wanna compile en both.
     
  14. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    The recommended approach is to build to your other platforms without the Amplitude asset since it was not designed for any other platform.
     
    sergiosoba likes this.
  15. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
  16. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Hi Nathan,

    This is not something we plan to implement. The issue on WebGL is that it's the only Unity platform that is using a completely different audio framework, a non-feature complete wrapper for Web Audio API. Although Web Audio API is rather feature rich, much of it was not implemented in Unity's wrapper. Additionally, audio processing is not closely related to microphone handling in Web Audio API.

    Michael
     
  17. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Ok, thanks for the quick response, Michael

    That's a bummer but I get your standpoint.

    Nathan
     
  18. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Hi Michael,

    would you be able to expand on the items that are missing for you to consider WebGL platform support for audio to be "feature complete"?

    We would use the same backend on WebGL if that was possible, but technical limitations of the web are preventing that from being possible. The main reasons for not using the existing FMOD library backend on WebGL is due to JavaScript/Web Audio not supporting realtime priority on mixing audio, and the large added download size that including audio decoders in .wasm distributables would incur.

    Though your post suggests that you are placing the blame on Unity, rather than to limitations of Web Audio itself. If so, I'd love to hear about the missing items in our audio implementation that are preventing you from achieving your goal.

    Though I am a bit confused, since in https://forum.unity.com/threads/amplitude-for-webgl.507835/page-2#post-4544344 you state that you are not using Unity's audio backend anyways, but go directly to Web Audio instead? Does that not allow you to sidestep any limitations that Unity has?
     
  19. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Hi jukka_j,

    I don't have my source in front of me so I'm working from memory, but Web Audio API can replicate the FMOD GetSpectrum and GetOutputData methods using analyzers, but the Unity wrapper doesn't implement this capability. This is the only reason Amplitude for WebGL was created, to expose this capability in the underlying Web Audio API using a native JavaScript library to pass the output back to Unity. We are working directly against the browsers underlying Web Audio API implementation, but the clunky bit in our implementation is we haven't been able to find a great method of identifying a clip/source using anything other than clip length after the Unity build process. This works well enough for most of our SALSA LipSync customers who are using Amplitude to extend SALSA LipSync to WebGL because dialogue audio clips are reliably different lengths. However, as we've seen some customers wanting to use Amplitude for music, this method quickly reveals it's limitations.

    SALSA LipSync can also work with real-time microphone input, but we don't support this on WebGL. I don't believe Unity's wrapper implements Web Audio API's microphone handling either, and bypassing to work directly with the browsers implementation is another can of worms that our small team doesn't have the resources to cost effectively address.

    Michael
     
  20. darsf

    darsf

    Joined:
    Jul 26, 2018
    Posts:
    1
    Hi @wetcircuit ,
    Did you get to fix it? If yes then would you kindly share? Thanks, SD
     
  21. delexaet

    delexaet

    Joined:
    Apr 14, 2016
    Posts:
    39
    I've read a review of amplitude on asset store saying it is not working on Unity 2021. Is this true?
     
  22. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Correct, we also state this at the top of the sales text on the store page. Unity made some underlying changes in 2021 that are incompatible with Amplitude. We don't have a work around yet.
     
  23. delexaet

    delexaet

    Joined:
    Apr 14, 2016
    Posts:
    39
    Ok thank you, also just wondering is there any basic ETA on when Safari/IE support will be available? mainly Safari.
     
  24. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Unfortunately we have no control over this. The last time I looked, Safari did not support the underlying Web Audio API methods Amplitude uses to make this work.

    Michael
     
  25. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    A new update of Amplitude for WebGL (version 1.2.2) was just submitted to the Asset Store.
    Unity 2021+ is now supported!

    This update includes the following:
    • Chg - Dual builds added to address WEBAudio framework changes. Legacy build designed for Unity 2019.4.34f1 through 2020.3.12f1. Modern build designed for Unity 2020.3.25f1 through 2021+.
    • Fix - Replaced all deprecated references to Pointer_stringify with UTF8ToString.
    • Fix - Fixed a bug in an analyzers index reference.
     
    Last edited: Jan 8, 2022
  26. A567W

    A567W

    Joined:
    Jan 4, 2018
    Posts:
    5
    The Amplitude for WebGL (version 1.2.2) sample did not work in Unity 2021.2.8f1.
    The Amplitude for WebGL (version 1.2.2) sample worked in Unity 2019.
    Does the usage change with Unity2021?
     
  27. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Hi A567W,

    Amplitude for WebGL build version 1.2.2 has been tested in Unity 2021.2.8f1, the demo scene works as intended.
    • Are you getting errors in the browser console?
    • Are you using the default Amplitude demo scene?
    • Is your web server setup to host your WebGL project correctly?
    Michael
     
  28. A567W

    A567W

    Joined:
    Jan 4, 2018
    Posts:
    5
    I tested it in the following environment.
    • Are you getting errors in the browser console?
    _PKG.loader.js:1 The JavaScript function 'Pointer_stringify(ptrToSomeCString)' is obsoleted and will be removed in a future Unity version. Please call 'UTF8ToString(ptrToSomeCString)' instead.​

    • Are you using the default Amplitude demo scene?
    AmplitudeSamples.unity​

    • Is your web server setup to host your WebGL project correctly?
    Google Chrome Local Web Server​
     
  29. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    That's helpful thanks!
    • There are no references to [Pointer_stringify] in version 1.2.2, so it sounds like you are still using an old build. Maybe try a new test project and be sure you are importing 1.2.2 from the asset store.
    • Google Chrome Local Web Server - If you mean viewing the files directly from the browser, this will likely result in security, permission, and/or CORS issues. Be sure you are testing with a proper web hosting environment of your choice.
    Michael
     
  30. A567W

    A567W

    Joined:
    Jan 4, 2018
    Posts:
    5
    Thank you
    It was fixed after re-downloading with Unity2021.
    It seems that it was bad to download it with Unity 2019 and then upgrade to Unity 2021.
     
  31. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    There are two builds included in 1.2.2 to address WEBAudio framework changes. Legacy build designed for Unity 2019.4.34f1 through 2020.3.12f1. Modern build designed for Unity 2020.3.25f1 through 2021+. You will only get the 2020.3.25f1 build if you importing using 2020.3.25f1 or newer. If you upgrade a project, it will require that you re-import to get the alternate build.
     
  32. A567W

    A567W

    Joined:
    Jan 4, 2018
    Posts:
    5
    It worked on Safari, but is Safari not supported?
     
  33. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    We have been investigating Safari again with the newest build. So far, it is not working on our test setup. If you've got it working, we'd love to know more about your setup. Send an email to assetsupport@crazyminnow.com with as much detail as you can offer regarding your setup.

    Thanks,
    Michael
     
  34. A567W

    A567W

    Joined:
    Jan 4, 2018
    Posts:
    5
    The test environment is as follows.

    Unity
    Unity 2022.1.0b2

    Mac - Safari
    Safari Version 15.2.
     
    Crazy-Minnow-Studio likes this.
  35. floatingfehrsen

    floatingfehrsen

    Joined:
    May 15, 2020
    Posts:
    2
    I see this thread was started with someone getting thousands of "Could not find analyzer" errors in the web console but I can't see how it was solved. The animation works find in the editor but not at all in WebGL.

    Environment is
    Unity 19.4.35f1,
    Amplitude 1.2.2,
    Salsa 2.5.4 and
    amplitudesalsa_2_0_0
    Chrome Version 98.0.4758.82

    Is there someone from Crazy Minnow who can help, I'll be very grateful?
     
    Last edited: Feb 17, 2022
    jvien likes this.
  36. r31ack

    r31ack

    Joined:
    Mar 24, 2022
    Posts:
    4
    Hi I have two questions about your assets. I downloaded your assets mainly to use the amplitued.average function. (I used a translator, so please forgive the awkward explanation.)

    1. Is it okay to use amplitued.average on other platforms (Android & iOS) other than WebGL?
    2. When it is executed using the _amplitued.audioSource.PlayOneShot(AudioClip) function, the average value is 0, which is very frustrating. (This problem was circumvented and solved.)
     
  37. K_Kuriyama

    K_Kuriyama

    Joined:
    Jul 4, 2020
    Posts:
    66
    @Crazy-Minnow-Studio

    Hello,
    It worked on Unity2021.2.14 by using Amplitude 1.2.2, but it didn't work on 2021.2.16, 2021.2.17.
    (All the acquired data will be 0.)
    Is it possible to respond?
     
    Last edited: Apr 26, 2022
  38. jvien

    jvien

    Joined:
    Apr 6, 2022
    Posts:
    8
    I have the exact same issue as floatingfehrsen and I'm using the same Salsa/Amplitude/AmplitudeSalsa versions.

    These are the unity versions I've tested the Amplitude example scene with the outcomes:

    Unity 2019.4.28f1 - Works
    Unity 2020.4.26f1 - Could not find analyzer
    Unity 2021.2.14f1 - Could not find analyzer
     
  39. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Hello, our forum notifications were not working for a long period of time and we missed these questions. Unity has been changing things in their builds and apparently broke something again. We will look into this and see if we can find a solution.

    D.
     
  40. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Hello, did you happen to upgrade your Unity from 2019.LTS to 2020? If so, there is a different version of Amplitude necessary for the 2020.3.25+. (And apparently there could be a change in 2021.2.16 that breaks it yet again.) Please remove it from your 2020.4 version and redownload to get the proper version. The build you get is determined by Unity and the version you are running when you download it.

    D.
     
  41. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Sorry for the late response, our forum notifications were not working for quite some time.
    Sorry this does not work on Android and iOS, it is only for WebGL. And it looks like you resolved problem #2.

    D.
     
  42. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Sorry for the late reply, we were not receiving forum notifications from Unity for some time.
    Generally speaking, these errors are due to the incorrect version of Amplitude being installed after a Unity upgrade. For example, Amplitude installed, Unity upgraded, Amplitude not at the correct version. It will be necessary to remove Amplitude (suggested) and then install it again via the AssetStore window, which should get you the correct version for your Unity version.

    D.
     
    K_Kuriyama likes this.
  43. jvien

    jvien

    Joined:
    Apr 6, 2022
    Posts:
    8
    That seems to be the case yes, seems to be working for 2020.3.26f1 now. The Amplitude readme also still refers to 1.2.1 version. Thanks!
     
  44. G3nko0

    G3nko0

    Joined:
    Oct 1, 2016
    Posts:
    12
    Can I get AudioClip.length on WebGL with Amplitude?

    Is it a valid formula?
    Duration (seconds)= Samples Per Frame ⋅ Total Frames (samples)Sample Rate (samples/second)
     
  45. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Hello @Ryabkin, you should be able to access the AudioClip via Amplitude's reference to the AudioSource.

    Code (CSharp):
    1. Amplitude.audioSource
    Hope that helps,
    Darrin
     
  46. easypeet

    easypeet

    Joined:
    Sep 25, 2017
    Posts:
    3
  47. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Hi,

    Please send your Amplitude invoice number to assetsupport@crazyminnow.com, along with a more detailed description of what "breaks again" means such as console errors or symptoms and we're happy to look into it.

    Thanks,
    Michael
     
  48. easypeet

    easypeet

    Joined:
    Sep 25, 2017
    Posts:
    3
    Alright, just sent you an email :)
     
  49. masai2k

    masai2k

    Joined:
    Mar 2, 2013
    Posts:
    45
    Hi,
    I need to use Salsa with RT-Voice in WebGL, producing a Text To Speech audio with google. In the editor all is ok (using salsa with amplitude). But online I hear the audio file but the avatar's lips don't move.
    I think the problem is that I create the audio in real time with Speak method of Salsa, and Amplitude can't analyze audio in streaming. Is it correct? And how to solve this problem??

    Thanks
    Massimo
     
  50. Crazy-Minnow-Studio

    Crazy-Minnow-Studio

    Joined:
    Mar 22, 2014
    Posts:
    1,399
    Hi Massimo,

    Please sent your SALSA and Amplitude invoices to assetsupport@crazyminnow.com, along with a very description of what you are trying to do, any errors you’re seeing, and what you’ve done to try to resolve the issue. I’m confused about why you are using RT-Voice and Google to produce text-to-speech as it seems redundant. My initial assumption is that you may not be waiting for the produced audio to be in the ready state. The audio can play in this state, but it’s data can’t be analyzed in this state.

    You can read about one way of handling streaming audio here.
    https://crazyminnowstudio.com/docs/amplitude/addons/webaudiourls/

    Michael