19 Jun '13 - 10:52 *
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: Duplicate a stream for independent effects  (Read 247 times)
fennick
Posts: 4


« on: 11 Jan '13 - 14:54 »
Reply with quoteQuote

Hi everyone!
The idea is to have different audio modules, to join as I wish, for example:
From an ASIO input,
- Apply DSP/FX_1 and save to file.
- Apply DSP/FX_2 (to the same ASIO input) and stream it.

For this I need to duplicate the output of each module (here ASIO input) into all the next ones, so I can process it independently. How can I do it?

I tried to clone a stream using StreamCreatePush but it doesn't apply the DSP I set to it, any idea?  Roll Eyes

int clone = Bass.BASS_StreamCreatePush(44100, 1, BASSFlag.BASS_SAMPLE_FLOAT, IntPtr.Zero);
CloneProc = new DSPPROC(CloneDSP);
Bass.BASS_ChannelSetDSP(orig, CloneProc, new IntPtr(clone), 0);

Bass.BASS_ChannelSetDSP(clone, myDSP, IntPtr.Zero, 0);  // myDSP is never applied!

...

private void CloneDSP(int handle, int channel, IntPtr buffer, int length, IntPtr user)
{
Bass.BASS_StreamPutData(user.ToInt32(), buffer, length);
}
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #1 on: 11 Jan '13 - 15:37 »
Reply with quoteQuote

That looks like you may just need to adjust the "priority" settings of the DSP/FX in your BASS_ChannelSetDSP/FX calls, ie. make sure the "CloneDSP" has lower priority than the effects so that it receives the sample data after the effects have been applied.
Logged
fennick
Posts: 4


« Reply #2 on: 11 Jan '13 - 16:17 »
Reply with quoteQuote

I want to apply 2 different effects to the same stream. Whatever priority I set, the effect_2 will have the data processed by the effect_1 and not the original stream. That's why I need to clone/duplicate the stream.

I tried to clone a stream using StreamCreatePush, but this doesn't work because if I apply a DSP to "clone" it's not processed. From the help, StreamPutData applies DSP/FX only using ChannelGetData. How? Why?
How can I apply a DSP/FX to a Push stream?
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #3 on: 11 Jan '13 - 16:50 »
Reply with quoteQuote

What are you doing with the "clone" stream, eg. are you calling BASS_ChannelPlay to play it? Any DSP/FX set on a push stream will be applied to the sample data as it goes into the playback buffer, but if you don't play the stream, then the data from the BASS_StreamPutData calls will just be building up. Perhaps you meant to use the BASS_STREAM_DECODE flag in the BASS_StreamCreatePush call, to make it a decoding channel? In that case, you would use BASS_ChannelGetData to take the data (with DSP/FX applied) out of the push stream.
Logged
fennick
Posts: 4


« Reply #4 on: 12 Jan '13 - 08:52 »
Reply with quoteQuote

Thanks Ian for your help, I solved!
I used BASS_STREAM_DECODE and ChannelGetData, and it was it started to process myDSP!

  int clone = Bass.BASS_StreamCreatePush(44100, 1, BASSFlag.[u][b]BASS_STREAM_DECODE[/b][/u] , IntPtr.Zero);
  CloneProc = new DSPPROC(CloneDSP);
  Bass.BASS_ChannelSetDSP(orig, CloneProc, new IntPtr(clone), 0);

  Bass.BASS_ChannelSetDSP(clone, myDSP, IntPtr.Zero, 0);  // myDSP is NOW applied!

  ...

private void CloneDSP(int handle, int channel, IntPtr buffer, int length, IntPtr user)
{
  Bass.BASS_StreamPutData(user.ToInt32(), buffer, length);
  [u][b]Bass.BASS_ChannelGetData(user.ToInt32(), buffer, length);[/b][/u]
}
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines