LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

independent two-channel volume control

Hi

 

I'm trying to establish independent volume control of each channel of a stereo sound card (which is configured as a 2-channel card). When I configure the polymorphic volume control VI to accept an array, only the zero-eth element of the array is effective, and it sets the volume for both channels. Is there a way to control the sound card gain independently for each of the 2 channels?

 

Best,

 

Geoff Hammond

 

0 Kudos
Message 1 of 11
(3,640 Views)

Hey Geoff, could you clarify which VI you are using? I was not able to find the one you were refering to. If it is an array as an output though, you may be able to parse out one channel and adjust the volume that way.

 

Regards,

 

-KP

Kurt P
Automated Test Software R&D
0 Kudos
Message 2 of 11
(3,602 Views)

Hey Kurt,

 

Thanks for the reply. 

 

The VI is Sound Output Set Volume.vi, which is in the Graphics & Sound>>Sound>>Output palette in LV2010. (The sound output VIs in LV7.0 did allow independent gain of each channel of a stereo soundcard, making it very useful for psychoacoustic work that required control of the sound streams directed to each ear.)

 

Best,

 

Geoff

0 Kudos
Message 3 of 11
(3,595 Views)

Hey Geoff,

 

How exactly did you do it in LabVIEW 7? I found an example that goes over how to remove a channel. I think it can be modified to act the way you want it to since it allows you to select audio channels. You can pull each channel and then adjust the volume accordingly.

 

https://decibel.ni.com/content/docs/DOC-28069

 

Regards,

 

-KP

Kurt P
Automated Test Software R&D
0 Kudos
Message 4 of 11
(3,562 Views)

Hey Kurt

 

It's straightforward in LV7.0. SO Volume.vi has separate U16 controls for each channel of a stereo sound card. From the Help:

 

left channel controls the volume for the left channel. You can enter a range of 0 to 65535.
right channel controls the volume for the left channel. You can enter a range of 0 to 65535.

 

 

The Help for Sound Output Set Volume (Array) in LV2010 makes it sound equally simple:

 

volume specifies the volume of the sound operation, one element per channel. 0 is silent and 100 is the loudest volume. The default is 100.

 

I read the 'one element per channel' as saying that the first element in the array (range 0-100) would set the gain for the left channel, and the second element would set gain for the right channel. However,my experience is that the first element sets the gain for *both* channels and that the second element is ignored.

 

Thanks for the example, but I don't think it will help as I want to have independent gain settings for each channel while both are playing.

 

I create 2 separate signal waveforms and build a 2D array from them. Writing this array to the sound card plays (correctly) one waveform to each channel. I can achieve independent levels in each channel by creating the waveforms with different amplitudes, but this is a bit awkward; it would be much simpler (and be a more general solution for me) to create the 2D waveform array and to control the levels independently through the Sound Output Set Volume (Array) VI.

 

Thanks for your help. I'd be interested to know if I have misunderstood the function of the volume-setting array in Sound Output Set Volume (Array) in LV2010.

 

Best,

 

Geoff

 

 

 

 

 

 

0 Kudos
Message 5 of 11
(3,543 Views)

Hi GeoffHammond

 

Could you attach a screenshot of your code or the VI in order to understand better and see what exactly is what you have?

 

Also I will like to ask you some questions.

 

Which version of LabVIEW are you using? Are you using any special library or VI in your code?

 

Regards

Esteban R.

0 Kudos
Message 6 of 11
(3,529 Views)

Hi Esteban

 

I'll attach a simple VI which writes a 2-second noise burst to each channel of the soundcard. It works fine *except* that the volume control array doesn't work as I expected from the Help (namely that each element in the array should determine the gain in one of the stereo soundcard channels). As it is, the first element controls the gain in both channels while the second element does not affect the gain in either channel.

 

In reply to your questions, I'm using LV2010 SP1, and I'm not using any special libraries or VIs. All straight off the palettes ...

 

Thanks for your advice,

 

Geoff

0 Kudos
Message 7 of 11
(3,510 Views)

Hey Geoff,

 

It looks like the data you're passing in is only a single 1D array which the VI is interpreting as a mono. Try opening a sound file that has two channels and then using that VI to control the volume of each of those channels. 

 

Regards,

 

KP

Kurt P
Automated Test Software R&D
0 Kudos
Message 8 of 11
(3,496 Views)

Hey Kurt

 

Thanks for your reply.

 

Not sure that I understand--the 2 channel VI attached to a previous post builds a 2D noise array (from a 1D noise stream) that's passed to Sound Output Write.vi. And variants of this program that write a 2D array made up of different signals to each channel (and which play correctly through the left and right sound card channels) don't allow independent volume settings with an array wired to the 'volume' input on Sound Output Set Volume.vi. Have I misunderstood?

 

Best,

 

Geoff

0 Kudos
Message 9 of 11
(3,472 Views)

Geoff,

 

The Detailed Help is your friend.  Checking the Detailed Help for the Sound Output Set Volume VI shows that it is polymorphic: One version has a scalar volume input while the other accepts an array.  Just wire an array of volume controls to the volume input and the VI will automatically change to accept it.  You can also select the type from the pop up menu for the VI.

 

Lynn

 

Independent Volume.png

0 Kudos
Message 10 of 11
(3,466 Views)