Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with mixing simultaneous sources #5

Closed
dannycorts opened this issue Oct 15, 2010 · 4 comments
Closed

Problem with mixing simultaneous sources #5

dannycorts opened this issue Oct 15, 2010 · 4 comments

Comments

@dannycorts
Copy link

Hello, thanks by SW3, I am studing the new version of SW, and i am very happy with SW3.

I have found a problem with mixing simultaneous sources, for example:

            var sequence:ListPerformance = new ListPerformance();
            sequence.addSourceAt(0, new SineSource(new AudioDescriptor(), 0.8, 440));
            sequence.addSourceAt(0, new SineSource(new AudioDescriptor(), 0.8, 660));
            sequence.addSourceAt(0, new SineSource(new AudioDescriptor(), 0.8, 880));
            var source:IAudioSource = new AudioPerformer(sequence, new AudioDescriptor() );
            player.play(source);

The result have some noise, and do not work well, i whish to know how to solve this problem, do i have something wrong in my code?

Thanks by help, :)

@maxl0rd
Copy link
Owner

maxl0rd commented Oct 15, 2010

Hi

You're clipping.

Just turn the gain down in the AudioPerformer with the mixGain property, which sets mixing loss in decibels.

ie audioPerformer.mixGain = -12 ... would let you mix any 4 sources without clipping.

That's a new SW3 feature.

@dannycorts
Copy link
Author

Hey, i found that changing audioPermorfer.mixGain help to solve the problem, but i will like to know if there is a function that calculate the correct value of the mixGain, because it is not the same if the number of mixed notes change.

@maxl0rd
Copy link
Owner

maxl0rd commented Oct 15, 2010

That's not an easy problem to solve generally in real-time. Best to set your mix conservatively or provide a user control.

If you have a final, rendered sample that you want to be amplified to full scale, you can use sample.normalize(), but you can't use that in a real-time signal chain.

@dannycorts
Copy link
Author

Thank you :)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants