Registriert seit: 14. Sep 2002
Ort: Steinbach, MB, Canada
301 Beiträge
Delphi XE2 Architect
|
Re: Audiodatei (MP3) leiser werden lassen
10. Feb 2006, 01:21
Hi
Der Folgende Code hatte ich mal für Bass v 2.1 geschrieben.
Delphi-Quellcode:
Private
Cur_Volume : Single;
FFadeOut : Boolean;
FFadeIn : Boolean;
FFadeTime : LongInt;
//------------- Fade in / Out
if (FFadeOut) and (Get_SongLen - Get_PlayTime < FFadeTime) then
Cur_Volume:= 100 * ((Get_SongLen - Get_PlayTime) / FFadeTime)
else
Cur_Volume:= 100;
if (FFadeIn) and (Get_PlayTime < FFadeTime) then
Cur_Volume:= 100 * (Get_PlayTime / FFadeTime)
else
if not (FFadeOut) then
Cur_Volume:= 100;
if Cur_Volume > 100 then Cur_Volume:= 100;
if Cur_Volume < 0 then Cur_Volume:= 0;
BASS_ChannelSetAttributes(Channel, -1, Trunc(Cur_Volume), trunc(Cur_Panning));
{-------------------------------- Volume --------------------------------------}
//This function affects the volume level of all applications using the same output device
//The volume level... 0 (min) - 100
Procedure TAudioEngine.Set_MainVolume(Value : WORD);
Begin
if Value < 0 then Value:= 0;
if Value > 100 then Value:= 100;
if BASS_SetVolume(Value) then
Cur_Volume:= Value;
end;
en Example aus der Bass Hilfe
Zitat:
Fadeout a channel's volume over a period of 1 second.
BASS_ChannelSlideAttributes(channel,-1,0,-101,1000);
BOOL WINAPI BASS_ChannelSlideAttributes(
DWORD handle,
int freq,
int volume,
int pan,
DWORD time
);
Parameters
handle The channel handle... a HCHANNEL, HSTREAM or HMUSIC.
freq The sample rate... 100 (min) - 100000 (max), -1 = leave current.
volume The volume... 0 (silent) - 100 or what's been set with the BASS_CONFIG_MAXVOL config option (max), -1 = leave current, -2 = fade to 0 and stop the channel.
pan The panning position... -100 (left) - 100 (right), -101 = leave current.
time
|
|
Zitat
|