aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-05-10 12:28:56 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-05-10 12:28:56 +0000
commitc6da424a1508eae4538244b4d00ddf1f0436b1b7 (patch)
tree18a125cc8a590c0916811e47c912134278e92bb7 /Game
parent8af89b5940bd15b013e3f48536888e352eb1c43b (diff)
downloadusdx-c6da424a1508eae4538244b4d00ddf1f0436b1b7.tar.gz
usdx-c6da424a1508eae4538244b4d00ddf1f0436b1b7.tar.xz
usdx-c6da424a1508eae4538244b4d00ddf1f0436b1b7.zip
Volumes are floating point values (single) now. The range changed from [0 .. 100] to [0.0 .. 1.0]
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1081 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game')
-rw-r--r--Game/Code/Classes/UAudioInput_Bass.pas16
-rw-r--r--Game/Code/Classes/UAudioInput_Portaudio.pas23
-rw-r--r--Game/Code/Classes/UAudioPlaybackBase.pas10
-rw-r--r--Game/Code/Classes/UAudioPlayback_Bass.pas28
-rw-r--r--Game/Code/Classes/UAudioPlayback_SDL.pas8
-rw-r--r--Game/Code/Classes/UAudioPlayback_SoftMixer.pas53
-rw-r--r--Game/Code/Classes/UMedia_dummy.pas12
-rw-r--r--Game/Code/Classes/UMusic.pas14
-rw-r--r--Game/Code/Classes/URecord.pas10
-rw-r--r--Game/Code/Screens/UScreenCredits.pas2
-rw-r--r--Game/Code/Screens/UScreenEditSub.pas4
-rw-r--r--Game/Code/Screens/UScreenOptionsRecord.pas20
-rw-r--r--Game/Code/Screens/UScreenSong.pas25
13 files changed, 113 insertions, 112 deletions
diff --git a/Game/Code/Classes/UAudioInput_Bass.pas b/Game/Code/Classes/UAudioInput_Bass.pas
index b4d0e52b..d086a23a 100644
--- a/Game/Code/Classes/UAudioInput_Bass.pas
+++ b/Game/Code/Classes/UAudioInput_Bass.pas
@@ -52,8 +52,8 @@ type
function Start(): boolean; override;
function Stop(): boolean; override;
- function GetVolume(): integer; override;
- procedure SetVolume(Volume: integer); override;
+ function GetVolume(): single; override;
+ procedure SetVolume(Volume: single); override;
end;
var
@@ -270,7 +270,7 @@ begin
RecordStream := 0;
end;
-function TBassInputDevice.GetVolume(): integer;
+function TBassInputDevice.GetVolume(): single;
var
SourceIndex: integer;
lVolume: Single;
@@ -291,10 +291,10 @@ begin
Log.LogError('BASS_RecordGetInput: ' + AudioCore.ErrorGetString() , 'TBassInputDevice.GetVolume');
Exit;
end;
- Result := Round(lVolume * 100);
+ Result := lVolume;
end;
-procedure TBassInputDevice.SetVolume(Volume: integer);
+procedure TBassInputDevice.SetVolume(Volume: single);
var
SourceIndex: integer;
begin
@@ -308,12 +308,12 @@ begin
end;
// clip volume to valid range
- if (Volume > 100) then
- Volume := 100
+ if (Volume > 1.0) then
+ Volume := 1.0
else if (Volume < 0) then
Volume := 0;
- if (not BASS_RecordSetInput(SourceIndex, 0, Volume/100)) then
+ if (not BASS_RecordSetInput(SourceIndex, 0, Volume)) then
begin
Log.LogError('BASS_RecordSetInput: ' + AudioCore.ErrorGetString() , 'TBassInputDevice.SetVolume');
end;
diff --git a/Game/Code/Classes/UAudioInput_Portaudio.pas b/Game/Code/Classes/UAudioInput_Portaudio.pas
index 183c482d..50543e17 100644
--- a/Game/Code/Classes/UAudioInput_Portaudio.pas
+++ b/Game/Code/Classes/UAudioInput_Portaudio.pas
@@ -51,8 +51,8 @@ type
function Start(): boolean; override;
function Stop(): boolean; override;
- function GetVolume(): integer; override;
- procedure SetVolume(Volume: integer); override;
+ function GetVolume(): single; override;
+ procedure SetVolume(Volume: single); override;
end;
function MicrophoneCallback(input: Pointer; output: Pointer; frameCount: Longword;
@@ -214,33 +214,26 @@ begin
RecordStream := nil;
end;
-function TPortaudioInputDevice.GetVolume(): integer;
+function TPortaudioInputDevice.GetVolume(): single;
begin
Result := 0;
{$IFDEF UsePortmixer}
if (Mixer <> nil) then
- begin
- Result := Round(Px_GetInputVolume(Mixer) * 100);
- // clip to valid range
- if (Result > 100) then
- Result := 100
- else if (Result < 0) then
- Result := 0;
- end;
+ Result := Px_GetInputVolume(Mixer);
{$ENDIF}
end;
-procedure TPortaudioInputDevice.SetVolume(Volume: integer);
+procedure TPortaudioInputDevice.SetVolume(Volume: single);
begin
{$IFDEF UsePortmixer}
if (Mixer <> nil) then
begin
// clip to valid range
- if (Volume > 100) then
- Volume := 100
+ if (Volume > 1.0) then
+ Volume := 1.0
else if (Volume < 0) then
Volume := 0;
- Px_SetInputVolume(Mixer, Volume / 100);
+ Px_SetInputVolume(Mixer, Volume);
end;
{$ENDIF}
end;
diff --git a/Game/Code/Classes/UAudioPlaybackBase.pas b/Game/Code/Classes/UAudioPlaybackBase.pas
index f1fe26f9..0251b8e8 100644
--- a/Game/Code/Classes/UAudioPlaybackBase.pas
+++ b/Game/Code/Classes/UAudioPlaybackBase.pas
@@ -28,7 +28,7 @@ type
procedure Play;
procedure Pause;
procedure Stop;
- procedure FadeIn(Time: real; TargetVolume: integer);
+ procedure FadeIn(Time: real; TargetVolume: single);
procedure SetPosition(Time: real);
function GetPosition: real;
@@ -39,8 +39,8 @@ type
// function SetOutputDevice(Device: TAudioOutputDevice): boolean;
function GetOutputDeviceList(): TAudioOutputDeviceList;
- procedure SetAppVolume(Volume: integer); virtual; abstract;
- procedure SetVolume(Volume: integer);
+ procedure SetAppVolume(Volume: single); virtual; abstract;
+ procedure SetVolume(Volume: single);
procedure SetLoop(Enabled: boolean);
procedure Rewind;
@@ -149,13 +149,13 @@ begin
Result := true;
end;
-procedure TAudioPlaybackBase.SetVolume(Volume: Integer);
+procedure TAudioPlaybackBase.SetVolume(Volume: single);
begin
if assigned(MusicStream) then
MusicStream.Volume := Volume;
end;
-procedure TAudioPlaybackBase.FadeIn(Time: real; TargetVolume: integer);
+procedure TAudioPlaybackBase.FadeIn(Time: real; TargetVolume: single);
begin
if assigned(MusicStream) then
MusicStream.FadeIn(Time, TargetVolume);
diff --git a/Game/Code/Classes/UAudioPlayback_Bass.pas b/Game/Code/Classes/UAudioPlayback_Bass.pas
index 2667bf6f..53fbd921 100644
--- a/Game/Code/Classes/UAudioPlayback_Bass.pas
+++ b/Game/Code/Classes/UAudioPlayback_Bass.pas
@@ -38,7 +38,7 @@ type
procedure Play(); override;
procedure Pause(); override;
procedure Stop(); override;
- procedure FadeIn(Time: real; TargetVolume: integer); override;
+ procedure FadeIn(Time: real; TargetVolume: single); override;
procedure Close(); override;
@@ -46,8 +46,8 @@ type
procedure SetLoop(Enabled: boolean); override;
function GetLength(): real; override;
function GetStatus(): TStreamStatus; override;
- function GetVolume(): integer; override;
- procedure SetVolume(volume: integer); override;
+ function GetVolume(): single; override;
+ procedure SetVolume(volume: single); override;
procedure AddSoundEffect(effect: TSoundEffect); override;
procedure RemoveSoundEffect(effect: TSoundEffect); override;
@@ -83,7 +83,7 @@ type
function GetName: String; override;
function InitializePlayback(): boolean; override;
function FinalizePlayback: boolean; override;
- procedure SetAppVolume(Volume: integer); override;
+ procedure SetAppVolume(Volume: single); override;
end;
TBassOutputDevice = class(TAudioOutputDevice)
@@ -132,13 +132,13 @@ begin
BASS_ChannelPlay(Handle, restart);
end;
-procedure TBassPlaybackStream.FadeIn(Time: real; TargetVolume: integer);
+procedure TBassPlaybackStream.FadeIn(Time: real; TargetVolume: single);
begin
// start stream
BASS_ChannelPlay(Handle, true);
// start fade-in: slide from fadeStart- to fadeEnd-volume in FadeInTime
- BASS_ChannelSlideAttribute(Handle, BASS_ATTRIB_VOL, TargetVolume/100, Trunc(Time * 1000));
+ BASS_ChannelSlideAttribute(Handle, BASS_ATTRIB_VOL, TargetVolume, Trunc(Time * 1000));
end;
procedure TBassPlaybackStream.Pause();
@@ -156,7 +156,7 @@ begin
Reset();
end;
-function TBassPlaybackStream.GetVolume(): integer;
+function TBassPlaybackStream.GetVolume(): single;
var
lVolume: single;
begin
@@ -167,18 +167,18 @@ begin
Result := 0;
Exit;
end;
- Result := Round(lVolume * 100);
+ Result := Round(lVolume);
end;
-procedure TBassPlaybackStream.SetVolume(volume: integer);
+procedure TBassPlaybackStream.SetVolume(volume: single);
begin
// clamp volume
if volume < 0 then
volume := 0;
- if volume > 100 then
- volume := 100;
+ if volume > 1.0 then
+ volume := 1.0;
// set volume
- BASS_ChannelSetAttribute(Handle, BASS_ATTRIB_VOL, volume/100);
+ BASS_ChannelSetAttribute(Handle, BASS_ATTRIB_VOL, volume);
end;
function TBassPlaybackStream.GetPosition: real;
@@ -576,10 +576,10 @@ begin
end;
end;
-procedure TAudioPlayback_Bass.SetAppVolume(Volume: integer);
+procedure TAudioPlayback_Bass.SetAppVolume(Volume: single);
begin
// Sets Volume only for this Application (now ranges from 0..10000)
- BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, Volume*100);
+ BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, Round(Volume*10000));
end;
diff --git a/Game/Code/Classes/UAudioPlayback_SDL.pas b/Game/Code/Classes/UAudioPlayback_SDL.pas
index ed5a208b..39ecc72f 100644
--- a/Game/Code/Classes/UAudioPlayback_SDL.pas
+++ b/Game/Code/Classes/UAudioPlayback_SDL.pas
@@ -34,7 +34,7 @@ type
function FinalizeAudioPlaybackEngine(): boolean; override;
public
function GetName: String; override;
- procedure MixBuffers(dst, src: PChar; size: Cardinal; volume: Integer); override;
+ procedure MixBuffers(dst, src: PChar; size: Cardinal; volume: Single); override;
end;
var
@@ -134,11 +134,9 @@ begin
Result := true;
end;
-procedure TAudioPlayback_SDL.MixBuffers(dst, src: PChar; size: Cardinal; volume: Integer);
+procedure TAudioPlayback_SDL.MixBuffers(dst, src: PChar; size: Cardinal; volume: Single);
begin
- // Note: (volume * SDL_MIX_MAXVOLUME) may exceed High(Integer)
- // if SDL_MIX_MAXVOLUME (=128 at the moment) changes
- SDL_MixAudio(PUInt8(dst), PUInt8(src), size, volume * SDL_MIX_MAXVOLUME div 100);
+ SDL_MixAudio(PUInt8(dst), PUInt8(src), size, Round(volume * SDL_MIX_MAXVOLUME));
end;
diff --git a/Game/Code/Classes/UAudioPlayback_SoftMixer.pas b/Game/Code/Classes/UAudioPlayback_SoftMixer.pas
index 431653d0..714e19ae 100644
--- a/Game/Code/Classes/UAudioPlayback_SoftMixer.pas
+++ b/Game/Code/Classes/UAudioPlayback_SoftMixer.pas
@@ -32,14 +32,15 @@ type
Status: TStreamStatus;
Loop: boolean;
- _volume: integer;
InternalLock: PSDL_Mutex;
SoundEffects: TList;
+ _volume: single;
+
FadeInStartTime, FadeInTime: cardinal;
- FadeInStartVolume, FadeInTargetVolume: integer;
+ FadeInStartVolume, FadeInTargetVolume: single;
procedure Reset();
@@ -57,14 +58,14 @@ type
procedure Play(); override;
procedure Pause(); override;
procedure Stop(); override;
- procedure FadeIn(Time: real; TargetVolume: integer); override;
+ procedure FadeIn(Time: real; TargetVolume: single); override;
procedure Close(); override;
function GetLength(): real; override;
function GetStatus(): TStreamStatus; override;
- function GetVolume(): integer; override;
- procedure SetVolume(Volume: integer); override;
+ function GetVolume(): single; override;
+ procedure SetVolume(Volume: single); override;
function GetLoop(): boolean; override;
procedure SetLoop(Enabled: boolean); override;
function GetPosition: real; override;
@@ -87,13 +88,13 @@ type
mixerBuffer: PChar;
internalLock: PSDL_Mutex;
- appVolume: integer;
+ appVolume: single;
procedure Lock(); {$IFDEF HasInline}inline;{$ENDIF}
procedure Unlock(); {$IFDEF HasInline}inline;{$ENDIF}
- function GetVolume(): integer;
- procedure SetVolume(volume: integer);
+ function GetVolume(): single;
+ procedure SetVolume(volume: single);
public
constructor Create(Engine: TAudioPlayback_SoftMixer);
destructor Destroy(); override;
@@ -101,7 +102,7 @@ type
procedure RemoveStream(stream: TAudioPlaybackStream);
function ReadData(Buffer: PChar; BufSize: integer): integer;
- property Volume: integer READ GetVolume WRITE SetVolume;
+ property Volume: single READ GetVolume WRITE SetVolume;
end;
TAudioPlayback_SoftMixer = class(TAudioPlaybackBase)
@@ -122,12 +123,12 @@ type
function InitializePlayback(): boolean; override;
function FinalizePlayback: boolean; override;
- procedure SetAppVolume(Volume: integer); override;
+ procedure SetAppVolume(Volume: single); override;
function GetMixer(): TAudioMixerStream; {$IFDEF HasInline}inline;{$ENDIF}
function GetAudioFormatInfo(): TAudioFormatInfo;
- procedure MixBuffers(dst, src: PChar; size: Cardinal; volume: Integer); virtual;
+ procedure MixBuffers(dst, src: PChar; size: Cardinal; volume: Single); virtual;
end;
implementation
@@ -150,7 +151,7 @@ begin
activeStreams := TList.Create;
internalLock := SDL_CreateMutex();
- appVolume := 100;
+ appVolume := 1.0;
end;
destructor TAudioMixerStream.Destroy();
@@ -172,14 +173,14 @@ begin
SDL_mutexV(internalLock);
end;
-function TAudioMixerStream.GetVolume(): integer;
+function TAudioMixerStream.GetVolume(): single;
begin
Lock();
result := appVolume;
Unlock();
end;
-procedure TAudioMixerStream.SetVolume(volume: integer);
+procedure TAudioMixerStream.SetVolume(volume: single);
begin
Lock();
appVolume := volume;
@@ -257,7 +258,7 @@ begin
begin
// mix stream-data with mixer-buffer
// Note: use Self.appVolume instead of Self.Volume to prevent recursive locking
- Engine.MixBuffers(Buffer, mixerBuffer, size, appVolume * stream.Volume div 100);
+ Engine.MixBuffers(Buffer, mixerBuffer, size, appVolume * stream.Volume);
end;
end;
@@ -388,7 +389,7 @@ begin
if not InitFormatConversion() then
Exit;
- _volume := 100;
+ _volume := 1.0;
result := true;
end;
@@ -415,7 +416,7 @@ begin
mixer.AddStream(Self);
end;
-procedure TGenericPlaybackStream.FadeIn(Time: real; TargetVolume: integer);
+procedure TGenericPlaybackStream.FadeIn(Time: real; TargetVolume: single);
begin
FadeInTime := Trunc(Time * 1000);
FadeInStartTime := SDL_GetTicks();
@@ -726,7 +727,7 @@ begin
DecodeStream.Position := Time;
end;
-function TGenericPlaybackStream.GetVolume(): integer;
+function TGenericPlaybackStream.GetVolume(): single;
var
FadeAmount: Single;
begin
@@ -745,7 +746,7 @@ begin
else
begin
// fading in progress
- _volume := Trunc(FadeAmount*FadeInTargetVolume + (1-FadeAmount)*FadeInStartVolume);
+ _volume := FadeAmount*FadeInTargetVolume + (1-FadeAmount)*FadeInStartVolume;
end;
end;
// return current volume
@@ -753,14 +754,14 @@ begin
Unlock();
end;
-procedure TGenericPlaybackStream.SetVolume(volume: integer);
+procedure TGenericPlaybackStream.SetVolume(volume: single);
begin
Lock();
// stop fading
FadeInTime := 0;
// clamp volume
- if (volume > 100) then
- _volume := 100
+ if (volume > 1.0) then
+ _volume := 1.0
else if (volume < 0) then
_volume := 0
else
@@ -850,13 +851,13 @@ begin
result := playbackStream;
end;
-procedure TAudioPlayback_SoftMixer.SetAppVolume(Volume: integer);
+procedure TAudioPlayback_SoftMixer.SetAppVolume(Volume: single);
begin
// sets volume only for this application
MixerStream.Volume := Volume;
end;
-procedure TAudioPlayback_SoftMixer.MixBuffers(dst, src: PChar; size: Cardinal; volume: Integer);
+procedure TAudioPlayback_SoftMixer.MixBuffers(dst, src: PChar; size: Cardinal; volume: Single);
var
SampleIndex: Cardinal;
SampleInt: Integer;
@@ -872,7 +873,7 @@ begin
while (SampleIndex < size) do
begin
// apply volume and sum with previous mixer value
- SampleInt := PSmallInt(@dst[SampleIndex])^ + PSmallInt(@src[SampleIndex])^ * volume div 100;
+ SampleInt := PSmallInt(@dst[SampleIndex])^ + Round(PSmallInt(@src[SampleIndex])^ * volume);
// clip result
if (SampleInt > High(SmallInt)) then
SampleInt := High(SmallInt)
@@ -889,7 +890,7 @@ begin
while (SampleIndex < size) do
begin
// apply volume and sum with previous mixer value
- SampleFlt := PSingle(@dst[SampleIndex])^ + PSingle(@src[SampleIndex])^ * volume/100;
+ SampleFlt := PSingle(@dst[SampleIndex])^ + PSingle(@src[SampleIndex])^ * volume;
// clip result
if (SampleFlt > 1.0) then
SampleFlt := 1.0
diff --git a/Game/Code/Classes/UMedia_dummy.pas b/Game/Code/Classes/UMedia_dummy.pas
index ad3aa94e..bb25a0aa 100644
--- a/Game/Code/Classes/UMedia_dummy.pas
+++ b/Game/Code/Classes/UMedia_dummy.pas
@@ -65,9 +65,9 @@ type
function FinalizePlayback: boolean;
function GetOutputDeviceList(): TAudioOutputDeviceList;
- procedure FadeIn(Time: real; TargetVolume: integer);
- procedure SetAppVolume(Volume: integer);
- procedure SetVolume(Volume: integer);
+ procedure FadeIn(Time: real; TargetVolume: single);
+ procedure SetAppVolume(Volume: single);
+ procedure SetVolume(Volume: single);
procedure SetLoop(Enabled: boolean);
procedure Rewind;
@@ -182,11 +182,11 @@ begin
Result := DummyOutputDeviceList;
end;
-procedure Tmedia_dummy.SetAppVolume(Volume: integer);
+procedure Tmedia_dummy.SetAppVolume(Volume: single);
begin
end;
-procedure Tmedia_dummy.SetVolume(Volume: integer);
+procedure Tmedia_dummy.SetVolume(Volume: single);
begin
end;
@@ -194,7 +194,7 @@ procedure Tmedia_dummy.SetLoop(Enabled: boolean);
begin
end;
-procedure Tmedia_dummy.FadeIn(Time: real; TargetVolume: integer);
+procedure Tmedia_dummy.FadeIn(Time: real; TargetVolume: single);
begin
end;
diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas
index 9977661f..9c029acd 100644
--- a/Game/Code/Classes/UMusic.pas
+++ b/Game/Code/Classes/UMusic.pas
@@ -148,15 +148,15 @@ type
procedure SetPosition(Time: real); virtual; abstract;
function GetLength(): real; virtual; abstract;
function GetStatus(): TStreamStatus; virtual; abstract;
- function GetVolume(): integer; virtual; abstract;
- procedure SetVolume(Volume: integer); virtual; abstract;
+ function GetVolume(): single; virtual; abstract;
+ procedure SetVolume(Volume: single); virtual; abstract;
function GetLoop(): boolean; virtual; abstract;
procedure SetLoop(Enabled: boolean); virtual; abstract;
public
procedure Play(); virtual; abstract;
procedure Pause(); virtual; abstract;
procedure Stop(); virtual; abstract;
- procedure FadeIn(Time: real; TargetVolume: integer); virtual; abstract;
+ procedure FadeIn(Time: real; TargetVolume: single); virtual; abstract;
procedure GetFFTData(var data: TFFTData); virtual; abstract;
function GetPCMData(var data: TPCMData): Cardinal; virtual; abstract;
@@ -167,7 +167,7 @@ type
property Length: real READ GetLength;
property Position: real READ GetPosition WRITE SetPosition;
property Status: TStreamStatus READ GetStatus;
- property Volume: integer READ GetVolume WRITE SetVolume;
+ property Volume: single READ GetVolume WRITE SetVolume;
property Loop: boolean READ GetLoop WRITE SetLoop;
end;
@@ -237,10 +237,10 @@ type
function FinalizePlayback: boolean;
function GetOutputDeviceList(): TAudioOutputDeviceList;
- procedure SetAppVolume(Volume: integer);
- procedure SetVolume(Volume: integer);
+ procedure SetAppVolume(Volume: single);
+ procedure SetVolume(Volume: single);
procedure SetLoop(Enabled: boolean);
- procedure FadeIn(Time: real; TargetVolume: integer);
+ procedure FadeIn(Time: real; TargetVolume: single);
procedure Rewind;
function Finished: boolean;
diff --git a/Game/Code/Classes/URecord.pas b/Game/Code/Classes/URecord.pas
index 55dedd1f..6d24e0f4 100644
--- a/Game/Code/Classes/URecord.pas
+++ b/Game/Code/Classes/URecord.pas
@@ -85,8 +85,8 @@ type
function Start(): boolean; virtual; abstract;
function Stop(): boolean; virtual; abstract;
- function GetVolume(): integer; virtual; abstract;
- procedure SetVolume(Volume: integer); virtual; abstract;
+ function GetVolume(): single; virtual; abstract;
+ procedure SetVolume(Volume: single); virtual; abstract;
end;
TAudioInputProcessor = class
@@ -247,10 +247,10 @@ end;
procedure TCaptureBuffer.AnalyzeBuffer;
var
- Volume: real;
- MaxVolume: real;
+ Volume: single;
+ MaxVolume: single;
SampleIndex: integer;
- Threshold: real;
+ Threshold: single;
begin
ToneValid := false;
ToneAbs := -1;
diff --git a/Game/Code/Screens/UScreenCredits.pas b/Game/Code/Screens/UScreenCredits.pas
index ce3b6046..f7f1fca7 100644
--- a/Game/Code/Screens/UScreenCredits.pas
+++ b/Game/Code/Screens/UScreenCredits.pas
@@ -1309,7 +1309,7 @@ Log.LogStatus('',' JB-4');
CTime_hold:=0;
AudioPlayback.Stop;
AudioPlayback.Open(soundpath + 'credits-outro-tune.mp3');
- AudioPlayback.SetVolume(20);
+ AudioPlayback.SetVolume(0.2);
AudioPlayback.SetLoop(True);
AudioPlayback.Play;
end;
diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas
index 0a80af8b..3bf57692 100644
--- a/Game/Code/Screens/UScreenEditSub.pas
+++ b/Game/Code/Screens/UScreenEditSub.pas
@@ -1174,7 +1174,7 @@ begin
Lines[0].Line[0].Note[0].Color := 1;
AudioPlayback.Open(CurrentSong.Path + CurrentSong.Mp3);
//Set Down Music Volume for Better hearability of Midi Sounds
- //Music.SetVolume(40);
+ //Music.SetVolume(0.4);
Lyric.Clear;
Lyric.X := 400;
@@ -1315,7 +1315,7 @@ begin
MidiOut.Close;
MidiOut.Free;
{$ENDIF}
- //Music.SetVolume(100);
+ //Music.SetVolume(1.0);
end;
function TScreenEditSub.GetNoteName(Note: Integer): String;
diff --git a/Game/Code/Screens/UScreenOptionsRecord.pas b/Game/Code/Screens/UScreenOptionsRecord.pas
index 8e3d0f67..8db5ede9 100644
--- a/Game/Code/Screens/UScreenOptionsRecord.pas
+++ b/Game/Code/Screens/UScreenOptionsRecord.pas
@@ -64,7 +64,7 @@ type
procedure StartPreview;
procedure StopPreview;
procedure UpdateInputDevice;
- procedure ChangeVolume(VolumeChange: integer);
+ procedure ChangeVolume(VolumeChange: single);
procedure DrawVolume(x, y, Width, Height: single);
procedure DrawVUMeter(const State: TDrawState; x, y, Width, Height: single);
procedure DrawPitch(const State: TDrawState; x, y, Width, Height: single);
@@ -119,13 +119,13 @@ begin
begin
// FIXME: add a nice volume-slider instead
// or at least provide visualization and acceleration if the user holds the key pressed.
- ChangeVolume(2);
+ ChangeVolume(0.02);
end;
'-':
begin
// FIXME: add a nice volume-slider instead
// or at least provide visualization and acceleration if the user holds the key pressed.
- ChangeVolume(-2);
+ ChangeVolume(-0.02);
end;
'T':
begin
@@ -203,6 +203,8 @@ begin
PreviewDeviceIndex := -1;
+ WidgetYPos := 0;
+
// init sliders if at least one device was detected
if (Length(AudioInputProcessor.DeviceList) > 0) then
begin
@@ -292,7 +294,9 @@ begin
// add Exit-button
ButtonTheme := Theme.OptionsRecord.ButtonExit;
- ButtonTheme.Y := WidgetYPos;
+ // adjust button position
+ if (WidgetYPos <> 0) then
+ ButtonTheme.Y := WidgetYPos;
AddButton(ButtonTheme);
if (Length(Button[0].Text) = 0) then
AddButtonText(14, 20, Theme.Options.Description[7]);
@@ -372,10 +376,10 @@ begin
StartPreview();
end;
-procedure TScreenOptionsRecord.ChangeVolume(VolumeChange: integer);
+procedure TScreenOptionsRecord.ChangeVolume(VolumeChange: single);
var
InputDevice: TAudioInputDevice;
- Volume: integer;
+ Volume: single;
begin
// validate CurrentDeviceIndex
if ((CurrentDeviceIndex < 0) or
@@ -391,7 +395,7 @@ begin
// set new volume
Volume := InputDevice.GetVolume() + VolumeChange;
InputDevice.SetVolume(Volume);
- //DebugWriteln('Volume: ' + inttostr(InputDevice.GetVolume));
+ //DebugWriteln('Volume: ' + floattostr(InputDevice.GetVolume));
// volume must be polled again
NextVolumePollTime := 0;
@@ -700,7 +704,7 @@ begin
if (SDL_GetTicks() >= NextVolumePollTime) then
begin
NextVolumePollTime := SDL_GetTicks() + 500; // next poll in 500ms
- SourceVolume := Device.GetVolume()/100;
+ SourceVolume := Device.GetVolume();
end;
// get source select slide
diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas
index 82d5100a..06314bcd 100644
--- a/Game/Code/Screens/UScreenSong.pas
+++ b/Game/Code/Screens/UScreenSong.pas
@@ -1497,17 +1497,21 @@ end;
procedure TScreenSong.onHide;
begin
- //When Music Fading is activated, Turn Music to 100 %
- If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then
- AudioPlayback.SetVolume(100);
+ // if music fading is activated, turn music to 100%
+ If (IPreviewVolumeVals[Ini.PreviewVolume] <> 1.0) or (Ini.PreviewFading <> 0) then
+ AudioPlayback.SetVolume(1.0);
- //If Preview is deactivated: Load MUsicfile now
- If (Ini.PreviewVolume = 0) then
+ // if preview is deactivated: load musicfile now
+ If (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then
AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3);
- //When hide then Stop Music (For Party Mode Popup on Exit)
- if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) and (AudioPlayback <> nil) then
- AudioPlayback.Stop;
+ // if hide then stop music (for party mode popup on exit)
+ if (Display.NextScreen <> @ScreenSing) and
+ (Display.NextScreen <> @ScreenSingModi) then
+ begin
+ if (AudioPlayback <> nil) then
+ AudioPlayback.Stop;
+ end;
end;
procedure TScreenSong.DrawExtensions;
@@ -1613,6 +1617,7 @@ begin
DrawExtensions;
+ Result := true;
end;
procedure TScreenSong.SelectNext;
@@ -1701,14 +1706,14 @@ begin
if (Ini.PreviewFading = 0) then
begin
// music fade disabled: start with full volume
- AudioPlayback.SetVolume(Ini.PreviewVolume * 10);
+ AudioPlayback.SetVolume(IPreviewVolumeVals[Ini.PreviewVolume]);
AudioPlayback.Play()
end
else
begin
// music fade enabled: start muted and fade-in
AudioPlayback.SetVolume(0);
- AudioPlayback.FadeIn(Ini.PreviewFading, Ini.PreviewVolume * 10);
+ AudioPlayback.FadeIn(Ini.PreviewFading, IPreviewVolumeVals[Ini.PreviewVolume]);
end;
end;
end;