# How to change the pitch of the same sound file to play in multi-channel？

**URL:** <https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514>\
**Category:** FMOD Engine\
**Tags:** unity, cpp\
**Created:** [August 2, 2021, 1:00pm UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514 "2021-08-02T13:00:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![longjin](https://avatars.discourse-cdn.com/v4/letter/l/46a35a/32.png) [@longjin](https://qa.fmod.com/u/longjin)\
**Post date:** [August 2, 2021, 1:00pm UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/1 "2021-08-02T13:00:29Z")

</div>

Under the test, only change the pitch to achieve some note sound effects. When playing, it will only be played in the same channel. Playing a note sound effect will replace the last played note sound effect, which will lead to broken sound. How to solve this problem? Try to call this interface: channelcontrol:: isplay. It is found that the isplaying state of the channel is false. It is possible to be true only when playing other different sound files.

---

<div class="post-metadata">

**Author:** ![Alcibiade](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alcibiade/32/4284_2.png) [@Alcibiade](https://qa.fmod.com/u/Alcibiade)\
**Post date:** [August 2, 2021, 8:29pm UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/2 "2021-08-02T20:29:00Z")

</div>

Hi, a screenshot of your code will make it way clearer for someone to answer.

---

<div class="post-metadata">

**Author:** ![longjin](https://avatars.discourse-cdn.com/v4/letter/l/46a35a/32.png) [@longjin](https://qa.fmod.com/u/longjin)\
**Post date:** [August 3, 2021, 1:19am UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/4 "2021-08-03T01:19:09Z")

</div>

ISound\* FmodSoundSystem::playSound3DControl(const FixedString &path, const SoundCreateInfo3D& createInfo, float pitch)  
{  
FMOD::Sound\* pSound = getTriggerSoundResource(path, ST\_3D, createInfo.isloop);  
FmodSound\* pSoundObj = NULL;

```
	if( pSound )
	{
		FMOD::Channel* pChannel = playSound(pSound, false, createInfo.volume, createInfo.isloop);
		FMOD::DSP* firstDSP = NULL;
		FMOD::DSP* secondDSP = NULL;

		if (pitch != 1.0f) {
			float fPitch = pitch, sPitch = 0.0f;
			if(pitch > 2.0f || pitch < 0.5f) {
				if(pitch > 2.0f) {
					fPitch = 2.0f;
					sPitch = pitch/2.0f;
				}
				if(pitch < 0.5f) {
					fPitch = 0.5f;
					sPitch = pitch/0.5f;
				}
			}
			m_pFmodSystem->lockDSP();
			FMOD_RESULT result = m_pFmodSystem->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT, &firstDSP);
			if (result == FMOD_OK) {
				firstDSP->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH, fPitch);
				pChannel->addDSP(0, firstDSP);
			} else {
				firstDSP = NULL;
			}

			if(pitch > 2.0f || pitch < 0.5f) {
				FMOD_RESULT result = m_pFmodSystem->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT, &secondDSP);
				if (result == FMOD_OK) {
					secondDSP->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH, sPitch);
					pChannel->addDSP(0, secondDSP);
				} else {
					secondDSP = NULL;
				}
			}
			m_pFmodSystem->unlockDSP();
		}
		
		pChannel->set3DMinMaxDistance(createInfo.mindistance, 10000.0f*100.0f);
		pChannel->set3DAttributes((FMOD_VECTOR*)&createInfo.pos, NULL);
		pSoundObj = new FmodSound(pChannel, firstDSP, secondDSP);
        pSoundObj->setSystem(this);
	}

	return pSoundObj;

```

}

---

<div class="post-metadata">

**Author:** ![longjin](https://avatars.discourse-cdn.com/v4/letter/l/46a35a/32.png) [@longjin](https://qa.fmod.com/u/longjin)\
**Post date:** [August 3, 2021, 1:49am UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/5 "2021-08-03T01:49:22Z")

</div>

![3](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/6/6f383fa366b26c2ab60403e81aff4b9db5ec57fb.png)

---

<div class="post-metadata">

**Author:** ![longjin](https://avatars.discourse-cdn.com/v4/letter/l/46a35a/32.png) [@longjin](https://qa.fmod.com/u/longjin)\
**Post date:** [August 3, 2021, 1:50am UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/6 "2021-08-03T01:50:05Z")

</div>

![30](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/3/361a1119586ded35b659ed889199460035677a42.png)

---

<div class="post-metadata">

**Author:** ![longjin](https://avatars.discourse-cdn.com/v4/letter/l/46a35a/32.png) [@longjin](https://qa.fmod.com/u/longjin)\
**Post date:** [August 3, 2021, 1:55am UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/7 "2021-08-03T01:55:04Z")

</div>

The sound file path here is the same, and the pitch is different, but the assigned channels are indeed the same，channel id is 511.  
However, what I want is a different channel to play.

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [August 3, 2021, 6:50am UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/8 "2021-08-03T06:50:29Z")

</div>

Just to clarify, is your goal to play a series of notes, each with different pitch adjustment, and for each such note to continue playing to completion even when a new note has begun playing? Or do you instead want to play a series of notes, each with different pitch adjustment, and for each such note to fade out gracefully when a new note begins playing?

---

<div class="post-metadata">

**Author:** ![longjin](https://avatars.discourse-cdn.com/v4/letter/l/46a35a/32.png) [@longjin](https://qa.fmod.com/u/longjin)\
**Post date:** [August 3, 2021, 7:16am UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/9 "2021-08-03T07:16:18Z")

</div>

Yes! I need to be able to play each note on a separate channel, rather than only on the same channel, so that the previous note is not played and the next note occupies this channel to play.

---

<div class="post-metadata">

**Author:** ![longjin](https://avatars.discourse-cdn.com/v4/letter/l/46a35a/32.png) [@longjin](https://qa.fmod.com/u/longjin)\
**Post date:** [August 3, 2021, 7:24am UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/10 "2021-08-03T07:24:57Z")

</div>

I want to play the piano by changing the pitch of only one note file.

---

<div class="post-metadata">

**Author:** ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)\
**Post date:** [August 4, 2021, 5:06am UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/11 "2021-08-04T05:06:23Z")

</div>

Each channel can only play one sound at a time. Thus, as you have observed, playing all your notes in the same channel will result in each note being cut off by the next.

If you need multiple notes to be playing simultaneously, each must be playing in a different channel.

---

<div class="post-metadata">

**Author:** ![longjin](https://avatars.discourse-cdn.com/v4/letter/l/46a35a/32.png) [@longjin](https://qa.fmod.com/u/longjin)\
**Post date:** [August 4, 2021, 9:45am UTC](https://qa.fmod.com/t/how-to-change-the-pitch-of-the-same-sound-file-to-play-in-multi-channel/17514/12 "2021-08-04T09:45:18Z")

</div>

Thanks.I know.
