Gamestudio Links
Zorro Links
Newest Posts
make a complaint
by EW_bytes. 11/26/26 23:00
FXCM => AVA Trade Plugin???
by Martin_HH. 11/25/26 21:59
No connection to MT4
by Martin_HH. 11/23/26 06:38
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
contractUpdate() is filtering if >2 rows
by mistery. 11/09/26 12:06
New Zorro version 3.15
by jcl. 11/09/26 09:24
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (EW_bytes), 15,961 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
snd_play() delay, ent_playsound() not threadsafe #287124
08/30/09 09:12
08/30/09 09:12
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Hi jcl!

As you already know, I want to use the built in sound functions for my VoIP feature. Now I ran over two new problems and I need you knowledge to solve them:

1) For VoIP, my application records a stream during runtime and splits the recorded stream into small 20 ms packets. These are sent over the network and then played with snd_play(). This is working well, but I noticed small noises/delays between the calls.

To explain the problem, try the following:
Code:
//Lite-C:
function main()
{
   wait(1);
   while(1)
   {
      SOUND* dummy_snd = snd_create("dummy.wav");
      var sndhandle = snd_play(dummy_snd,100,0);
      while(snd_playing(sndhandle)) {wait(1);}
      snd_remove(dummy_snd);
      wait(1);
   }
}



dummy.wav is a tone. The output should be one long tone, but in reality between the snd_play() instructions small delays/noise can be heard.
Get the soundfile here (use dummy.wav).

What can I do against this delay/noise?

2) Using ent_playsound() in a thread causes a crash. But I would need ent_playsound() also to be threadsave so that I can make a 3d VoIP.
What shell I do? Any possibility that this function gets threadsafe in one of the next updates?


Thanks for your help!


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: snd_play() delay, ent_playsound() not threadsafe [Re: Dark_samurai] #287277
08/31/09 07:18
08/31/09 07:18
Joined: Jul 2000
Posts: 28,149
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,149
Frankfurt
I would not do it this way. Permanently deleting and creating a sound will cause the artifacts that you're hearing. Use the pds and pdsb pointers to directly create a sound buffer for your voice. AFAIK, DirectSound itself is threadsafe, but engine functions are not.



Re: snd_play() delay, ent_playsound() not threadsafe [Re: jcl] #287301
08/31/09 10:16
08/31/09 10:16
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Quote:
Permanently deleting and creating a sound will cause the artifacts that you're hearing. Use the pds and pdsb pointers to directly create a sound buffer for your voice.


How to get access to the pDS and pDSB pointers? Do you have any examples for that?

Quote:
AFAIK, DirectSound itself is threadsafe, but engine functions are not.


So what shell I do to use 3d sound in a thread? Recreate the ent_playsound function with directsound, or is there any easier workaround?


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: snd_play() delay, ent_playsound() not threadsafe [Re: Dark_samurai] #287311
08/31/09 11:25
08/31/09 11:25
Joined: Jul 2000
Posts: 28,149
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,149
Frankfurt
All pointers you need are in avars.h:

ENGINE_ void* pds; // pointer to the IDirectSound interface
ENGINE_ void* pdsb; // pointer to the primary IDirectSoundBuffer

Create a secondary 3D soundbuffer, fill it, and move it with the entity. This should be doable without much hassle.

Re: snd_play() delay, ent_playsound() not threadsafe [Re: jcl] #287325
08/31/09 12:11
08/31/09 12:11
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Do you have any examples for that, because I never have worked with DirectSound before?

Do I have access to the DirectSound functions when I write an acknex plugin or do I need to include the DX SDK?


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: snd_play() delay, ent_playsound() not threadsafe [Re: Dark_samurai] #287335
08/31/09 13:21
08/31/09 13:21
Joined: Jul 2000
Posts: 28,149
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,149
Frankfurt
You need the DX SDK. This SDK contains many examples for DirectSound.

One important info: The DirectSound functions use DX7, not DX8. A sound buffer is a DIRECTSOUND3DBUFFER struct, not DIRECTSOUND3DBUFFER8.

Re: snd_play() delay, ent_playsound() not threadsafe [Re: jcl] #287755
09/02/09 12:04
09/02/09 12:04
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
So what version of the DX SDK should be used and which one is used by the engine? March 2009?

Edit: Btw. because DirectSound was replaced through XAudio2, there are no samples anymore in the DX SDK...

Could you give me a short code snippet how to create a new buffer , copy data in it and play it?

Last edited by Dark_samurai; 09/02/09 13:53.

ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: snd_play() delay, ent_playsound() not threadsafe [Re: Dark_samurai] #287846
09/02/09 19:35
09/02/09 19:35
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Originally Posted By: Dark_samurai
So what version of the DX SDK should be used and which one is used by the engine? March 2009?

Edit: Btw. because DirectSound was replaced through XAudio2, there are no samples anymore in the DX SDK...
I use the NOV-2007 DXSDK. It has samples using DX7 & 8 as well as voice management.
It does however give an error about a pre-release X-Audio2 but just ignore it. The SDK still installs and works fine.
If you can't find it let me know and I'll make it available for download. (I hope i'm allowed to do that)

Quote:
Could you give me a short code snippet how to create a new buffer , copy data in it and play it?
I wouldn't mind an example also please. smile


Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: snd_play() delay, ent_playsound() not threadsafe [Re: Nidhogg] #287899
09/03/09 07:20
09/03/09 07:20
Joined: Jul 2000
Posts: 28,149
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,149
Frankfurt
A7 uses DirectX of April 2006. This SDK contains a programming guide and many samples for DirectSound, so I recommend this version. If you can't find it, let me know - I could upload the documentation and the samples.

Re: snd_play() delay, ent_playsound() not threadsafe [Re: jcl] #287970
09/03/09 13:35
09/03/09 13:35
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
I found a download to the April 2006 SDK. Now I try to get normal output working (not the 3d one):

Code:
LPDIRECTSOUND dsDSound = (LPDIRECTSOUND)ev->pds;
LPDIRECTSOUNDBUFFER dsBuffer;
DSBUFFERDESC dsBufferDesc;
WAVEFORMATEX waveform;

dsBufferDesc.dwFlags = DSBCAPS_STICKYFOCUS;
dsBufferDesc.dwBufferBytes = voip_bufsize;
init_waveformat(&waveform);
dsBufferDesc.lpwfxFormat = &waveform;
dsBufferDesc.dwSize = sizeof(dsBufferDesc);

dsDSound->CreateSoundBuffer(&dsBufferDesc,&dsBuffer,NULL); //This methode always returns E_INVALIDARG



I did everything exactly as it is explained in msdn, but of course it's not working... The CreateSoundBuffer methode always returns E_INVALIDARG. What am I doing wrong? This thing drives me crazy.

PS: waveform is initialized with 16000Hz,16bit/sample,mono.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Page 1 of 2 1 2

Moderated by  old_bill, Tobias 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1