wavOutSetVolume_(hwo, dwVolume) question...

Just starting out? Need help? Post your questions and find answers here.
gregreen
User
User
Posts: 28
Joined: Fri Apr 21, 2023 7:26 pm

wavOutSetVolume_(hwo, dwVolume) question...

Post by gregreen »

Can anyone help me with loading the dwVolume variable with the right DWORD to set the left and right channel volumes to -100 100 or 40 -40 for example. How do I come up with the DWORD and how do I express it with the dwVolume variable?

I'm looking at the C code I think (mmeapi.h) and I know I need the WAVECAPS_LRVOLUME structure. But this is above my paygrade. Any example or info would be most welcome and helpful. I'm trying to figure it out! So far, no luck. Thx!

I'm using: waveOutGetVolume_(hwaveOut, @pdwVolume) to get the volume successfully (I think), and the debugger shows a pdwVolume value of 710609796 I'm not sure how to view that as something useful. The documentation says 0x4000 is an example of what pdwVolume is returning.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: wavOutSetVolume_(hwo, dwVolume) question...

Post by infratec »

You can try this:

Code: Select all

Procedure.l waveOutdwVolume(Left.u, Right.u)
  ProcedureReturn Right << 16 | Left
EndProcedure
gregreen
User
User
Posts: 28
Joined: Fri Apr 21, 2023 7:26 pm

Re: wavOutSetVolume_(hwo, dwVolume) question...

Post by gregreen »

So do something like this to mute the right channel? Sorry, tryin' hard to figure this out.

Code: Select all

Procedure.l waveOutdwVolume(Left.u, Right.u)
  ProcedureReturn Right << 16 | Left
EndProcedure

waveOutSetVolume_(hwaveOut, waveOutdwVolume(65532, 0))
gregreen
User
User
Posts: 28
Joined: Fri Apr 21, 2023 7:26 pm

[SOLVED] wavOutSetVolume_(hwo, dwVolume) question...

Post by gregreen »

infratec nailed it! The code is working. I'm going to study up on the syntax as I don't know what
variable << 16 | variable means exactly other than to turn integers into what is needed.

Thank you very much for your help! I will try to return the favor to someone else having a problem.
This forum has been awesome! I'm learning new stuff everyday!
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: wavOutSetVolume_(hwo, dwVolume) question...

Post by infratec »

dw means doubleword
a word is 16 bit, a double word is 32 bit.
In PB a dw is .l and a word is .w or .u

<< means shifting bits right

It returns a long, where Right word is shifted 16 bits to the right and left is or'ed to the lower 16 bits.
gregreen
User
User
Posts: 28
Joined: Fri Apr 21, 2023 7:26 pm

Re: wavOutSetVolume_(hwo, dwVolume) question...

Post by gregreen »

Thank you for taking the time to explain. That’s what makes this forum awesome!
Post Reply