Strange DirectPlayVoice happenings 
Author Message
 Strange DirectPlayVoice happenings

Hi,

I've been getting some very odd results with DirectPlayVoice. When use
the Simple Voice sample program to create a new game, everything works
fine. My quick test  is to make some noise near the mic and observer the
volume control slider moving as the automatic gain control kicks in -
this confirms that the audio is working.

But I haven't been able to make the same functionality work in the
fairly large app that this is part of. I even went so far as to copy and
paste a subset of the demo code - worked fine in a standalone, but not
in the large app. My first thought was that this had something to do
with memory boundaries, but now I'm not so sure because ...

In the process of "professionalizing" the standalone,  I did something
to it that caused it to not work there either. Arrgh. Far too many hours
later ...

1. Peer hosting seems to work okay (generates a good CreatePlayer
event.)
2. StartVoiceServer seems to be okay, but doesn't raise any events.
Should it?
3. StartVoiceClient goes through the motions, gets
DirectPlayVoiceEvent8_ConnectResult  of 0 and a CreateVoicePlayer event.

But according to the "slider motion test" the app doesn't seem to hear
the microphone. The audio wizard (CheckAudioSetup) runs okay and hears
the mic okay. SimpleVoice still runs okay.

Things that don't make any difference:
 - Restarting VB
 - Rebooting
 - Making MaxPlayers  = 10 instead of 0 (no limit)

This code is in a class module whose lifetime is the lifetime of the
app. (Yes, I checked with breakpoints to make sure the object wasn't
accidentally being destroyed and re-created.)  On the theory that being
in a class module might have something to do with it, I tried making the
Peer object a module-level one on the calling form and passing it into
the routines (ByRef of course). It didn't change anything so I put it
back to the simpler case of the Peer being a module-level object in the
class.

Code is below. For testing, and to make sure everything has plenty of
time, I call each of the subs from a separate button in the order Host,
StartVoiceServer, StartVoiceClient.

I've been too close to this for too long, so there's a good chance I'm
missing something perfectly obvious. (This seems like a good candiate
for one of those 'slap your forehead' moments.)

Anyone been there? Thoughts? Ideas? Half ideas?

Thanks in advance.

Reg Jacklin

===================

Windows 2000, 700 MHz true Pentium II, 512 meg RAM, SoundBlaster AWE32.

Selected subsets of the code shown below: (Error handlers etc. omitted
for brevity.)

Public Sub HostSession( _
           ByRef pFrm As Form)

  Dim DPAddress As DirectPlay8Address
  Dim PlayerInfo As DPN_PLAYER_INFO

  On Error GoTo ErrorHandler

  Set DPAddress = mDX8.DirectPlayAddressCreate

  DPAddress.SetSP DP8SP_TCPIP
'  If mPORT > 0 Then
'     DPAddress.AddComponentLong DPN_KEY_PORT, mPORT
'    Commented out to eliminate a potential confusion factor
'  End If

    Set mDX8 = New DirectX8
    Set mDPPeer = mDX8.DirectPlayPeerCreate

    mDPPeer.RegisterMessageHandler pFrm

    'Set up my peer info
    PlayerInfo.Name = "Abcd"
    PlayerInfo.lInfoFlags = DPNINFO_NAME

    mDPPeer.SetPeerInfo PlayerInfo, DPNOP_SYNC
    mDPPeer.Host mAppDesc, DPAddress

  Exit Sub

'Invoked by Class_Initialize
Public Sub DescribeApp( _
           ByVal pSessionName As String _
         , Optional ByVal pPort As Long = 0 _
         , Optional ByVal pMaxPlayers As Long = 0)
  With mAppDesc
    .guidApplication = mVOICE_GUID
    .SessionName = pSessionName
    .lMaxPlayers = pMaxPlayers 'MaxPlayers of 0 is unlimited
    .lFlags = DPNSESSION_MIGRATE_HOST
  End With
  mPORT = pPort

End Sub

Public Function StartVoiceServer( _
                ByRef pForm As Form)

  Dim Session As DVSESSIONDESC

  On Error GoTo ErrorHandler

  'Initialize and start the session

  Session.lBufferAggressiveness = DVBUFFERAGGRESSIVENESS_DEFAULT
  Session.lBufferQuality = DVBUFFERQUALITY_DEFAULT

  Session.lSessionType = DVSESSIONTYPE_PEER
  Session.guidCT = vbNullString

  Set mdvServer = mDX8.DirectPlayVoiceServerCreate
  mdvServer.StartServerNotification pForm
  mdvServer.Initialize mDPPeer, 0
  mdvServer.StartSession Session, 0

  Exit Function

Public Function StartVoiceClient( _
                ByRef pForm As Form)

 Dim Flags As Long
 Dim SoundConfig As DVSOUNDDEVICECONFIG
 Dim VoiceClient As DVCLIENTCONFIG

 On Error GoTo ErrorHandler

  Flags = 0
  Set mdvClient = mDX8.DirectPlayVoiceClientCreate
  mdvClient.StartClientNotification pForm
  mdvClient.Initialize mDPPeer, Flags

  VoiceClient.lFlags = DVCLIENTCONFIG_AUTOVOICEACTIVATED Or
DVCLIENTCONFIG_AUTORECORDVOLUME
  VoiceClient.lBufferAggressiveness = DVBUFFERAGGRESSIVENESS_DEFAULT
  VoiceClient.lBufferQuality = DVBUFFERQUALITY_DEFAULT
  VoiceClient.lNotifyPeriod = 0
  VoiceClient.lThreshold = DVTHRESHOLD_UNUSED
  VoiceClient.lPlaybackVolume = DVPLAYBACKVOLUME_DEFAULT

  SoundConfig.hwndAppWindow = pForm.hWnd

  mdvClient.Connect SoundConfig, VoiceClient, Flags

Exit Function



Mon, 20 Sep 2004 14:45:02 GMT  
 Strange DirectPlayVoice happenings

Quote:
> But I haven't been able to make the same functionality work in the
> fairly large app that this is part of. I even went so far as to copy and
> paste a subset of the demo code - worked fine in a standalone, but not
> in the large app. My first thought was that this had something to do
> with memory boundaries, but now I'm not so sure because ...

Could you try some *diff* tool to see what changes to the SDK sample you
made that caused it to break?  I doubt you will find any memory conflicts
with the DX stuff.  Perhaps a global variable somewhere in your project that
is causing a conflict?  Sorry I don't have any better suggestions.

Quote:
> In the process of "professionalizing" the standalone,  I did something
> to it that caused it to not work there either. Arrgh. Far too many hours
> later ...

Maybe rework the sample app again, gradually testing it to see if it works
as you go.  You really need to narrow down the change that you made to the
sample that broke your implementation of it.  I had a quick look at your
code, I'm not seeing anything wrong yet.  I'll try to look at it again
later.

Quote:
> 2. StartVoiceServer seems to be okay, but doesn't raise any events.
> Should it?

You should be getting events from your server.  Does your form have:

Implements DirectPlayVoiceEvent8

I'm assuming you probably do. Hmmm.  Does your StartServerNotification or
mdvServer.Initialize methods return any error codes?  Anything in the debug
output?

--
Eric DeBrosse
http://www.blown.com/dx/
Microsoft Visual Basic DirectX MVP

The opinions expressed in this message are my own personal views and
do not reflect the official views of Microsoft Corporation. The MVP program
does not constitute employment or contractual obligation with Microsoft.



Tue, 21 Sep 2004 02:41:46 GMT  
 Strange DirectPlayVoice happenings


[snip]

Quote:
> Maybe rework the sample app again, gradually testing it to see if it works
> as you go.  You really need to narrow down the change that you made to the
> sample that broke your implementation of it.  I had a quick look at your
> code, I'm not seeing anything wrong yet.  I'll try to look at it again
> later.

Thanks Eric. It was a bit tedious but that did it.

Yep, I did something pretty dumb. The reason you couldn't find anything wrong
with the code was that there wasn't anything wrong with it - it just wasn't
complete. I completely missed the sample's SetTransmitTargets in
DirectPlayVoiceEvent8_ConnectResult, and was making the assumption that the
voice client should default to transmit.

Duh! Well, you know what they say about assumptions.

But now I have just the opposite problem - how do you turn the darn thing off?
The documentation says "to specify no targets, pass an empty array for [the
PlayerTargetIDs] parameter". (Actually, it says this for the voice server, but
says nothing for the client.) But what does an "empty array" look like in VB?
Is it an array with one element set to Empty? A variant defaulted to Empty? 0?
Invalid PlayerID?  Erased? Null? Dim Targets()? I tried all of these and they
don't shut the mic off. Targets() crashes VB.

The sample doesn't do the mic shutoff, so no help there. I can't find a setting
for this anywhere in the documentation.

Thanks again in advance.

Reg

Quote:

> --
> Eric DeBrosse
> http://www.blown.com/dx/
> Microsoft Visual Basic DirectX MVP

> The opinions expressed in this message are my own personal views and
> do not reflect the official views of Microsoft Corporation. The MVP program
> does not constitute employment or contractual obligation with Microsoft.



Wed, 22 Sep 2004 12:47:27 GMT  
 Strange DirectPlayVoice happenings

Quote:
> But now I have just the opposite problem - how do you turn the darn thing
off?
> The documentation says "to specify no targets, pass an empty array for
[the
> PlayerTargetIDs] parameter". (Actually, it says this for the voice server,
but
> says nothing for the client.) But what does an "empty array" look like in
VB?
> Is it an array with one element set to Empty? A variant defaulted to
Empty? 0?
> Invalid PlayerID?  Erased? Null? Dim Targets()? I tried all of these and
they
> don't shut the mic off. Targets() crashes VB.

Never tried to do this, but how about you give this flag a try?

Dim lTargets(0) as Long
lTargets(0) = DVID_NOTARGET

The docs might be wrong here.  Since 0 = DVID_ALLPLAYERS, sending in an
uninitialized array would have the same effect, since the default
(un-initialized) value of a Long is 0.

Let me know what you find out.

--
Eric DeBrosse
http://www.blown.com/dx/
Microsoft Visual Basic DirectX MVP

The opinions expressed in this message are my own personal views and
do not reflect the official views of Microsoft Corporation. The MVP program
does not constitute employment or contractual obligation with Microsoft.



Thu, 23 Sep 2004 01:56:46 GMT  
 Strange DirectPlayVoice happenings
Hi Again Eric,

Nope. That's not it. As it happened, I had my experimental "off" value set to
-1, which is the one I see for DVID_NOTARGET and was putting it in the first
element of the array just as you suggested. No joy there. 0 doesn't work either.
Other ideas anyone?

I teach a course called "Real World Software Development". One of the things I
tell the students is that no matter how great a function you come up with, if
you don't document how to use it, it is literally useless.

How about that Microsoft? When will we have some decent documentation for
DirectX VB? (I even see some of the constants - the relatively few that are
documented - spelled wrong in the existing docs.)

Reg


Quote:
> > But now I have just the opposite problem - how do you turn the darn thing
> off?
> > The documentation says "to specify no targets, pass an empty array for
> [the
> > PlayerTargetIDs] parameter". (Actually, it says this for the voice server,
> but
> > says nothing for the client.) But what does an "empty array" look like in
> VB?
> > Is it an array with one element set to Empty? A variant defaulted to
> Empty? 0?
> > Invalid PlayerID?  Erased? Null? Dim Targets()? I tried all of these and
> they
> > don't shut the mic off. Targets() crashes VB.

