Page 1 of 1

wavOutSetVolume_(hwo, dwVolume) question...

Posted: Sun Sep 08, 2024 9:57 pm
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.

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

Posted: Sun Sep 08, 2024 10:05 pm
by infratec
You can try this:

Code: Select all

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

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

Posted: Mon Sep 09, 2024 2:27 am
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))

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

Posted: Mon Sep 09, 2024 3:23 am
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!

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

Posted: Mon Sep 09, 2024 9:13 am
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.

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

Posted: Mon Sep 09, 2024 4:42 pm
by gregreen
Thank you for taking the time to explain. That’s what makes this forum awesome!