Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by diemo · Jan 17, 2012 at 02:28 PM · audiosoundfilterc

Procedural native audio synthesis with OnAudioFilterRead

I'm trying to use the Unity3.5 audio buffer access to integrate a synthesis engine in C to produce audio.
When I try to do it in the most efficient way, i.e. passing the audio buffer pointer, I get crashes in what looks like FMOD memory management.

Maybe I'm not allowed to pass arrays by reference like that, since the (hoped for) memory pinning seems to invoke some runtime code that is not allowed in the audio thread or so? I only have shaky knowledge about the Mono C# to C interface, p/invoke, marshaling, and all that.

the C# audio filter script on the (empty) audio source:

 [DllImport ("synth-lib")]
 private static extern void synth (IntPtr self, int nsamp, float[] data, int channels);
     
 void OnAudioFilterRead (float[] data, int channels)  {
         synth(impl_, data.Length, data, channels); 
 }

the C code prototype:

  void synth (mysynth_t *self, int nsamp, float *data, int channels); 


the crash log:

 Thread 0:  Dispatch queue: com.apple.main-thread
 4   libmono.0.dylib                   0x02845278 mono_handle_native_sigsegv + 327
 5   libSystem.B.dylib                 0x93c6505b _sigtramp + 43
 6   ???                               0xffffffff 0 + 4294967295
 7   fmod_editor.dylib                 0x02ac904e 0x2ac7000 + 8270
 8   fmod_editor.dylib                 0x02b2b249 FMOD::SystemI::getMemoryUsedImpl(FMOD::MemoryTracker*) + 2181
 9   fmod_editor.dylib                 0x02b28db1 FMOD::System::lockDSP() + 39
 10  com.unity3d.UnityEditor3.x        0x006514a7 AudioManager::ProcessScheduledSources() + 23
 11  com.unity3d.UnityEditor3.x        0x00659ea3 AudioManager::Update() + 51
 
 Thread 16 Crashed:
 0   libSystem.B.dylib                 0x93c6c0ee __semwait_signal_nocancel + 10
 6   libmono.0.dylib                   0x027be019 mono_sigsegv_signal_handler + 498
 7   libSystem.B.dylib                 0x93c6505b _sigtramp + 43
 8   ???                               0xffffffff 0 + 4294967295
 9   libmono.0.dylib                   0x02986483 g_log + 41
 10  libmono.0.dylib                   0x028d5946 mono_array_to_lparray + 164
 11  ???                               0x08bd400c 0 + 146620428
 12  ???                               0x38641a78 0 + 946084472
 13  ???                               0x3864161f 0 + 946083359
 14  ???                               0x3864193e 0 + 946084158
 15  libmono.0.dylib                   0x027c5140 mono_jit_runtime_invoke + 1149
 16  libmono.0.dylib                   0x0290d170 mono_runtime_invoke + 133
 17  com.unity3d.UnityEditor3.x        0x00678933 AudioCustomFilter::readCallback(FMOD_DSP_STATE*, float*, float*, unsigned int, int, int) + 291
 18  fmod_editor.dylib                 0x02b0483b FMOD::DSPConnection::getInput(FMOD::DSP**) + 18131
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image FatWednesday · Nov 20, 2013 at 02:28 PM 0
Share

Did you ever solve this issue? Although not working with procedural audio, we are seeing a large number of crashes at various points in our game to do with unity re-gaining focus on iOS devices, all the crash logs seem to call that get$$anonymous$$emoryUsedImpl method right before they then abort and die.

Been trying to solve this for a few days now and we're getting nowhere.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by drudiverse · Dec 10, 2014 at 11:48 PM

Have to pass the onaudiofilterread function a float array of same length as audiobuffer settings.

See reference for example of the loop that has to be in the function, i dont think that above code would work on it. it's a tricky code it needs just 1-2 loops and if functions.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why my sound it's not attaching to my Flashlight 2 Answers

Stop another sound from another script? 1 Answer

Get acess and switch to many audio source in a single Object HELP!! 1 Answer

Music works but not when accessed by another script in JavaScript 1 Answer

Play from a variety of sounds? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges