new feature: toggle replay gain mode (requires >=mpd-0.16)
This commit is contained in:
2
doc/keys
2
doc/keys
@@ -84,6 +84,8 @@
|
|||||||
#
|
#
|
||||||
#key_toggle_consume = 'R'
|
#key_toggle_consume = 'R'
|
||||||
#
|
#
|
||||||
|
#key_toggle_replay_gain_mode = 'Y'
|
||||||
|
#
|
||||||
#key_shuffle = 'Z'
|
#key_shuffle = 'Z'
|
||||||
#
|
#
|
||||||
#key_toggle_crossfade = 'x'
|
#key_toggle_crossfade = 'x'
|
||||||
|
|||||||
@@ -177,6 +177,8 @@ void Help::GetKeybindings()
|
|||||||
*w << DisplayKeys(Key.ToggleRandom) << "Toggle random mode\n";
|
*w << DisplayKeys(Key.ToggleRandom) << "Toggle random mode\n";
|
||||||
*w << DisplayKeys(Key.ToggleSingle) << "Toggle single mode\n";
|
*w << DisplayKeys(Key.ToggleSingle) << "Toggle single mode\n";
|
||||||
*w << DisplayKeys(Key.ToggleConsume) << "Toggle consume mode\n";
|
*w << DisplayKeys(Key.ToggleConsume) << "Toggle consume mode\n";
|
||||||
|
if (Mpd.Version() >= 16)
|
||||||
|
*w << DisplayKeys(Key.ToggleReplayGainMode) << "Toggle replay gain mode\n";
|
||||||
*w << DisplayKeys(Key.Shuffle) << "Shuffle playlist\n";
|
*w << DisplayKeys(Key.Shuffle) << "Shuffle playlist\n";
|
||||||
*w << DisplayKeys(Key.ToggleCrossfade) << "Toggle crossfade mode\n";
|
*w << DisplayKeys(Key.ToggleCrossfade) << "Toggle crossfade mode\n";
|
||||||
*w << DisplayKeys(Key.SetCrossfade) << "Set crossfade\n";
|
*w << DisplayKeys(Key.SetCrossfade) << "Set crossfade\n";
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "charset.h"
|
#include "charset.h"
|
||||||
|
#include "error.h"
|
||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
|
|
||||||
using namespace MPD;
|
using namespace MPD;
|
||||||
@@ -417,6 +418,47 @@ void Connection::SetVolume(unsigned vol)
|
|||||||
UpdateStatus();
|
UpdateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Connection::GetReplayGainMode() const
|
||||||
|
{
|
||||||
|
if (!itsConnection || !mpd_send_command(itsConnection, "replay_gain_status", NULL))
|
||||||
|
return "Unknown";
|
||||||
|
std::string result;
|
||||||
|
if (mpd_pair *pair = mpd_recv_pair_named(itsConnection, "replay_gain_mode"))
|
||||||
|
{
|
||||||
|
result = pair->value;
|
||||||
|
if (!result.empty())
|
||||||
|
result[0] = toupper(result[0]);
|
||||||
|
mpd_return_pair(itsConnection, pair);
|
||||||
|
}
|
||||||
|
mpd_response_finish(itsConnection);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Connection::SetReplayGainMode(ReplayGainMode mode) const
|
||||||
|
{
|
||||||
|
if (!itsConnection)
|
||||||
|
return;
|
||||||
|
const char *rg_mode;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case rgmOff:
|
||||||
|
rg_mode = "off";
|
||||||
|
break;
|
||||||
|
case rgmTrack:
|
||||||
|
rg_mode = "track";
|
||||||
|
break;
|
||||||
|
case rgmAlbum:
|
||||||
|
rg_mode = "album";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FatalError("undefined value of ReplayGainMode!");
|
||||||
|
}
|
||||||
|
if (!mpd_send_command(itsConnection, "replay_gain_mode", rg_mode, NULL))
|
||||||
|
return;
|
||||||
|
if (!isCommandsListEnabled)
|
||||||
|
mpd_response_finish(itsConnection);
|
||||||
|
}
|
||||||
|
|
||||||
void Connection::SetCrossfade(unsigned crossfade) const
|
void Connection::SetCrossfade(unsigned crossfade) const
|
||||||
{
|
{
|
||||||
if (!itsConnection)
|
if (!itsConnection)
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ namespace MPD
|
|||||||
|
|
||||||
enum ItemType { itDirectory, itSong, itPlaylist };
|
enum ItemType { itDirectory, itSong, itPlaylist };
|
||||||
enum PlayerState { psUnknown, psStop, psPlay, psPause };
|
enum PlayerState { psUnknown, psStop, psPlay, psPause };
|
||||||
|
enum ReplayGainMode { rgmOff, rgmTrack, rgmAlbum };
|
||||||
|
|
||||||
struct Item
|
struct Item
|
||||||
{
|
{
|
||||||
Item() : song(0) { }
|
Item() : song(0) { }
|
||||||
@@ -161,6 +162,9 @@ namespace MPD
|
|||||||
void SetCrossfade(unsigned) const;
|
void SetCrossfade(unsigned) const;
|
||||||
void SetVolume(unsigned);
|
void SetVolume(unsigned);
|
||||||
|
|
||||||
|
std::string GetReplayGainMode() const;
|
||||||
|
void SetReplayGainMode(ReplayGainMode) const;
|
||||||
|
|
||||||
int AddSong(const std::string &, int = -1); // returns id of added song
|
int AddSong(const std::string &, int = -1); // returns id of added song
|
||||||
int AddSong(const Song &, int = -1); // returns id of added song
|
int AddSong(const Song &, int = -1); // returns id of added song
|
||||||
bool AddRandomSongs(size_t);
|
bool AddRandomSongs(size_t);
|
||||||
|
|||||||
@@ -1782,6 +1782,22 @@ int main(int argc, char *argv[])
|
|||||||
Config.wrapped_search = !Config.wrapped_search;
|
Config.wrapped_search = !Config.wrapped_search;
|
||||||
ShowMessage("Search mode: %s", Config.wrapped_search ? "Wrapped" : "Normal");
|
ShowMessage("Search mode: %s", Config.wrapped_search ? "Wrapped" : "Normal");
|
||||||
}
|
}
|
||||||
|
else if (Keypressed(input, Key.ToggleReplayGainMode) && Mpd.Version() >= 16)
|
||||||
|
{
|
||||||
|
LockStatusbar();
|
||||||
|
Statusbar() << "Replay gain mode ? [" << fmtBold << 'o' << fmtBoldEnd << "ff/" << fmtBold << 't' << fmtBoldEnd << "rack/" << fmtBold << 'a' << fmtBoldEnd << "lbum]";
|
||||||
|
wFooter->Refresh();
|
||||||
|
input = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
TraceMpdStatus();
|
||||||
|
wFooter->ReadKey(input);
|
||||||
|
}
|
||||||
|
while (input != 'o' && input != 't' && input != 'a');
|
||||||
|
UnlockStatusbar();
|
||||||
|
Mpd.SetReplayGainMode(input == 't' ? rgmTrack : (input == 'a' ? rgmAlbum : rgmOff));
|
||||||
|
ShowMessage("Replay gain mode: %s", Mpd.GetReplayGainMode().c_str());
|
||||||
|
}
|
||||||
else if (Keypressed(input, Key.ToggleSpaceMode))
|
else if (Keypressed(input, Key.ToggleSpaceMode))
|
||||||
{
|
{
|
||||||
Config.space_selects = !Config.space_selects;
|
Config.space_selects = !Config.space_selects;
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
|||||||
keys.ToggleRandom[0] = 'z';
|
keys.ToggleRandom[0] = 'z';
|
||||||
keys.ToggleSingle[0] = 'y';
|
keys.ToggleSingle[0] = 'y';
|
||||||
keys.ToggleConsume[0] = 'R';
|
keys.ToggleConsume[0] = 'R';
|
||||||
|
keys.ToggleReplayGainMode[0] = 'Y';
|
||||||
keys.ToggleSpaceMode[0] = 't';
|
keys.ToggleSpaceMode[0] = 't';
|
||||||
keys.ToggleAddMode[0] = 'T';
|
keys.ToggleAddMode[0] = 'T';
|
||||||
keys.ToggleMouse[0] = '|';
|
keys.ToggleMouse[0] = '|';
|
||||||
@@ -206,6 +207,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
|||||||
keys.ToggleRandom[1] = null_key;
|
keys.ToggleRandom[1] = null_key;
|
||||||
keys.ToggleSingle[1] = null_key;
|
keys.ToggleSingle[1] = null_key;
|
||||||
keys.ToggleConsume[1] = null_key;
|
keys.ToggleConsume[1] = null_key;
|
||||||
|
keys.ToggleReplayGainMode[1] = null_key;
|
||||||
keys.ToggleSpaceMode[1] = null_key;
|
keys.ToggleSpaceMode[1] = null_key;
|
||||||
keys.ToggleAddMode[1] = null_key;
|
keys.ToggleAddMode[1] = null_key;
|
||||||
keys.ToggleMouse[1] = null_key;
|
keys.ToggleMouse[1] = null_key;
|
||||||
@@ -412,6 +414,8 @@ void ReadKeys(ncmpcpp_keys &keys)
|
|||||||
GetKeys(key, keys.ToggleSingle);
|
GetKeys(key, keys.ToggleSingle);
|
||||||
else if (key.find("key_toggle_consume ") != std::string::npos)
|
else if (key.find("key_toggle_consume ") != std::string::npos)
|
||||||
GetKeys(key, keys.ToggleConsume);
|
GetKeys(key, keys.ToggleConsume);
|
||||||
|
else if (key.find("key_toggle_replay_gain_mode ") != std::string::npos)
|
||||||
|
GetKeys(key, keys.ToggleReplayGainMode);
|
||||||
else if (key.find("key_toggle_space_mode ") != std::string::npos)
|
else if (key.find("key_toggle_space_mode ") != std::string::npos)
|
||||||
GetKeys(key, keys.ToggleSpaceMode);
|
GetKeys(key, keys.ToggleSpaceMode);
|
||||||
else if (key.find("key_toggle_add_mode ") != std::string::npos)
|
else if (key.find("key_toggle_add_mode ") != std::string::npos)
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ struct ncmpcpp_keys
|
|||||||
int ToggleRandom[2];
|
int ToggleRandom[2];
|
||||||
int ToggleSingle[2];
|
int ToggleSingle[2];
|
||||||
int ToggleConsume[2];
|
int ToggleConsume[2];
|
||||||
|
int ToggleReplayGainMode[2];
|
||||||
int ToggleSpaceMode[2];
|
int ToggleSpaceMode[2];
|
||||||
int ToggleAddMode[2];
|
int ToggleAddMode[2];
|
||||||
int ToggleMouse[2];
|
int ToggleMouse[2];
|
||||||
|
|||||||
Reference in New Issue
Block a user