Solved

Playing L or R channel of stereo file - how?

Posted on 1997-09-09
3
336 Views
Last Modified: 2013-12-03
Hi,

I am currently writing an audio application in Win95 which works with
stereo files. I am trying to play only one of the channels at a time. While
I have done this by sending volume messages which change the balance of the
mixer, I think there is another, better way to do it. Can anybody help me?

Thanks,

Neil
neil.crane@virgin.net
0
Comment
Question by:madmay
3 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1406313
Which method (PlaySound, MCI, waveOut or DirectSound) do you use to play the sound? Do you mean you want one channel sound to be heard on both channels?
0
 

Accepted Solution

by:
avivl earned 100 total points
ID: 1406314
The MCI_SETAUDIO command sets values associated with audio playback and capture. Digital-video and VCR devices recognize this command.

MCIERROR mciSendCommand(MCIDEVICEID wDeviceID, MCI_SETAUDIO,
    DWORD dwFlags, (DWORD) (LPMCI_GENERIC_PARMS) lpSetAudio);
 




Parameters



wDeviceID

Device identifier of the MCI device that is to receive the command message.


dwFlags

MCI_NOTIFY, MCI_WAIT, or MCI_TEST. For information about these flags, see The Wait, Notify, and Test Flags.


lpSetAudio

Address of an MCI_GENERIC_PARMS structure. (Devices with extended command sets might replace this structure with a device-specific structure.)



Return Values

Returns zero if successful or an error otherwise.

Remarks

The following flags apply to the digitalvideo device type:

MCI_DGV_SETAUDIO_ALG

The lpstrAlgorithm member of the structure identified by lpSetAudio contains an address of a buffer containing the name of an audio compression algorithm. The compression algorithm is used by subsequent MCI_RESERVE or MCI_RECORD commands. The available algorithms are device dependent. If the algorithm is incompatible with the current file format, the file format is changed to the default format for the algorithm.


MCI_DGV_SETAUDIO_CLOCKTIME

The time specified is in milliseconds and is absolute time when used with MCI_DGV_SETAUDIO_OVER. (This time is not in step with the playing of the workspace.)


MCI_DGV_SETAUDIO_INPUT

Modifies the bass, treble, or volume flag so that it affects the input signal and modifies what is recorded. If possible, this is the default when monitoring the input.


MCI_DGV_SETAUDIO_ITEM

An audio constant is specified in the dwItem member of the structure identified by lpSetAudio. The constant identifies the value that is being set. The following constants are defined:


MCI_DGV_SETAUDIO_AVGBYTESPERSEC

The average number of bytes is specified in the dwValue member of the structure identified by lpSetAudio. This value sets the average number of bytes per second for playing or recording in the PCM (Pulse Code Modulation) and ADPCM (Adaptive Differential Pulse Code Modulation) formats. The file is saved in this format.


MCI_DGV_SETAUDIO_BASS

The audio low frequency level is specified as a factor in the dwValue member of the structure identified by lpSetAudio.


MCI_DGV_SETAUDIO_BITSPERSAMPLE

The number of bits per sample is specified in the dwValue member of the structure identified by lpSetAudio. This value sets the number of bits per sample played or recorded in the PCM format. The file is saved in this format.


MCI_DGV_SETAUDIO_BLOCKALIGN

The data block alignment is specified in the dwValue member of the structure identified by lpSetAudio. This value sets the alignment of data blocks relative to the start of input waveform data.


MCI_DGV_SETAUDIO_SAMPLESPERSEC

The sample rate is specified in the dwValue member of the structure identified by lpSetAudio. This value sets the sample rate for playing and recording with the PCM and ADPCM algorithms. The file is saved in this format.


MCI_DGV_SETAUDIO_SOURCE

A constant specifying the source of audio input is included in the dwValue member of the structure identified by lpSetAudio. The following constants are defined for the audio input sources:

MCI_DGV_SETAUDIO_SOURCE_AVERAGE

    The average of the left and right audio channels.

MCI_DGV_SETAUDIO_SOURCE_LEFT

    Left audio channel.

MCI_DGV_SETAUDIO_SOURCE_RIGHT

    Right audio channel.

MCI_DGV_SETAUDIO_SOURCE_STEREO

    Stereo.


MCI_DGV_SETAUDIO_STREAM

An audio-stream is specified in the dwValue member of the structure identified by lpSetAudio. The integer value specifies the audio stream played back from the workspace. If the stream is not specified, the first physically interleaved audio stream is played.


MCI_DGV_SETAUDIO_TREBLE

The audio high-frequency level is specified as a factor in the dwValue member of the structure identified by lpSetAudio.


MCI_DGV_SETAUDIO_VOLUME

The audio level for one or both audio channels is specified as a factor in the dwValue member of the structure identified by lpSetAudio. If the left and right volumes have been set to different values, then the ratio of left to right volume is approximately unchanged.


