summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/config-example3
-rw-r--r--contrib/pianobar.112
-rw-r--r--src/main.c4
-rw-r--r--src/player.c3
-rw-r--r--src/player.h1
-rw-r--r--src/settings.c7
-rw-r--r--src/settings.h5
-rw-r--r--src/ui_act.c18
-rw-r--r--src/ui_act.h2
9 files changed, 49 insertions, 6 deletions
diff --git a/contrib/config-example b/contrib/config-example
index f39d45d..f96440b 100644
--- a/contrib/config-example
+++ b/contrib/config-example
@@ -29,6 +29,8 @@
#act_songtired = t
#act_upcoming = u
#act_stationselectquickmix = x
+#act_voldown = (
+#act_volup = )
# Misc
# mp3, mp3-hifi or aacplus
@@ -38,3 +40,4 @@
#sort = quickmix_10_name_az
#love_icon = [+]
#ban_icon = [-]
+#volume = 0
diff --git a/contrib/pianobar.1 b/contrib/pianobar.1
index 6a6bd33..5478fa3 100644
--- a/contrib/pianobar.1
+++ b/contrib/pianobar.1
@@ -126,6 +126,14 @@ Show next songs in playlist.
Select quickmix stations.
.TP
+.B act_voldown = (
+Decrease volume.
+
+.TP
+.B act_volup = )
+Increase volume.
+
+.TP
.B audio_format = {aacplus,mp3,mp3-hifi}
Select audio format. aacplus is default if both libraries (faad, mad) are
available. mp3-hifi is available for Pandora One customers only.
@@ -180,6 +188,10 @@ bottom) and name from z to a.
.B user = your@user.name
Your pandora.com username.
+.TP
+.B volume = 0
+Initial volume correction in dB. Usually between -30 and +5.
+
.SH REMOTE CONTROL
.B pianobar
can be controlled through a fifo. You have to create it yourself by executing
diff --git a/src/main.c b/src/main.c
index 89763d7..dea30b9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -180,7 +180,8 @@ static void BarMainHandleUserInput (BarApp_t *app) {
BarUiActQuit, BarUiActRenameStation,
BarUiActSelectStation, BarUiActTempBanSong,
BarUiActPrintUpcoming, BarUiActSelectQuickMix,
- BarUiActDebug, BarUiActBookmark};
+ BarUiActDebug, BarUiActBookmark, BarUiActVolDown,
+ BarUiActVolUp};
idToF[i] (app, curFd);
break;
}
@@ -275,6 +276,7 @@ static void BarMainStartPlayback (BarApp_t *app, pthread_t *playerThread) {
}
app->player.gain = app->playlist->fileGain;
+ app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume);
app->player.audioFormat = app->playlist->audioFormat;
/* throw event */
diff --git a/src/player.c b/src/player.c
index 83c5713..a819103 100644
--- a/src/player.c
+++ b/src/player.c
@@ -56,7 +56,7 @@ THE SOFTWARE.
* @param apply this gain
* @return this * yourvalue = newgain value
*/
-static inline unsigned int computeReplayGainScale (float applyGain) {
+unsigned int BarPlayerCalcScale (float applyGain) {
return pow (10.0, applyGain / 20.0) * RG_SCALE_FACTOR;
}
@@ -414,7 +414,6 @@ void *BarPlayerThread (void *data) {
/* init handles */
pthread_mutex_init (&player->pauseMutex, NULL);
- player->scale = computeReplayGainScale (player->gain);
player->waith.data = (void *) player;
/* extraHeaders will be initialized later */
player->waith.extraHeaders = extraHeaders;
diff --git a/src/player.h b/src/player.h
index 4ce0fbb..0062589 100644
--- a/src/player.h
+++ b/src/player.h
@@ -102,5 +102,6 @@ struct audioPlayer {
enum {PLAYER_RET_OK = 0, PLAYER_RET_ERR = 1};
void *BarPlayerThread (void *data);
+unsigned int BarPlayerCalcScale (float);
#endif /* _PLAYER_H */
diff --git a/src/settings.c b/src/settings.c
index 259c9f0..d181b7a 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -95,7 +95,7 @@ void BarSettingsRead (BarSettings_t *settings) {
/* _must_ have same order as in BarKeyShortcutId_t */
static const char defaultKeys[] = {'?', '+', '-', 'a', 'c', 'd', 'e', 'g',
'h', 'i', 'j', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'x', '$',
- 'b',
+ 'b', '(', ')',
};
static const char *shortcutFileKeys[] = {
"act_help", "act_songlove", "act_songban", "act_stationaddmusic",
@@ -104,7 +104,7 @@ void BarSettingsRead (BarSettings_t *settings) {
"act_addshared", "act_songmove", "act_songnext", "act_songpause",
"act_quit", "act_stationrename", "act_stationchange",
"act_songtired", "act_upcoming", "act_stationselectquickmix",
- "act_debug", "act_bookmark",
+ "act_debug", "act_bookmark", "act_voldown", "act_volup",
};
/* apply defaults */
@@ -116,6 +116,7 @@ void BarSettingsRead (BarSettings_t *settings) {
#endif
#endif
settings->history = 5;
+ settings->volume = 0;
settings->sortOrder = BAR_SORT_NAME_AZ;
memcpy (settings->keys, defaultKeys, sizeof (defaultKeys));
settings->loveIcon = strdup ("<3");
@@ -187,6 +188,8 @@ void BarSettingsRead (BarSettings_t *settings) {
} else if (streq ("ban_icon", key)) {
free (settings->banIcon);
settings->banIcon = strdup (val);
+ } else if (streq ("volume", key)) {
+ settings->volume = atoi (val);
}
}
diff --git a/src/settings.h b/src/settings.h
index 078c337..0d97c80 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -52,8 +52,10 @@ typedef enum {
BAR_KS_SELECTQUICKMIX = 19,
BAR_KS_DEBUG = 20,
BAR_KS_BOOKMARK = 21,
+ BAR_KS_VOLDOWN = 22,
+ BAR_KS_VOLUP = 23,
/* insert new shortcuts _before_ this element and increase its value */
- BAR_KS_COUNT = 22,
+ BAR_KS_COUNT = 24,
} BarKeyShortcutId_t;
typedef enum {
@@ -68,6 +70,7 @@ typedef enum {
typedef struct {
unsigned int history;
+ int volume;
BarStationSorting_t sortOrder;
PianoAudioFormat_t audioFormat;
char *username;
diff --git a/src/ui_act.c b/src/ui_act.c
index 679f098..0ed55ec 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -103,6 +103,8 @@ BarUiActCallback(BarUiActHelp) {
"select quickmix stations",
NULL,
"bookmark song/artist",
+ "decrease volume",
+ "increase volume",
};
size_t i;
@@ -564,3 +566,19 @@ BarUiActCallback(BarUiActBookmark) {
}
}
+/* decrease volume
+ */
+BarUiActCallback(BarUiActVolDown) {
+ --app->settings.volume;
+ /* FIXME: assuming unsigned integer store is atomic operation */
+ app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume);
+}
+
+/* increase volume
+ */
+BarUiActCallback(BarUiActVolUp) {
+ ++app->settings.volume;
+ /* FIXME: assuming unsigned integer store is atomic operation */
+ app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume);
+}
+
diff --git a/src/ui_act.h b/src/ui_act.h
index f731f72..66ad731 100644
--- a/src/ui_act.h
+++ b/src/ui_act.h
@@ -50,5 +50,7 @@ BarUiActCallback(BarUiActQuit);
BarUiActCallback(BarUiActDebug);
BarUiActCallback(BarUiActHistory);
BarUiActCallback(BarUiActBookmark);
+BarUiActCallback(BarUiActVolDown);
+BarUiActCallback(BarUiActVolUp);
#endif /* _UI_ACT_H */