Author Topic: Convert left mono channel ==> to stereo output  (Read 676 times)

Cafony

  • Posts: 33
I have this line of code that makes my audio play in MONO (left chanel playing)

Code: [Select]
Bass.BASS_ChannelSetAttribute(_stream, BASSAttribute.BASS_ATTRIB_PAN, -1);

How can I make this MONO left channel playing in bouth (left+right) channels?
Ive tryed this line but stays the same (only left channel plays)

Code: [Select]
BassMix.BASS_Mixer_StreamAddChannel(_stream, _stream, BASSFlag.BASS_AC3_DOWNMIX_2);

Thanks a lot !

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: Convert left mono channel ==> to stereo output
« Reply #1 on: 27 Mar '24 - 17:10 »
What is the file format? With OGG/MP3/MP2/MP1 formats, you can simply use the BASS_SAMPLE_MONO flag to have a stereo file decoded in mono. More generally, if you're playing the file through a BASSmix mixer then you could use its matrix mixing option (BASS_MIXER_CHAN_MATRIX) to convert to mono. Please see the "Matrix mixing" section of the BASSmix documentation for details/examples. If you're not playing through a mixer then the BASS_FX add-on's BASS_FX_BFX_MIX effect is another option, as is a DSP function (via BASS_ChannelSetDSP).

Cafony

  • Posts: 33
Re: Convert left mono channel ==> to stereo output
« Reply #2 on: 28 Mar '24 - 15:36 »
Sorry but I cant figures out to make it work.
Please help
Thanks

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: Convert left mono channel ==> to stereo output
« Reply #3 on: 28 Mar '24 - 17:48 »
In case you aren't playing through a mixer (so no matrix mixing), you could use the BASS_FX add-on's BASS_FX_BFX_MIX effect like this:

Code: [Select]
mixfx = BASS_ChannelSetFX(stream, BASS_FX_BFX_MIX, 0);
int mix[2] = { // 2 = assuming the stream is stereo
BASS_BFX_CHAN1 | BASS_BFX_CHAN2, // 1st output = 1st+2nd inputs
BASS_BFX_CHAN1 | BASS_BFX_CHAN2 // 2nd output = 1st+2nd inputs
};
BASS_BFX_MIX param = { mix };
BASS_FXSetParameters(mixfx, param);

Cafony

  • Posts: 33
Re: Convert left mono channel ==> to stereo output
« Reply #4 on: 29 Mar '24 - 10:39 »
Thanks Ian your idea, after I search the web and found this code :

http://www.radio42.com/bass/help/html/76af95fd-293b-4186-02b6-6d4a183fa13d.htm

I made  a new object from BASS_FX_BFX_MIX
Then add the same channels in parameters BASSFXChan.BASS_BFX_CHAN1
And it makes a MONO out on boutgh channels has I want it !!

Thanks for your great help.

Code: [Select]
            BASS_BFX_MIX swap = new BASS_BFX_MIX(BASSFXChan.BASS_BFX_CHAN1, BASSFXChan.BASS_BFX_CHAN1);
            int mixfx = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_MIX, 0);
            Bass.BASS_FXSetParameters(mixfx, swap);

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: Convert left mono channel ==> to stereo output
« Reply #5 on: 29 Mar '24 - 13:34 »
Note that using only BASS_BFX_CHAN1 will mean you get the left channel on both channels. If you would rather have a mix of left and right channels then you should add BASS_BFX_CHAN2 to it:

Code: [Select]
BASS_BFX_MIX mix = new BASS_BFX_MIX(BASSFXChan.BASS_BFX_CHAN1 | BASSFXChan.BASS_BFX_CHAN2, BASSFXChan.BASS_BFX_CHAN1 | BASSFXChan.BASS_BFX_CHAN2);

Or:

Code: [Select]
BASS_BFX_MIX mix = new BASS_BFX_MIX(BASSFXChan.BASS_BFX_CHAN1 + BASSFXChan.BASS_BFX_CHAN2, BASSFXChan.BASS_BFX_CHAN1 + BASSFXChan.BASS_BFX_CHAN2);

Cafony

  • Posts: 33
Re: Convert left mono channel ==> to stereo output
« Reply #6 on: 29 Mar '24 - 16:16 »
Ok I understand.
Im making a music player for musitians.

I play guitar , sometime when trying to transcribe guitar solos you have two guitars:
1 guitar ---- right channel   
2 guitar ---- left channel

So the porpose of this funtion is :
- to have the left MONO channel guitar ==== >   played on both channels (right+left)
- or the right MONO channel guitar ===>  played on both channels (righ+left)

And this funtion is working as I wanted :-)

Thanks again for your help!

Cafony

  • Posts: 33
Re: Convert left mono channel ==> to stereo output
« Reply #7 on: 17 Apr '24 - 11:20 »
Hello, in this funtion I make a mono out from the "left" channel, playing in stereo R/L out:

Code: [Select]
        public static int monoLeft(int _stream)
        {           
            int mixfx = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_MIX, 0);
            BASS_BFX_MIX swap = new BASS_BFX_MIX(BASSFXChan.BASS_BFX_CHAN1, BASSFXChan.BASS_BFX_CHAN1);           
            Bass.BASS_FXSetParameters(mixfx, swap);
            return mixfx;
        }

from this point (if I undersand),  "the stream only have the CHAN1 in L/R output".

How can I go back to have the CHAN1 and CHAN2 again in a "normal stereo out" as the original stream.

I've tryed this code but didnt work (cause the stream, from the last change, only has CHAN1)

Code: [Select]
BASS_BFX_MIX swap = new BASS_BFX_MIX(BASSFXChan.BASS_BFX_CHAN1, BASSFXChan.BASS_BFX_CHAN2);

Please a little help. Thanks


Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: Convert left mono channel ==> to stereo output
« Reply #8 on: 17 Apr '24 - 18:05 »
I've tryed this code but didnt work (cause the stream, from the last change, only has CHAN1)

Code: [Select]
BASS_BFX_MIX swap = new BASS_BFX_MIX(BASSFXChan.BASS_BFX_CHAN1, BASSFXChan.BASS_BFX_CHAN2);

That looks fine. How are you using it? It should be in a BASS_FXSetParameters call with the original "mixfx" handle, ie. don't call BASS_ChannelSetFX again. Another option is to just free the effect with BASS_ChannelRemoveFX. In either case, the key thing is to retain the "mixfx" handle.

Cafony

  • Posts: 33
Re: Convert left mono channel ==> to stereo output
« Reply #9 on: 18 Apr '24 - 10:57 »
Ok after some testing, I understand :-)

When open file, and after creating a stream from file, add this to a global variable:

Code: [Select]
            mixMono = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_MIX, 0);

and then , yes, I can use the mono stereo funtion I create

Its working:

- Left channel to L/R
- Right channel to L/R

Thanks great help !!