23 Oct '14 - 16:08 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Pan not working?  (Read 2387 times)
frdfsnlght
Posts: 7


« on: 15 Feb '12 - 21:57 »
Reply with quoteQuote

This is tough to troubleshoot since the problem is only happening on one computer and it's in my car. Things work fine on my desktop.

I'm using Bass/Bass.NET 2.4.8.1 and C#. I'm writing a small test program to play with pan/fade in my car which has a 4 speaker setup. I've got the following set up in code (I've removed debugging statements and error checking for clarity):

Bass.BASS_Init(2, 44100, BASSInit.BASS_DEVICE_DEFAULT, System.IntPtr.Zero);
BassMix.LoadMe();

float pan = 0f;  // -1 is left, +1 is right
float fade = 0f; // -1 is rear, +1 is front

int s = Bass.BASS_StreamCreateFile("stereo.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE);
int sFront = BassMix.BASS_Split_StreamCreate(s, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_SPEAKER_FRONT, null);
Bass.BASS_ChannelSetAttribute(sFront, BASSAttribute.BASS_ATTRIB_PAN, pan);
Bass.BASS_ChannelSetAttribute(sFront, BASSAttribute.BASS_ATTRIB_VOL, ((fade >= 0) ? 1f : (1f + fade)));

int sRear = BassMix.BASS_Split_StreamCreate(s, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_SPLIT_SLAVE | BASSFlag.BASS_SPEAKER_REAR, null);
Bass.BASS_ChannelSetAttribute(sRear, BASSAttribute.BASS_ATTRIB_PAN, pan);
Bass.BASS_ChannelSetAttribute(sRear, BASSAttribute.BASS_ATTRIB_VOL, ((fade <= 0) ? 1f : (1f - fade)));
Bass.BASS_ChannelSetLink(sFront, sRear);

Bass.BASS_ChannelPlay(sFront, false);

This works as I expect on my desktop (albeit with 2 front speakers since I don't have 4 speakers at my desk) when I fiddle with the "pan" value. In my car, panning doesn't work, but fading does. There are no errors from Bass when it runs in the car and looking at the BASS_INFO stuff after init shows 4 speakers. The balance control in the Windows sound control panel works as expected.

Am I doing something wrong? Is there a better way to split/pan/fade a stream? If everything looks good, what else should I provide the reader to help figure this out?
Logged
Ian @ un4seen
Administrator
Posts: 17044


« Reply #1 on: 16 Feb '12 - 15:04 »
Reply with quoteQuote

Unfortunately, the BASS_ATTRIB_PAN attribute doesn't have any effect when using SPEAKER flags on Windows. Panning/balance control could be implemented in a DSP function instead (an example of that can be found in the DSPPROC documentation). If you're using Vista/7, support for BASS_ATTRIB_PAN with SPEAKER flags on those Windows versions has been added recently, so you could give the latest build a try...

   www.un4seen.com/stuff/bass.dll
Logged
frdfsnlght
Posts: 7


« Reply #2 on: 17 Feb '12 - 00:53 »
Reply with quoteQuote

Yes, I am using Windows 7. I'll try the DLL you've pointed to.

Meanwhile, is there any better arrangement of Bass components to do what I'm trying to do? It seems having to pan 2 streams (front and rear) is a bit messy. And I plan on adding some Fx stuff like an EQ eventually. I supposed I'd have to add that to each of the front and rears streams? A lot of duplicated effort. Is there a way so that I have a single stream to pan and add effects to, then split it into front and rear so I can fade them independently?
Logged
SoundMike
Posts: 283


« Reply #3 on: 17 Feb '12 - 04:27 »
Reply with quoteQuote

If you're using Vista/7, support for BASS_ATTRIB_PAN with SPEAKER flags on those Windows versions has been added recently, ...

That's great news, Ian!  Smiley  I'll try the new build when I've got some time - probably next week.
Logged
Ian @ un4seen
Administrator
Posts: 17044


« Reply #4 on: 17 Feb '12 - 16:23 »
Reply with quoteQuote

Meanwhile, is there any better arrangement of Bass components to do what I'm trying to do? It seems having to pan 2 streams (front and rear) is a bit messy. And I plan on adding some Fx stuff like an EQ eventually. I supposed I'd have to add that to each of the front and rears streams? A lot of duplicated effort. Is there a way so that I have a single stream to pan and add effects to, then split it into front and rear so I can fade them independently?

If you set the effects on the source stream ("s"), then they will be present in both splitter streams ("sFront" and "sRear").
Logged
frdfsnlght
Posts: 7


« Reply #5 on: 17 Feb '12 - 18:35 »
Reply with quoteQuote

I'll try that with respect to the effects. Should panning work at that level too (i.e., on "s") (and with the new DLL)?

About the new DLL... good news/bad news. The new DLL does indeed allow me to pan left and right using the code I posted above. However, fading is now broken. More specifically, I'm getting no audio out of the rear (sRear). This is using the exact same code. All I did was swap out the bass.dll file for the new one. If I put the "old" one back, it works like before (panning is broken, but fading works fine). Any ideas?
Logged
Ian @ un4seen
Administrator
Posts: 17044


« Reply #6 on: 20 Feb '12 - 15:55 »
Reply with quoteQuote

Is it just that the BASS_ATTRIB_VOL attribute is having no effect on the rear speakers, or do you hear nothing at all from those speakers? Are the front speakers working OK in the meantime? Please also confirm what speaker configuration you have set via the Sound control panel.
Logged
frdfsnlght
Posts: 7


« Reply #7 on: 20 Feb '12 - 16:36 »
Reply with quoteQuote

There is no sound from the rears. Windows CP is set to 4 speakers. Through the CP, I have control of all the speakers (I can make sound come out of each, so I know they're working). When I adjust the fader control (which changes the BASS_ATTRIB_VOL on both fronts and rears), there's never any sound from the rears. But (and this may just be psychological or my old ears) there seems to be a slight reduction in front volume level as I fade from center to front. The code holds the front volume at 1 during this change, so I'm not sure what's going on there.

Other than that, the fronts work as expected with the new DLL - panning left/right works perfectly.

For reference, this is running on an MSI E350IA-E45 mini-itx board with AMD Hudson chipset, Zacate-FT1 APU, and integrated Realtek ALC887 sound chip, under 64bit Windows 7 (but using 32-bit Bass). I don't have the audio driver version handy, but I can get it if it helps.

If I get a chance this week, I'm going to re-implement the code to put panning and effects on the splitter input stream and only fade/volume on the splitter outputs. I'll test again with that. I can send the C# code to you if you'd think that would help.

Logged
Ian @ un4seen
Administrator
Posts: 17044


« Reply #8 on: 20 Feb '12 - 17:07 »
Reply with quoteQuote

There is no sound from the rears. Windows CP is set to 4 speakers.

Is that a "Quadraphonic" or "Surround" speaker arrangement, and does switching to the other help?
Logged
frdfsnlght
Posts: 7


« Reply #9 on: 21 Feb '12 - 14:23 »
Reply with quoteQuote

I use a "Quadraphonic" setup. I switched to "Surround 5.1" and disabled the center and subwoofer and had the same results with my test app (however Bass detected 6 speakers).

I'm using Realtek driver version 6.0.1.6482 dated 10/18/2011.
Logged
Ian @ un4seen
Administrator
Posts: 17044


« Reply #10 on: 21 Feb '12 - 16:39 »
Reply with quoteQuote

Hmm... I see what you mean. I gave the latest Realtek driver a try on a Win7 system, and the new SPEAKER flag system does indeed appear to not work properly with it (the sound is always coming from the front speakers regardless). Funnily enough, it is working when using Microsoft's default driver instead. I'll see if a universal solution can be found, but if not, I'll make the new system optional for the next release.
Logged
frdfsnlght
Posts: 7


« Reply #11 on: 21 Feb '12 - 17:10 »
Reply with quoteQuote

I hope you can get it working with the Realtek drivers. I need that driver to allow me to re-assign speaker outputs ports. At least I think I need that driver to allow that. Whatever. I need to ability to re-assign the outputs but I'm not sure I can do that with the MS driver.
Logged
Ian @ un4seen
Administrator
Posts: 17044


« Reply #12 on: 22 Feb '12 - 15:25 »
Reply with quoteQuote

Things seem to start working properly (the sound goes to the correct speakers) if the soundcard's speaker setup is changed once output is initialized, ie. after BASS_Init is called. Do you see the same? Of course, that isn't a practical solution, but it does seem to further suggest something odd going on in the Realtek driver; I haven't seen this with any other soundcards/drivers so far. I'll continue lookng.

In the meantime, you could go back to the release BASS.DLL version and apply the pan/balance control in a DSP function (see the DSPPROC example), or if you would prefer not to deal with DSP functions, you could use the BASS_FX add-on's BASS_FX_BFX_VOLUME effect to do it, something like this...

volfx=BASS_ChannelSetFX(stream, BASS_FX_BFX_VOLUME, 0); // set a volume effect on a stream
BASS_BFX_VOLUME fxparam;
fxparam.lChannel=BASS_BFX_CHAN1; // setting the left volume
fxparam.fVolume=(pan<=0?1:1-pan);
BASS_FXSetParameters(volfx, fxparam); // apply it
fxparam.lChannel=BASS_BFX_CHAN2; // setting the right volume
fxparam.fVolume=(pan>=0?1:1+pan);
BASS_FXSetParameters(volfx, fxparam); // apply it

In both cases (DSP function or BASS_FX_BFX_VOLUME) you can set the DSP/FX on the source stream to have it apply to both splitters, if that is what you want.

If the aim is to play the same thing on the front and rear speakers, another option is to use BASSmix's matrix mixing feature (instead of splitters), eg. create a 4 channel mixer and use a matrix to place the source stream on all 4 speakers. If interested, please see the BASSmix documentation for details on that.
Logged
frdfsnlght
Posts: 7


« Reply #13 on: 22 Feb '12 - 16:31 »
Reply with quoteQuote

I'll have to try out your BassFx solution. And I'll read up on Matrix mixers too. I'm new to all this, so I'm still learning.

Tremendous thanks for the help so far! And good luck figuring out the Realtek driver stuff.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.20 | SMF © 2013, Simple Machines