left-right audio control

How can I control the left channel (left speaker) or the right channel (right speaker) for the audio(wavesound?) or
Mpeg1 file in Visual Basic?
Could you give me some program codes for VB4 or VB5?
thank you
hokmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lmarceauCommented:
If you would have told us which final result you needed a could give you a more precide answer.
But I know you can't play two diffenrent files into each speaker. Since the data is played at the same time, it must be bundled at the same place. You will need to mix it in memory or to create a files with want you need on the hard disk before starting the playback.

The only thing you can do is to use the waveOutSetVolume. It will allow you to independently set the left and the rigth volume.
Syntax

UINT waveOutSetVolume(wDeviceID, dwVolume)

This function sets the volume of a waveform output device.

Parameters

UINT  wDeviceID

Identifies the waveform output device.

DWORD  dwVolume

Specifies the new volume setting. The low-order word contains the left channel volume setting, and the high-order word contains the right channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.

If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and the high-order word is ignored.

Return Value

Returns zero if the function was successful. Otherwise, it returns an error number. Possible error returns are:

MMSYSERR_INVALHANDLE

Specified device handle is invalid.

MMSYSERR_NOTSUPPORTED

Function isn't supported.

MMSYSERR_NODRIVER

The driver was not installed.

Comments

Not all devices support volume changes. To determine whether the device supports volume control, use the WAVECAPS_VOLUME flag to test the dwSupport field of the WAVEOUTCAPSstructure (filled by waveOutGetDevCaps).


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hokmanAuthor Commented:
what is low order word? what is high order word?
how to write this program code?
how do I know my DeviceID?
0
lmarceauCommented:
For your first question:
A byte is made up of 8 bits.
A word is made up of 16 bits. -> This is what Vb calls an Integer
And a pack of 32 bits is called a long word, or simply long in Vb.
A long can be divided into two part:
The first 16 bits in a long, those at right, those which has the lowest impact on the numerical value, are called the low order word.
And the orders 16 bits in the long, those at left, those which has te higest impact on the numerical value, are called the high order word

waveOutSetVolume function want you to pack two information in the long, one in each word that make it up. You can do that this way:

dim LeftVolume as integer
dim RightVolume as integer
dim ToBeSend as long
ToBeSend = LeftVolume + RightVolume * 2^16

And this line in a module in your code: (vb4 16bit)
Declare Function waveOutSetVolume Lib "MMSYSTEM" (ByVal udeviceid As Integer, ByVal dwVolume As Long) As Integer

You can look up for the corect line for your vb version with the API text viewer that came with vb. Open the file vb\winapi\winmmsys.txt and search for waveOutSetVolume.

The DeviceId is the number of the sound card driver. Usually this is zero since most computer only have one sound card. But if a computer have many, then the first card has the number 0, the second has #1, the third has #2 and so on.
You can ask for the number of devices with the call waveOutGetNumDevs and ask the user for which he want to set the volume.
You could want to ask Windows for the name of the differents sound cards with waveOutGetDevCaps() to be able to show them to the user rather than only the number. Most user will not know which sound card has which number.
0
hokmanAuthor Commented:
thank you for your patience.
But I still have problem because I am a beginner
what kind of command buttoms should I use e.g. slider or VScroll or HScroll?(or two slider to have right and left volume control, then how to disturbute the program code into two fields of sliders)
Should I also use waveOutGetVolume in order to make waveOutSetVolume have effect?
wDeviceID = 0
and dwVolume = ToBeSend
right?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.