[RESOLVED] PDK Sound Service Instance -> Play() Function

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: PDK Sound Service Instance -> Play() Function

Post by Clifton Crane »

Hi Jim,

Storing the reference counted pointer in your own class should be fine. If your class is the sole owner of the ISoundInstance, you'll just want to make sure it has a ref-count of one throughout its lifetime so that is properly released when your class is destroyed.
Clifton Crane
Prepar3D® Software Engineer Sr.
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK Sound Service Instance -> Play() Function

Post by BenBaron »

Hi guys,

now, I am seeing the following problem: I am trying to play a 3D sound just once, when a certain condition is met. The sound is created as CreateSoundInstance(bLooping = false) and all HRESULTS return S_OK. I checked with the debugger that Play() is indeed called only once in my code on the sound instance, but the sound loops audible, anyways. This is while IsLooping() on the SoundInstance returns false.

Is anyone able to confirm this behaviour or has an idea where I might be making a mistake?

All the best,

Benny
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: PDK Sound Service Instance -> Play() Function

Post by Clifton Crane »

Hi Benny,

Do you see the same behavior if the sound is not created as 3D?
Clifton Crane
Prepar3D® Software Engineer Sr.
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK Sound Service Instance -> Play() Function

Post by BenBaron »

Clifton Crane wrote: Tue Dec 18, 2018 5:01 pm Hi Benny,

Do you see the same behavior if the sound is not created as 3D?
Hi Clifton,

indeed, changing b3D to 'false' it is only played once. So it seems to have something to do with the 3D mode. What might this be?

Greets,

Benny
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: PDK Sound Service Instance -> Play() Function

Post by Clifton Crane »

Hello,

What SOUND_GROUP are you using? Its possible that 3D sound may not work for SOUND_GROUP_VOICE.
Clifton Crane
Prepar3D® Software Engineer Sr.
flyboy7798
Posts: 37
Joined: Thu Jul 20, 2017 7:15 pm

Re: PDK Sound Service Instance -> Play() Function

Post by flyboy7798 »

Clifton,

Thanks got it.

V/R
Jim
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK Sound Service Instance -> Play() Function

Post by BenBaron »

Clifton,

no, I am using SOUND_GROUP::SOUND_GROUP_ENVIRONMENT. I'm gonna wrap up some code without error checking and mabye you can spot a mistake:

Code: Select all

CComPtr<P3D::ISoundInstanceV440> soundInstance = nullptr;

Code: Select all

PDKSoundService->CreateSoundInstance(this->name.c_str(), SOUND_GROUP::SOUND_GROUP_ENVIRONMENT, VIEW_POINT::VIEW_POINT_ALL, false, true, true, (void**)&soundInstance);
with this->name being a wstring with an absolute path to a .wav file

Code: Select all

soundInstance->SetMinVolume(0.0);

Code: Select all

soundInstance->SetMaxVolume(10000.0);

Code: Select all

soundInstance->SetPitch(1.0f);

Code: Select all

soundInstance->SetPosition(position)
with position being a valid world coordinate P3DDXYZ

Code: Select all

soundInstance->SetCockpitAttenuation(0.0);

Code: Select all

soundInstance->SetFullScaleDistance(100.0f);

Code: Select all

soundInstance->Play();
Thanks in advance.

All the best, Benny
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: PDK Sound Service Instance -> Play() Function

Post by Clifton Crane »

Hello,

We were able to reproduce the issue where 3D one-shot sounds would continue to loop. This will be resolved in the next release. Return type will be corrected as well (i.e. IsPlaying() will return S_FALSE without having to call Play() first).

Thanks!
Clifton Crane
Prepar3D® Software Engineer Sr.
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK Sound Service Instance -> Play() Function

Post by BenBaron »

Thanks for the information, Clifton.

Nice to know I can stop trying to figure this one out.

All the best,

Benny
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK Sound Service Instance -> Play() Function

Post by BenBaron »

Hi guys,

it is now working on my side with 4.5. Thanks for the fix.

All the best,

Benny
Locked