Skip to content

Commit 5b96e17

Browse files
Added new command line option: --gain <float>
1 parent 6969738 commit 5b96e17

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ portamp@linderdaum.com
99

1010
=============================
1111

12-
Portable command-line music player for Windows, OS X and Linux
12+
Portable command-line music player for Windows, macOS, and Linux
1313

1414
=============================
1515

1616
Usage:
1717
------
1818

1919
```
20-
portamp <filename> [<filename2> ...] [--loop] [--wav-modplug] [--verbose] [--output-file <file.wav>]
20+
portamp <filename> [<filename2> ...] [--loop] [--wav-modplug] [--verbose] [--gain <float>] [--output-file <file.wav>]
2121
```
2222

2323
Features:

src/Utils.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,10 @@ class clBlob
6363

6464
struct sConfig
6565
{
66-
sConfig()
67-
: m_Loop( false )
68-
, m_UseModPlugToDecodeWAV( false )
69-
, m_Verbose( false )
70-
, m_OutputFile()
71-
{}
72-
73-
bool m_Loop;
74-
bool m_UseModPlugToDecodeWAV;
75-
bool m_Verbose;
66+
bool m_Loop = false;
67+
bool m_UseModPlugToDecodeWAV = false;
68+
bool m_Verbose = false;
69+
float m_Gain = 1.0f;
7670
std::string m_OutputFile;
7771
};
7872

src/main.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ sConfig ReadConfigFromCommandLine( int argc, char* argv[] )
3131
if ( strstr( argv[i], "--loop" ) == argv[i] ) Cfg.m_Loop = true;
3232
else if ( strstr( argv[i], "--wav-modplug" ) == argv[i] ) Cfg.m_UseModPlugToDecodeWAV = true;
3333
else if ( strstr( argv[i], "--verbose" ) == argv[i] ) Cfg.m_Verbose = true;
34+
else if (strstr(argv[i], "--gain") == argv[i])
35+
{
36+
if (i + 1 < argc)
37+
{
38+
Cfg.m_Gain = strtof(argv[++i], nullptr);
39+
}
40+
else
41+
{
42+
printf("Expected gain level [float] for --volume\n");
43+
exit(0);
44+
}
45+
}
3446
else if ( strstr (argv[i], "--output-file" ) == argv[i] )
3547
{
3648
if ( i+1 < argc )
@@ -57,7 +69,7 @@ void PrintBanner()
5769
printf( "portamp@linderdaum.com\n" );
5870
printf( "https://github.com/corporateshark/PortAMP\n" );
5971
printf( "\n" );
60-
printf( "portamp <filename1> [<filename2> ...] [--loop] [--wav-modplug] [--verbose] [--output-file <filename.wav>]\n" );
72+
printf( "portamp <filename1> [<filename2> ...] [--loop] [--wav-modplug] [--verbose] [--gain <float>] [--output-file <filename.wav>]\n" );
6173
printf( "\n" );
6274
}
6375

@@ -78,11 +90,16 @@ int main( int argc, char* argv[] )
7890
g_Config.m_Verbose = true;
7991
#endif
8092

81-
auto AudioSubsystem = CreateAudioSubsystem_OpenAL();
93+
std::shared_ptr<iAudioSubsystem> AudioSubsystem = CreateAudioSubsystem_OpenAL();
8294

8395
AudioSubsystem->Start();
8496

85-
auto Source = AudioSubsystem->CreateAudioSource();
97+
if (g_Config.m_Gain > 0) {
98+
AudioSubsystem->SetListenerGain(g_Config.m_Gain);
99+
}
100+
101+
std::shared_ptr<iAudioSource> Source = AudioSubsystem->CreateAudioSource();
102+
86103
// allow seamless looping if there is only one track
87104
if ( g_Playlist.GetNumTracks() == 1 ) Source->SetLooping( g_Config.m_Loop );
88105

0 commit comments

Comments
 (0)