filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.14k stars 450 forks source link

Unity Editor crash when calling Read of IWaveSource #446

Open Curtis-VL opened 3 years ago

Curtis-VL commented 3 years ago

Hi,

I'm a little stumped as I've seen a bunch of examples with 'in theory' identical code that should work. In a nutshell, the Editor crashes and doesn't provide a great deal of detail in the log beyond this:

0x00007FFC7BC9759E (resampledmo) DllGetClassObject

Code can be found here: https://pastebin.com/0KkrAX69

Crash occures on line 195 at calling '_convertedSource.Read(buffer, 0, buffer.Length)'.

Any thoughts on what I'm doing wrong here? From what I can see I'm using it exactly as the example code I have says, which compiles and runs fine, though that is not a Unity application!

(And yes, I'm aware Untiy isn't 'really' support but should work! Sorry for asking about this!)

escheiermann commented 2 years ago

Hi,

I'm having a similar issue with CSCore and Unity Editor (2020.3.12f). In my project I'm loading the audiofile with:

IWaveSource song = CSCore.Codecs.CodecFactory.Instance.GetCodec("Assets/Music/sample.mp3");

And when I try to write the content of the audioclip to a stream with:

MemoryStream stream = new MemoryStream();
song.WriteToStream(stream);

The editor crashes while in game mode.

I figured out that this has something to do with the mp3 Codec from CSCore. As a workaround I'm currently using .wav files which work perfectly fine with CSCore and Unity.

In this issue on Unity's issuetracker the author has a similar issue and mentions that this crash doesn't reproduce with .NET 3.5.

I hope that someone can look a little bit further into the issue, or give a workaround to use .mp3 files in Unity with CSCore.