Play one song to 2 outputs

Started by djjoy, May 21, 2016, 02:02:09 PM

Previous topic - Next topic

djjoy

Hi,
I'm testing your library. I need load one song. I want to play this song to 2 outputs. One to master(device 1)  and other to (device 2) headphones at the same time.
Can I do this?

Waiting for your reply,

Best Regards


DJ Joy

Administrator

Hello,

this feature is currently not supported but we have already planned to add it in a future release.

Kind Regards

Severino Delaurenti
MultiMedia Soft

djjoy

Thanks Severino for your reply.

I have another request.
Do you have examples for use active dj in delphi?
I would be so grateful.

Best Regards

(Sorry for my English... I'm Spanish)

DJ Joy

Administrator

Hello,
you are welcome.

It must be remarked that, with the current version of the component, if you don't mind to have a small latency (in any case less than 500 ms) between the two output cards, you could already implement the multiple output through a queue and through a custom DSP. The way to proceed would be as follows:

- Let the control instance 2 players (A and B) and set for each of them the needed output device through the InitDJSystem or at a later time through the StreamOutputDeviceSet method
- Load the sound file in player A (using LoadSound or any other loading method)
- Create a sound queue in player B using the StreamQueueCreate method
- Attach a custom DSP to player A: the callback function of this custom DSP should get the input buffer and use it to feed the queue of player B through the StreamQueuePushData method
- At this point you could start playback on both players

Details about the management of custom DSPs can be found inside the related documentation's tutorial:
http://www.activedjstudio.com/help/amp3dj_00016b.htm
As you may understand, in this case you won't need to modify audio data in input but simply pass contents of the input audio buffer to the queue of player B.

Although we don't make use of Delphi ourselves, we have some very old Delphi porting of some of our samples related to version 3 of the component: some of the control's methods used in these samples is certainly deprecated but it's likely that they could give you a starting point. Please, find the zip attached.

Hope this helps.

Kind Regards

Severino Delaurenti
MultiMedia Soft

djjoy

Hi Severino...
Many thanks for your fast reply.

I will try your response.

DJ Joy.

djjoy

Hi severino again,

I'm trying to add a customdsp for send data to StreamQueuePushData. I don't know how to do this in delphi:
My idea is get data for each decks ( by custom dsp) and save it in a global var ( s1 and s2).
In the streamqueue, get data from s1 and s2.

I create callback for dsp:



var
m_idDspHeadInternal : integer;
m_idDspHeadInternal1 : integer;

s1:^extended; //buffer to head on player 0
l1: integer;   //length of buffer on player 0
s2:^extended; //buffer to head on player 1
l2: integer;   //length of buffer on player 1

procedure SetheadCallback(bufferSamples: pointer; bufferSamplesLength: DWORD; nUserData: DWORD);
     var
         a : Integer;
         r: olevariant;
begin
  //fill the buffer and get bufferlength
  s1 := bufferSamples;
  l1:=  bufferSamplesLength;
end;

procedure SetheadCallback1(bufferSamples: pointer; bufferSamplesLength: DWORD; nUserData: DWORD);
     var
         a : Integer;
         r: olevariant;
begin
  //fill the buffer and get bufferlength
  s2 := bufferSamples;
  l2:=  bufferSamplesLength;
end;


//on form create
procedure TForm1.FormCreate(Sender: TObject);
begin
Amp3dj1.CustomDSP.UseFloatSamples(BOOL_TRUE);
m_idDspHeadInternal := Amp3dj1.CustomDSP.InternalLoad(0);
m_idDspHeadInternal1 := Amp3dj1.CustomDSP.InternalLoad(1);
Amp3dj1.CustomDSP.InternalSetFunction(0, m_idDspHeadInternal,  SetheadCallback);  //<--Here is the problem.
Amp3dj1.CustomDSP.InternalSetFunction(1, m_idDspHeadInternal1, SetheadCallback1);  //<--Here is the problem.
//How can I call InternalSetFunction?? I get error Not Enough actual parameters.
// I try with @SetHeadCallback
// with ^SetHeadCallback
// with integer(SetHeadCallback)

Amp3dj1.CustomDSP.Enable(0,m_idDspHeadInternal, BOOL_TRUE,0,0);
Amp3dj1.CustomDSP.Enable(1,m_idDspHeadInterna1l, BOOL_TRUE,0,0);
//I create a streamQueue Player
Amp3dj1.StreamQueueCreate (2, 44100, 2, 16);  // I create the headphones channel on player 2
end;

//When streamqueue needs data, i fill it with the sum of headphones buffers
procedure TForm.Amp3dj1StreamQueueStalled(ASender: TObject; nPlayer: SmallInt);
var
  r: olevariant;
  a:integer;
begin
  r :=  varArrayCreate([0,L1],varSingle);
  for a := 0 to L1 -1 do
  begin
     r[a] := s1^ +  s2^;  // I have to divide by 2 ????
     inc(s1);
     inc(s2);

  end;

  amp3dj1.StreamQueuePushData(1, r, L1);

end;



Can you help me?

Best Regards,

Jose Maria

Administrator

Hello,

unfortunately we are not expert about Delphi language but it's likely that the problem could be the fact that you are not declaring the dsp callback functions as "stdcall;". You may try to change



procedure SetheadCallback(bufferSamples: pointer; bufferSamplesLength: DWORD; nUserData: DWORD);



to



procedure SetheadCallback(bufferSamples: pointer; bufferSamplesLength: DWORD; nUserData: DWORD); stdcall;



Hope this helps.

Kind Regards

Severino Delaurenti
MultiMedia Soft