Author Topic: Pan final mix (STREAMPROC_DEVICE) and/or Stream global  (Read 86 times)

jpf

  • Posts: 198
It seems this isn't currently available, or is it?

I see "Stream global volume level" is implemented as BASS_CONFIG_GVOL_STREAM, but it doesn't help.

I tried applying a DSP translated from your C code (found on bass.chm under "DSPPROC callback") into VB6 to the final mix. It crashes the IDE when I assign a value to pan in the main thread.

I tried embedding the writing and the reading of pan into a CriticalSection. The IDE still crashes.

I thought of locking the final mix channel (BASS_ChannelLock) during writing to pan, though I asumed lock isn't supported on the final mix. Surprisingly BASS_ChannelLock returned TRUE, but the IDE still crashes.

I though of implementing your C pan dsp code on a VC6 dll, as I did for other dsp functions in the past but I'm not confident on getting the CriticalSection right.

Any ideas?

Edit:
This is the draft of the code I wrote so far; it doesn't include a CriticalSection.
Code: [Select]
float pan; // panning position, set as you would the BASS_ATTRIB_PAN attribute

void CALLBACK PanDSP(HDSP handle, DWORD channel, void *buffer, DWORD length, void *user)
{
    float *s = (float*)buffer;
    if (!pan) return; // no processing neeeded for centre panning
    for (; length; length -= 8, s += 2) {
        if (pan < 0) s[1] = s[1] * (1 + pan); // pan left = reduce right
        else s[0] = s[0] * (1 - pan); // vice versa
    }
}

//Public Declare Sub jpSetPan Lib "jplib.dll" ()
void __stdcall jpSetPan(float NewPan)
{
pan=NewPan;
}

//Public Declare Function jpAddressOfPanDsp Lib "jplib.dll" () As Long
int __stdcall jpAddressOfPanDsp()
{
return((int)(PanDSP));
}

« Last Edit: 25 Nov '24 - 22:32 by jpf »

Ian @ un4seen

  • Administrator
  • Posts: 26172
I tried applying a DSP translated from your C code (found on bass.chm under "DSPPROC callback") into VB6 to the final mix. It crashes the IDE when I assign a value to pan in the main thread.

I'm not a VB6 user myself, but I think DSP callback stuff needs to be in a separate module, as in the DSPTEST example in the BASS package? If you haven't already done that, you could try it, perhaps including a function to set the pan value.

I though of implementing your C pan dsp code on a VC6 dll, as I did for other dsp functions in the past but I'm not confident on getting the CriticalSection right.

Any ideas?

Edit:
This is the draft of the code I wrote so far; it doesn't include a CriticalSection.
Code: [Select]
float pan; // panning position, set as you would the BASS_ATTRIB_PAN attribute

void CALLBACK PanDSP(HDSP handle, DWORD channel, void *buffer, DWORD length, void *user)
{
    float *s = (float*)buffer;
    if (!pan) return; // no processing neeeded for centre panning
    for (; length; length -= 8, s += 2) {
        if (pan < 0) s[1] = s[1] * (1 + pan); // pan left = reduce right
        else s[0] = s[0] * (1 - pan); // vice versa
    }
}

//Public Declare Sub jpSetPan Lib "jplib.dll" ()
void __stdcall jpSetPan(float NewPan)
{
pan=NewPan;
}

//Public Declare Function jpAddressOfPanDsp Lib "jplib.dll" () As Long
int __stdcall jpAddressOfPanDsp()
{
return((int)(PanDSP));
}

That looks like it should work fine, with this little change:

Code: [Select]
//Public Declare Sub jpSetPan Lib "jplib.dll" (ByVal NewPan as Single)

A critical section shouldn't be necessary because it won't do any harm if the pan setting is changed while processing.

jpf

  • Posts: 198
I'm not a VB6 user myself, but I think DSP callback stuff needs to be in a separate module, as in the DSPTEST example in the BASS package? If you haven't already done that, you could try it, perhaps including a function to set the pan value.

That stuff was already in a module (not in a class or a form) shared with other global stuff. That should be enough, but anyway I moved it to a new module on its own. The IDE still crashes as before.

About the C dll code:
That looks like it should work fine, with this little change:

Code: [Select]
//Public Declare Sub jpSetPan Lib "jplib.dll" (ByVal NewPan as Single)

You're absolutelly right. I can't believe I forgot to add that!

A critical section shouldn't be necessary because it won't do any harm if the pan setting is changed while processing.

The C dll did the job! The IDE doesn't crash. Thanks!