Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
Delphi 6 Personal
|
Re: Sounds übereinander abspielen
16. Jun 2009, 21:37
Oder einfach die BASS.DLL ( BASS.DLL) verwenden:
Delphi-Quellcode:
// ... *schnipp* ... //
implementation
{$R *.dfm}
var
WavFileName1 : string;
WavFileName2 : string;
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Caption := Application.Title;
WavFileName1 := ExtractFilePath(ParamStr(0)) + '\WavSnd\LongSound.wav'; // oder mp3-Files
WavFileName2 := ExtractFilePath(ParamStr(0)) + '\WavSnd\ShortSound.wav';
// Bass.dll initialisieren
if not BASS_Init(-1, 44100, 0, 0, nil) then
begin
ShowMessage('Can''t initialize sound.');
Application.Terminate; // Stop & Exit Prograam
end;
/////// SOUNDVOLUME SETUP //////////////////////////////////////////////////
//
// Muss man nicht, kann man aber wenn man will
//
// Get Stream global Volume
StreamVol := BASS_GetConfig(BASS_CONFIG_GVOL_STREAM);
// immer ein bissel leiser abends ;-)
// 1000 = 100%
// 800 = 80%
// 100 = 10%
if StreamVol > 800 then
begin
StreamVol := 800;
BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, StreamVol);
end;
////////////////////////////////////////////////////////////////////////////
// Load Wave-File
hStream1 := BASS_StreamCreateFile(False, PChar(WavFileName1), 0, 0, 0);
hStream2 := BASS_StreamCreateFile(False, PChar(WavFileName2), 0, 0, 0);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
// alles Freigeben
if hStream1 <> 0 then
begin
BASS_ChannelStop(hStream1); // muss man nich anhalten, ich machs
BASS_StreamFree(hStream1);
end;
if hStream2 <> 0 then
begin
BASS_ChannelStop(hStream2); // muss man nich anhalten, ich machs
BASS_StreamFree(hStream2);
end;
// Bass.dll deinitialisieren
BASS_Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// "BASS_ChannelPlay(Stream1, True);" True = Play from Start
BASS_ChannelPlay(hStream1, True);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
BASS_ChannelPlay(hStream2, True);
end;
end.
|
|
Zitat
|