Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by barbe63 · Oct 03, 2019 at 02:52 AM · audioeffectsdsp

Chain multiple effects in OnAudioFilterRead

Hello, I'm trying to chain multiple effects in OnAudioFilterRead and i'm having hard time for that, quite hard considering i'm not familiar with dsp processing. Here is part of my code that i'm struggling with.

 void OnAudioFilterRead(float[] data, int channels)
     {      
         if(effects.Count>0)
         {
             for(int j=0; j<effects.Count; j++)
             {
                 switch(effects[j].effectType)
                 {
                     case DSPEffectType.LowPassFilter:
                     case DSPEffectType.HighPassFilter:
                     for (int i = 0; i < data.Length; i = i + channels)
                     {
                         for(int c = 0; c < channels; c++)
                         {
                             if(c==0)
                             {
                                 buffc0[j] = data[i+c];
                                 data[i+c] = (filters[effects[j].id].b0/filters[effects[j].id].a0)*buffc0[j] + (filters[effects[j].id].b1/filters[effects[j].id].a0)*x1c0[j] + (filters[effects[j].id].b2/filters[effects[j].id].a0)*x2c0[j]  + (-filters[effects[j].id].a1/filters[effects[j].id].a0)*y1c0[j] + (-filters[effects[j].id].a2/filters[effects[j].id].a0)*y2c0[j];
                                 x2c0[j] = x1c0[j];
                                 x1c0[j] = buffc0[j];
                                 y2c0[j] = y1c0[j];
                                 y1c0[j] = data[i+c];
                             }
                             else
                             {
                                 buffc1[j] = data[i+c];
                                 data[i+c] = (filters[effects[j].id].b0/filters[effects[j].id].a0)*buffc1[j] + (filters[effects[j].id].b1/filters[effects[j].id].a0)*x1c1[j] + (filters[effects[j].id].b2/filters[effects[j].id].a0)*x2c1[j]  + (-filters[effects[j].id].a1/filters[effects[j].id].a0)*y1c1[j] + (-filters[effects[j].id].a2/filters[effects[j].id].a0)*y2c1[j];
                                 x2c1[j] = x1c1[j];
                                 x1c1[j] = buffc1[j];
                                 y2c1[j] = y1c1[j];
                                 y1c1[j] = data[i+c];
                             }
                         }
                     }
                     break;
                 }
            }   
     }


First i did this code but not using lists for buffc0, x1c0 etc... but i had some crackling like i did something wrong. Then i did those arrays, it sounds better but as soon as i have 3 effects it's not working at all (sound struggling to play). Even 2 of them may have some issues sometimes with maybe performances. Can someone please help me to understand what i'm doing wrong?

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

143 People are following this question.

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

Related Questions

multi Coloured Audio Waveform? 1 Answer

All game audio distorts and desyncs after a few hours 1 Answer

Reverb? Reverb Zones?!?!? 2 Answers

Is there a Unity audio dsp cpu cap and can you change it? 0 Answers

This script opens up an Audio Source but what would I need to do to get it to open up a Resonance Audio Source instead? 0 Answers


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