# Problem duplicating sound sources

**URL:** https://qa.fmod.com/t/problem-duplicating-sound-sources/12140
**Category:** Unity
**Created:** [November 6, 2015, 5:13pm UTC](https://qa.fmod.com/t/problem-duplicating-sound-sources/12140 "2015-11-06T17:13:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Pelle](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/pelle/32/79_2.png) [@Pelle](https://qa.fmod.com/u/Pelle)
#### Post date: [November 6, 2015, 5:13pm UTC](https://qa.fmod.com/t/problem-duplicating-sound-sources/12140/1 "2015-11-06T17:13:37Z")

</div>

Hi all,  
I’m tryng to reproduce the effect of a sound coming from another room. One of my task was to duplicate a sound coming from an adiacent room and append it to the door to simulate the occlusion of the wall. I have impemented my own class soundSource that let me handle some features that i needed for the game, like applyng filters, setting parameters and some other useful stuff.  
On the door i have attached this script:

```
void Start ()
{
	StartCoroutine ("test");
}

IEnumerator test ()
{
	appendSoundSource (ssDoor);
	yield return new WaitForSeconds (1.1f);
	removeSoundSource (ssDoor);
}

public void appendSoundSource (FMOD_SoundSource originalSS)
{
	ssDoor = gameObject.AddComponent<FMOD_SoundSource> ();
	ssDoor.duplicateFrom (originalSS);
	ssDoor.applyFilter (1, 20000, 20);
	ssDoor.start ();
}

public void removeSoundSource (FMOD_SoundSource ssDoor)
{
	PVPair pvp = new PVPair ("EndTrigger", 1);
	ssDoor.setParameterValue (pvp);
}

```

For testing purpose i’ve created a coroutine that append the soundSource and then call remooveSoundSource that let the event go out of the loop region. Here’s a screenshoot of my fmod project:

![enter image description here](http://i67.tinypic.com/m7yg3t.png)

My problem is that if i remove the yield instruction everything works as i expected to, but if i keep that line it does not. It looks strange because unity doesn’t give me errors, and it seems that the parameter “EndTrigger” is modified correctly, but i can’t figure out why it doesn’t go out of the loop region.

I hope that i have been clear enough and on the other hand also synthetic enough  
Does somebody have any tips to solve my problem?

Thanks

---

<div class="post-metadata">

### Author: ![Pelle](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/pelle/32/79_2.png) [@Pelle](https://qa.fmod.com/u/Pelle)
#### Post date: [November 9, 2015, 4:39pm UTC](https://qa.fmod.com/t/problem-duplicating-sound-sources/12140/2 "2015-11-09T16:39:48Z")

</div>

Resolved!  
I had the method init() that created an instance of the event. This metod was called for initialization in the Start() of the SoundSource i created, and also in the start() function i created to let the event play (myEvent.start()). The thing i didn’t expect was that the method start() was called before the initialization metod Start() and so my init() created an event that was dereferentiated after the Start() was called.  
I only had to reorganize the code and everything worked!

It’s a really specific case, but i hope this could help somebody…
