sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.7k stars 639 forks source link

Echo effect in release build makes the system unstable when disabling it before it is used #484

Open terraslate opened 10 years ago

terraslate commented 10 years ago

When i create 60 submixes in succession on my system (on the same thread in a loop) and attach 4 effects in this order, Reverb, Echo, Limiter and then my custom Effect i get odd behaviour in release build by calling EnableEcho = false [which translates to _mix.DisableEffect(1)] as below. Oddly if i don't call it and it is left as the default upon creation (which is enabled) then each mix is created extremely quickly.

Userstory: Loop start creating 1 of 60 submixvoice instances, add 4 effects in the chain as above, 5 SourceVoice are associated with it then continue loop to number 2 and repeat.

Each effect is 2 channel, 48000 as is each submixvoice and the master as well.

With this issue each submix takes very long to create so by the 58th its taking 5 seconds to create and the 59th and 60th may come along in the next minute. Thereafter the system is far more likely to crash.

This issue DOES NOT occur in debug builds of my code but it does occur in release builds yet the execution path is identical.

  public bool EnableEcho
    {
        get
        {
            return _mix.IsEffectEnabled(1);
        }
        set
        {
            if (value)
            {
                _mix.EnableEffect(1);
            }
            else
            {
                _mix.DisableEffect(1);
            }
        }
    }
ArtiomCiumac commented 10 years ago

Typically, .NET applications may have different behavior in Debug/Release builds when static fields are used (due to different behavior when no explicit static constructor is defined). Also it may be a audio driver issue (less likely).

Do you have a sample project, a code fragment or an unit test that reproduces the issue so I can test it from my side?

terraslate commented 10 years ago

Hi. I'll send you tomorrow. It's midnight here ☺

Many thanks for the quick replies btw. Project is awesome.

Sent from Samsung Mobile

-------- Original message --------
From: Artiom Ciumac
Date:24/09/2014 11:59 PM (GMT+08:00)
To: sharpdx/SharpDX
Cc: terraslate
Subject: Re: [SharpDX] Echo effect in release build makes the system unstable when disabling it before it is used (#484)

Typically, .NET applications may have different behavior in Debug/Release builds when static fields are used (due to different behavior when no explicit static constructor is defined). Also it may be a audio driver issue (less likely).

Do you have a sample project, a code fragment or an unit test that reproduces the issue so I can test it from my side?


Reply to this email directly or view it on GitHub: https://github.com/sharpdx/SharpDX/issues/484#issuecomment-56692904

terraslate commented 10 years ago

Hi Sorry for the delay. Please find two zips here https://www.dropbox.com/sh/i5uxa7gjelsakyr/AAC6wxk8iA4j442sbJs1Q0-xa?dl=0 Note: I have a soundblaster z Do not concern yourself with the saving to disk part yet, i am working on that and am just toying with different architectures.

In the loop to create new UserMix on my machine if i set it to 60 in release mode and have echo enabled (look at UserMix constructor) then i get the slowdown issue. I noticed i didn't get this issue on my work machine where there is not a soundblaster z, but some cheap on board chip. The other interesting thing is if i set the loop to create 1 mix only i rarely ever hear anything come from the mastervoice speakers. If i set to 2 or more its more than 95% guaranteed to make it to the speakers. Finally, the mastervoice issue where i cannot route to nowhere, you'll note in UserMix constructor that i have to set the masteringvoice on the submix regardless since passing in no VoiceDescriptor results in an error and so i cannot route to nowhere (i tried passing in no parameters that fails, null (still routes to master), and an empty array (that fails)). The code zip file does not include the sharpx binaries and i removed every large file i could find that wasn't in my code (except for the naudio lib) so i hope the project can still load for you. Thanks for your efforts. Kind regards Jason P.S one final thing. Do you know if in my code any part of it runs in the hardware of the soundblaster z? i'm on windows 7 pro 64 bit. Is XAudio2 supposed to use the sound card to do the mixing and effects?

Date: Thu, 25 Sep 2014 00:05:53 +0800 Subject: Re: [SharpDX] Echo effect in release build makes the system unstable when disabling it before it is used (#484) From: terraslate@hotmail.com To: reply@reply.github.com

Hi. I'll send you tomorrow. It's midnight here ☺

Many thanks for the quick replies btw. Project is awesome.

Sent from Samsung Mobile

-------- Original message -------- From: Artiom Ciumac Date:24/09/2014 11:59 PM (GMT+08:00) To: sharpdx/SharpDX Cc: terraslate Subject: Re: [SharpDX] Echo effect in release build makes the system unstable when disabling it before it is used (#484)

Typically, .NET applications may have different behavior in Debug/Release builds when static fields are used (due to different behavior when no explicit static constructor is defined). Also it may be a audio driver issue (less likely).

Do you have a sample project, a code fragment or an unit test that reproduces the issue so I can test it from my side?

Reply to this email directly or view it on GitHub.