> Never tried to do this, but how about you give this flag a try?

> Dim lTargets(0) as Long
> lTargets(0) = DVID_NOTARGET

> The docs might be wrong here.  Since 0 = DVID_ALLPLAYERS, sending in an
> uninitialized array would have the same effect, since the default
> (un-initialized) value of a Long is 0.

> Let me know what you find out.

> --
> Eric DeBrosse
> http://www.blown.com/dx/
> Microsoft Visual Basic DirectX MVP

> The opinions expressed in this message are my own personal views and
> do not reflect the official views of Microsoft Corporation. The MVP program
> does not constitute employment or contractual obligation with Microsoft.



Thu, 23 Sep 2004 11:51:12 GMT  
 Strange DirectPlayVoice happenings
Hi,
Sorry it took me so long, I've been working on other
stuff, but once connected to the voice session, you could
then use DirectPlayVoiceClient8.SetClientConfig to change
the dvlientconfig's lflag to:
DVCLIENTCONFIG_RECORDMUTE
Which is defined in the docs as:
Mute the input from the microphone and stop recording.
This also stops compression so CPU usage is reduced.
This doesn't mean that you won't hear anything though.
Larry
Quote:
>-----Original Message-----
>Hi Again Eric,

>Nope. That's not it. As it happened, I had my

experimental "off" value set to
Quote:
>-1, which is the one I see for DVID_NOTARGET and was

putting it in the first
Quote:
>element of the array just as you suggested. No joy

there. 0 doesn't work either.
Quote:
>Other ideas anyone?

>I teach a course called "Real World Software

Development". One of the things I
Quote:
>tell the students is that no matter how great a function

you come up with, if
Quote:
>you don't document how to use it, it is literally
useless.

>How about that Microsoft? When will we have some decent
documentation for
>DirectX VB? (I even see some of the constants - the

relatively few that are
Quote:
>documented - spelled wrong in the existing docs.)

>Reg


>> > But now I have just the opposite problem - how do

you turn the darn thing
Quote:
>> off?
>> > The documentation says "to specify no targets, pass
an empty array for
>> [the
>> > PlayerTargetIDs] parameter". (Actually, it says this

for the voice server,
Quote:
>> but
>> > says nothing for the client.) But what does

an "empty array" look like in
Quote:
>> VB?
>> > Is it an array with one element set to Empty? A

variant defaulted to
Quote:
>> Empty? 0?
>> > Invalid PlayerID?  Erased? Null? Dim Targets()? I

tried all of these and
Quote:
>> they
>> > don't shut the mic off. Targets() crashes VB.

>> Never tried to do this, but how about you give this
flag a try?

>> Dim lTargets(0) as Long
>> lTargets(0) = DVID_NOTARGET

>> The docs might be wrong here.  Since 0 =

DVID_ALLPLAYERS, sending in an
Quote:
>> uninitialized array would have the same effect, since
the default
>> (un-initialized) value of a Long is 0.

>> Let me know what you find out.

>> --
>> Eric DeBrosse
>> http://www.blown.com/dx/
>> Microsoft Visual Basic DirectX MVP

>> The opinions expressed in this message are my own
personal views and
>> do not reflect the official views of Microsoft

Corporation. The MVP program
Quote:
>> does not constitute employment or contractual

obligation with Microsoft.
Quote:

>.



Wed, 06 Oct 2004 02:41:34 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Strange things are happening lately...

2. Strange Happenings???

3. Strange happenings!

4. Strange event happenings

5. 16bit to 32bit Strange Happenings

6. VB - Strange Happenings using Chr(34) ""

7. strange things are happening

8. Strange happenings with ADO

9. Strange happenings in my picture box

10. Stranger In A Strange Land...

11. Strange Strange Error

12. I cant believe it is happening - Windows 2000 and Access 2000 crashes

 

 
Powered by phpBB® Forum Software