MCI_DGV_SETAUDIO_LEFT

Enables the left audio channel when used with MCI_SET_ON. Disables the left audio channel when used with MCI_SET_OFF. When this flag is used with the combination of MCI_DGV_SETAUDIO_VALUE and MCI_DGV_SETAUDIO_VOLUME, it sets the volume of the left audio channel. When this flag is used with MCI_DGV_SETAUDIO_SOURCE, it specifies the left audio channel as the source for the audio input digitizer.


MCI_DGV_SETAUDIO_OVER

A transition length parameter is included in the dwOver member of the structure identified by lpSetAudio. The length value specifies how long (in units of the current time format) it should take to make a change that uses a factor. If this flag is not used, changes occur immediately.


MCI_DGV_SETAUDIO_QUALITY

The lpstrQuality member of the structure identified by lpSetAudio contains an address of a buffer defining the audio quality. A text-string within the buffer specifies the characteristics of the audio compression algorithm.

The MCI_DGV_SETAUDIO_ALG flag can be used to select a quality descriptor for the specified algorithm. If this flag is omitted, then the current algorithm is used.

The algorithms and descriptor names available depend on the device. Each device supplies documentation for the available algorithms and a description of the applicable descriptor names. The MCI_QUALITY command can define additional descriptor names.


MCI_DGV_SETAUDIO_RECORD

Specifies whether recording includes or excludes audio data. When combined with MCI_SET_ON, audio data is recorded. When combined with MCI_SET_OFF, audio data is excluded. The default includes audio data.


MCI_DGV_SETAUDIO_RIGHT

Enables the right audio channel when used with MCI_SET_ON. Disables the right audio channel when used with MCI_SET_OFF. When this flag is used with the combination of MCI_DGV_SETAUDIO_VALUE and MCI_DGV_SETAUDIO_VOLUME, it sets the volume of the right audio channel.


MCI_DGV_SETAUDIO_VALUE

A value is specified in the dwValue member of the structure identified by lpSetAudio. The meaning of the value is specified by the constant defined for the MCI_DGV_SETAUDIO_ITEM flag.


MCI_SET_OFF

Disables the specified audio channel.


MCI_SET_ON

Enables the specified audio channel.


MCI_SETAUDIO_OUTPUT

Modifies the bass, treble, or volume flag so that it modifies only the played signal and not what is recorded. If possible, this is the default when monitoring the input.



For digital-video devices, the lpSetAudio parameter points to an MCI_DGV_SETAUDIO_PARMS structure.

The following additional flags are used with the vcr device type:

MCI_VCR_SETAUDIO_RECORD

Sets the audio recording to on or off, which is used in conjunction with one of following flags:


MCI_SET_ON

Audio recording on.


MCI_SET_OFF

Audio recording off. It might be necessary to first turn off the assemble recording (using the MCI_SET command with the MCI_VCR_SET_ASSEMBLE_RECORD flag set to off) before the audio recording can be turned off.


MCI_TRACK

The dwTrack member of the structure identified by lpSetAudio specifies which track is affected by the command.


MCI_VCR_SETAUDIO_SOURCE

Sets the audio source. This flag must be used with the MCI_VCR_SETAUDIO_TO flag.


MCI_VCR_SETAUDIO_MONITOR

Sets the audio source monitor. This flag must be used with the MCI_VCR_SETAUDIO_TO flag.


MCI_VCR_SETAUDIO_TO

The dwTo member of the structure identified by lpSetAudio contains a constant describing the type of input or monitored input. It must be one of the following:


MCI_VCR_SRC_TYPE_TUNER

Type is tuner.


MCI_VCR_SRC_TYPE_LINE

Type is line.


MCI_VCR_SRC_TYPE_AUX

Type is auxiliary.


MCI_VCR_SRC_TYPE_GENERIC

Type is generic.


MCI_VCR_SRC_TYPE_MUTE

Type is mute. This can be used only with the MCI_VCR_SETAUDIO_SOURCE flag.


MCI_VCR_SRC_TYPE_OUTPUT

Type is output.


MCI_VCR_SETAUDIO_NUMBER

The dwNumber member of the structure identified by lpSetAudio contains the audio input (of the type specified in the dwTo member) to use.



For VCR devices, the lpSetAudio parameter points to an MCI_VCR_SETAUDIO_PARMS structure.

See Also

MCI_DGV_SETAUDIO_PARMS, MCI_GENERIC_PARMS, MCI_QUALITY, MCI_RECORD, MCI_RESERVE, MCI_SET, MCI_VCR_SETAUDIO_PARMS 
0
 

Author Comment

by:madmay
ID: 1406315
I am using WaveOutWrite to play audio; maybe I play left/ right channels (singly!) using waveoutmessage?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now