Search Issue Tracker

Won't Fix

Votes

1

Found in

2018.3.0a1

2018.3.0f2

2019.1.0a1

Issue ID

1113325

Regression

No

[WebGL] "Data too long to fit the audioclip: . X sample(s) discarded" on "audioClip.setData"

WebGL

-

Reproduction steps:

1. Open "megalon.zip" project and download "2018_12_27_14_05_26_654.json"
2. Build and Run project for WebGL
3. Drag "2018_12_27_14_05_26_654.json" into the appropriate area
4. "Play"
5. Access the Developers Console
6. Notice an error: "Data too long to fit the audioclip: . 27495 sample(s) discarded"

Expected Result: No errors appear
Actual Result: Error appears every time the audio clip is player

Reproduced with: 2019.2.0a1, 2019.4.18f1, 2018.3.3f1, 2017.4.18f1

  1. Resolution Note (2019.2.X):

    Desktop Team Management has evaluated this issue and determined that it does not meet our current bug severity threshold. If you would like your issue to be reviewed again, please re-submit your bug

Comments (5)

  1. ZealousAppex

    Oct 21, 2024 02:22

    Same issue :(

  2. in0finite

    Oct 18, 2024 18:07

    I am having the same issue.

    It turns out that whenever you call `AudioClip.SetData()`, it creates a new `AudioBuffer` in Javascript, instead of updating existing one. This also reduces size of AudioClip to the size of passed array, so next time you try to set data with larger array, it will discard it.

    The solution that worked for me was to always use buffer of the same size, the size that you initially set when creating AudioClip.

    So if AudioClip has 48000 samples, always SetData() with 48000 array size. This means you have to maintain this array manually, instead of sending small chunks of data into AudioClip.

  3. Der-Kleine

    Oct 19, 2023 10:35

    I may have found a solution to the problem: When you call AudioClip.Create, multiply the lengthSamples with the sample rate of the file you're creating from divided by 44100.

    so instead of setting

    lengthSamples = someValue

    set

    lengthSamples = (int)(someValue * (audioFile.sampleRate / 44100f))

  4. chrisMary

    Jan 07, 2022 05:59

    I have the same problem

  5. oxovira

    Aug 10, 2021 12:32

    Same problem

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.