0
0

Hello…

i’m trying to sync one mp3 on two soundcards. that way i can build a mp3 player that supports more then 4 different outputs. i knot that perfect sync is not posible. currently i tried with the following delphi code. works for mp3 with cbr but with vbr, the sync is very bad. any hints?

thanks

[code:rs6eti81]
unit Unit3;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, fmod, fmodtypes;

type
TForm3 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
sys2: FMOD_SYSTEM;
sys1: FMOD_SYSTEM;
Sound1: FMOD_SOUND;
Sound2: FMOD_SOUND;
Chan1: FMOD_CHANNEL;
Chan2: FMOD_CHANNEL;
end;

var
Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
var
CurPos: Cardinal;
begin
// jump to the middle of the mp3 (to test the syncing)
FMOD_Sound_GetLength(Sound1, CurPos, FMOD_TIMEUNIT_MS);
FMOD_Channel_SetPosition(Chan1, CurPos div 2, FMOD_TIMEUNIT_MS);
end;

procedure TForm3.Button2Click(Sender: TObject);
var
CurPos: Cardinal;
begin
// here starts the sync

// get the current position of channel1
FMOD_Channel_GetPosition(Chan1, CurPos, FMOD_TIMEUNIT_MS);
// set the current position of channel1 to channel2
FMOD_Channel_SetPosition(Chan2, CurPos, FMOD_TIMEUNIT_MS);
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
// init devices 1
FMOD_System_Create(sys1);
FMOD_System_SetDriver(Sys1, 1);
FMOD_System_Init(Sys1, 32, FMOD_INIT_NORMAL, nil);
FMOD_System_CreateSound(Sys1, ‘test1.mp3’, FMOD_CREATECOMPRESSEDSAMPLE or FMOD_ACCURATETIME or FMOD_3D or FMOD_SOFTWARE, nil, Sound1);

// init devices 2
FMOD_System_Create(sys2);
FMOD_System_SetDriver(Sys2, 2);
FMOD_System_Init(Sys2, 32, FMOD_INIT_NORMAL, nil);
FMOD_System_CreateSound(Sys2, ‘test1.mp3’, FMOD_CREATECOMPRESSEDSAMPLE or FMOD_ACCURATETIME or FMOD_3D or FMOD_SOFTWARE, nil, Sound2);

// start sound1
FMOD_System_PlaySound(Sys1, FMOD_CHANNEL_FREE, Sound1, false, Chan1);
// start sound 2
FMOD_System_PlaySound(Sys2, FMOD_CHANNEL_FREE, Sound2, false, Chan2);
end;

end.
[/code:rs6eti81]

  • You must to post comments
0
0

You might get a better sync if you start each sound paused, then call System::lockDSP() on both, call setPaused(false) on each channel, then call System::unlockDSP() on both.

Do you have to use 2 soundcards? Why not use a 4 channel output or 5.1 and just position the sound on different speakers, using Channel::setSpeakerMix for example, that would mean perfect sync.

  • You must to post comments
0
0

hi brett.

[quote="brett":10soz6yo]You might get a better sync if you start each sound paused, then call System::lockDSP() on both, call setPaused(false) on each channel, then call System::unlockDSP() on both.[/quote:10soz6yo]

i have to try this.

[quote="brett":10soz6yo]Do you have to use 2 soundcards? Why not use a 4 channel output or 5.1 and just position the sound on different speakers, using Channel::setSpeakerMix for example, that would mean perfect sync.[/quote:10soz6yo]

i have to use more then one soundcard to get more then 4 channels. i plan to create a multiroom player that supports at least 8 or mayby even more different zones. any idea why positioning works pretty good with constant bit rate mp3’s but doesn’t work good with variable bit rate mp3’s? i expected loading the mp3’s with FMOD_ACCURATETIME gives me acurate positioning.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.