Commit bc183449 authored by Kevin Whitaker's avatar Kevin Whitaker

Set log output is sent to file. Implment seemingly correct replain gain support.

parent e2ec2f21
......@@ -10,7 +10,7 @@ find_package(Groove REQUIRED)
find_package(TagLib REQUIRED)
add_executable(arbitrateor src/main.cpp src/WebInterface.cpp src/GroovePlayer.cpp src/ui/LoginInterface.cpp src/ui/PlayerInterface.cpp src/ui/TrackDetails.cpp src/ui/RequestInterface.cpp src/ui/UploadInterface.cpp src/ui/AdminInterface.cpp)
target_link_libraries(arbitrateor ${Wt_LIBRARIES} ${GROOVE_LIBRARY} ${GROOVE_FINGERPRINT_LIBRARY} ${GROOVE_PLAYER_LIBRARY} ${TAGLIB_LIBRARY} pthread boost_system stdc++fs) #TODO get threading links based on platform. Remove gcc experimental fs when official c++17 exists.
target_link_libraries(arbitrateor ${Wt_LIBRARIES} ${GROOVE_LIBRARY} ${GROOVE_FINGERPRINT_LIBRARY} ${GROOVE_PLAYER_LIBRARY} ${GROOVE_LOUDNESS_LIBRARY} ${TAGLIB_LIBRARY} pthread boost_system stdc++fs) #TODO get threading links based on platform. Remove gcc experimental fs when official c++17 exists.
install(TARGETS arbitrateor RUNTIME DESTINATION .)
install(FILES ${CMAKE_SOURCE_DIR}/wt_config.xml DESTINATION .)
......
......@@ -3,5 +3,5 @@ Arbitrateor - Audio Jukebox
These packages are required to build on Ubuntu 16.04:
```
witty-dev libgroove-dev libgroovefingerprinter-dev libgrooveplayer-dev libtag1-dev g++ cmake
witty-dev libgroove-dev libgroovefingerprinter-dev libgrooveplayer-dev libgrooveloundness-dev libtag1-dev g++ cmake
```
......@@ -7,14 +7,16 @@
# GROOVE_LIBRARY
# GROOVE_FINGERPRINT_LIBRARY
# GROOVE_PLAYER_LIBRARY
# GROOVE_LOUDNESS_LIBRARY
find_path(GROOVE_INCLUDE_DIR NAMES groove/groove.h)
find_library(GROOVE_LIBRARY NAMES groove)
find_library(GROOVE_FINGERPRINT_LIBRARY NAMES groovefingerprinter)
find_library(GROOVE_PLAYER_LIBRARY NAMES grooveplayer)
find_library(GROOVE_LOUDNESS_LIBRARY NAMES grooveloudness)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GROOVE DEFAULT_MSG GROOVE_LIBRARY GROOVE_FINGERPRINT_LIBRARY GROOVE_PLAYER_LIBRARY GROOVE_INCLUDE_DIR)
find_package_handle_standard_args(GROOVE DEFAULT_MSG GROOVE_LIBRARY GROOVE_FINGERPRINT_LIBRARY GROOVE_PLAYER_LIBRARY GROOVE_LOUDNESS_LIBRARY GROOVE_INCLUDE_DIR)
mark_as_advanced(GROOVE_INCLUDE_DIR GROOVE_LIBRARY GROOVE_FINGERPRINT_LIBRARY GROOVE_PLAYER_LIBRARY)
mark_as_advanced(GROOVE_INCLUDE_DIR GROOVE_LIBRARY GROOVE_FINGERPRINT_LIBRARY GROOVE_PLAYER_LIBRARY GROOVE_LOUDNESS_LIBRARY)
......@@ -227,6 +227,8 @@ void GroovePlayerMgr::grooveEventLoop()
struct GroovePlayer* player = groove_player_create();
if(!player) {return;}
currentPlayer = player;
currentRPG = groove_loudness_detector_create();
groove_loudness_detector_attach(currentRPG,playlist);
groove_playlist_insert(playlist, groove_file_open(selectedTrack.trackPath.c_str()),1.0,1.0,nullptr);
......@@ -245,6 +247,13 @@ void GroovePlayerMgr::grooveEventLoop()
}
else if(event.eventType == GROOVE_NOWPLAYING)
{
//Clean up playlist if more than 4
if(groove_playlist_count(playlist) > 4)
{
groove_file_close(currentPlaylist->head->file);
groove_playlist_remove(currentPlaylist,currentPlaylist->head);
}
//clean up state
currentSkipRequester.clear();
currentTrack = getCurrentTrackDB(&sqlSession);
getPictureFromTrack(&currentTrack);
......@@ -266,6 +275,14 @@ void GroovePlayerMgr::grooveEventLoop()
}
);
Wt::log("info") << "Track playing changed to: " << currentTrack.trackName;
//Make sure gain is suggested
struct GrooveLoudnessDetectorInfo info;
groove_loudness_detector_info_get(currentRPG,&info,1);
struct GroovePlaylistItem* item;
groove_player_position(currentPlayer,&item,nullptr);
groove_playlist_set_item_gain(currentPlaylist, item, clamp_rg(-18.0 - info.loudness));
groove_playlist_set_item_peak(currentPlaylist, item, info.peak);
Wt::log("info") << "Gain being set to:" << clamp_rg(-18.0 - info.loudness) << " and peak to:" << info.peak;
}
else if(event.eventType == VOTING_ENDED)
{
......@@ -519,6 +536,8 @@ void GroovePlayerMgr::grooveEventLoop()
currentPlayer = nullptr;
groove_player_detach(player);
groove_player_destroy(player);
groove_loudness_detector_detach(currentRPG);
groove_loudness_detector_destroy(currentRPG);
groove_playlist_destroy(playlist);
}
......
......@@ -29,6 +29,8 @@
#include "db/User.h"
#include "db/AudioTrack.h"
#include <groove/groove.h>
#include <grooveplayer/player.h>
#include <grooveloudness/loudness.h>
#include <experimental/filesystem> //TODO:Change to non-gcc way when officially using c++17
namespace std {
namespace filesystem = experimental::filesystem;
......@@ -48,6 +50,7 @@ public:
struct GroovePlaylist* currentPlaylist;
struct GroovePlayer* currentPlayer;
struct GrooveLoudnessDetector* currentRPG;
AudioTrack currentTrack;
std::list<AudioTrack> currentVoteBatch;
std::list<std::pair<AudioTrack, int>> currentVoteStatus;
......@@ -87,6 +90,11 @@ private:
void removeOrphanedTracks(Wt::Dbo::Session* session);
AudioTrack getCurrentTrackDB(Wt::Dbo::Session* session);
static double clamp_rg(double x) {
if (x < -51.0) return -51.0;
else if (x > 51.0) return 51.0;
else return x;
};
};
......
......@@ -3,6 +3,7 @@
#include <Wt/WServer>
#include <Wt/WConfig.h>
#include "GroovePlayer.h"
#include <experimental/filesystem> //TODO:Change to non-gcc way when officially using c++17
Wt::WApplication* createApplication(const Wt::WEnvironment& env)
{
......@@ -13,6 +14,7 @@ int main ( int argc, char** argv )
{
try {
Wt::WServer server(argv[0]);
server.logger().setFile(std::filesystem::current_path()/"arb-log.txt");
server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION);
server.addEntryPoint(Wt::Application, createApplication);
if(server.start())
......
......@@ -52,10 +52,6 @@ AdminInterface::AdminInterface(WebInterface* app)
AdminInterface::~AdminInterface()
{
delete addBtn;
delete passwordField;
delete usernameField;
delete userLayout;
}
void AdminInterface::addClicked()
......
......@@ -143,36 +143,6 @@ PlayerInterface::PlayerInterface(WebInterface* app)
PlayerInterface::~PlayerInterface()
{
// Keep these out until I have a good reason to use.
// delete mainDisplay;
// delete requestPane;
// delete uploadPane;
// delete adminPane;
// delete track3vote;
// delete track2vote;
// delete track1vote;
// delete track3votecount;
// delete track2votecount;
// delete track1votecount;
// delete track3details;
// delete track2details;
// delete track1details;
// delete voteTracksLayout;
// delete voteTracksContainer;
// delete votePanel;
// delete voteControlContainer;
// delete voteMetaLayout;
// delete voteMetaContainer;
// delete skipRequest;
// delete skipDeny;
// delete playpause;
// delete currentTrackDetails;
// delete trackProgress;
// delete currentTrackProgress;
// delete skipControls;
// delete playControlLayout;
// delete playControlWidget;
// delete interfaceLayout;
}
void PlayerInterface::playpauseClicked()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment