Remove unnecessary logging statements and database queries.
This commit is contained in:
parent
22f45fbd66
commit
293c12a7e0
|
|
@ -150,7 +150,7 @@ cMainFrame::cMainFrame()
|
||||||
m_pTimer = new wxTimer(this);
|
m_pTimer = new wxTimer(this);
|
||||||
|
|
||||||
m_pTransportControls = new cTransportControls(m_pTopPanel, *m_pMediaCtrl);
|
m_pTransportControls = new cTransportControls(m_pTopPanel, *m_pMediaCtrl);
|
||||||
m_pWaveformViewer = new cWaveformViewer(m_pTopPanel, *m_pMediaCtrl, *m_pDatabase);
|
m_pWaveformViewer = new cWaveformViewer(m_pTopPanel, *m_pMediaCtrl);
|
||||||
|
|
||||||
// Binding events.
|
// Binding events.
|
||||||
Bind(wxEVT_MENU, &cMainFrame::OnSelectAddFile, this, SampleHive::ID::MN_AddFile);
|
Bind(wxEVT_MENU, &cMainFrame::OnSelectAddFile, this, SampleHive::ID::MN_AddFile);
|
||||||
|
|
@ -227,7 +227,7 @@ void cMainFrame::OnMediaFinished(wxMediaEvent& event)
|
||||||
if (m_pTimer->IsRunning())
|
if (m_pTimer->IsRunning())
|
||||||
{
|
{
|
||||||
m_pTimer->Stop();
|
m_pTimer->Stop();
|
||||||
SH_LOG_DEBUG("TIMER STOPPED");
|
SH_LOG_DEBUG("Stopping timer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pTransportControls->SetSamplePositionText("--:--/--:--");
|
m_pTransportControls->SetSamplePositionText("--:--/--:--");
|
||||||
|
|
@ -238,8 +238,6 @@ void cMainFrame::OnMediaFinished(wxMediaEvent& event)
|
||||||
|
|
||||||
void cMainFrame::UpdateElapsedTime(wxTimerEvent& event)
|
void cMainFrame::UpdateElapsedTime(wxTimerEvent& event)
|
||||||
{
|
{
|
||||||
SH_LOG_DEBUG("TIMER IS RUNNING..");
|
|
||||||
|
|
||||||
wxString duration, position;
|
wxString duration, position;
|
||||||
wxLongLong llLength, llTell;
|
wxLongLong llLength, llTell;
|
||||||
|
|
||||||
|
|
@ -869,9 +867,7 @@ void cMainFrame::OnRecieveCallFunctionPlay(SampleHive::cCallFunctionEvent& event
|
||||||
wxString selection = event.GetSlection();
|
wxString selection = event.GetSlection();
|
||||||
bool checkAutoplay = event.GetAutoplayValue();
|
bool checkAutoplay = event.GetAutoplayValue();
|
||||||
|
|
||||||
wxString sample_path = serializer.DeserializeShowFileExtension() ?
|
wxString sample_path = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selection).Path;
|
||||||
m_pDatabase->GetSamplePathByFilename(selection.BeforeLast('.').ToStdString()) :
|
|
||||||
m_pDatabase->GetSamplePathByFilename(selection.ToStdString());
|
|
||||||
|
|
||||||
if (checkAutoplay)
|
if (checkAutoplay)
|
||||||
{
|
{
|
||||||
|
|
@ -931,7 +927,7 @@ void cMainFrame::PlaySample(const std::string& filepath, const std::string& samp
|
||||||
|
|
||||||
if (!m_pTimer->IsRunning())
|
if (!m_pTimer->IsRunning())
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Starting timer..");
|
SH_LOG_DEBUG("Starting timer.");
|
||||||
m_pTimer->Start(20, wxTIMER_CONTINUOUS);
|
m_pTimer->Start(20, wxTIMER_CONTINUOUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "Utility/HiveData.hpp"
|
#include "Utility/HiveData.hpp"
|
||||||
#include "Utility/Log.hpp"
|
#include "Utility/Log.hpp"
|
||||||
#include "Utility/Paths.hpp"
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Utils.hpp"
|
||||||
#include "Utility/Serialize.hpp"
|
#include "Utility/Serialize.hpp"
|
||||||
#include "Utility/Event.hpp"
|
#include "Utility/Event.hpp"
|
||||||
#include "Utility/Signal.hpp"
|
#include "Utility/Signal.hpp"
|
||||||
|
|
@ -41,9 +42,9 @@
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
|
|
||||||
cWaveformViewer::cWaveformViewer(wxWindow* window, wxMediaCtrl& mediaCtrl, cDatabase& database)
|
cWaveformViewer::cWaveformViewer(wxWindow* window, wxMediaCtrl& mediaCtrl)
|
||||||
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE),
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE),
|
||||||
m_Window(window), m_Database(database), m_MediaCtrl(mediaCtrl)
|
m_Window(window), m_MediaCtrl(mediaCtrl)
|
||||||
{
|
{
|
||||||
this->SetDoubleBuffered(true);
|
this->SetDoubleBuffered(true);
|
||||||
|
|
||||||
|
|
@ -125,21 +126,17 @@ void cWaveformViewer::RenderPlayhead(wxDC& dc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selected).Path.ToStdString();
|
||||||
|
|
||||||
SampleHive::cTags tags(path);
|
SampleHive::cTags tags(path);
|
||||||
|
|
||||||
int length = tags.GetAudioInfo().length;
|
int length = tags.GetAudioInfo().length;
|
||||||
SH_LOG_DEBUG("Sample length: {}", length);
|
|
||||||
|
|
||||||
double position = m_MediaCtrl.Tell();
|
double position = m_MediaCtrl.Tell();
|
||||||
SH_LOG_DEBUG("Current Sample Position: {}", position);
|
|
||||||
|
|
||||||
int panel_width = this->GetSize().GetWidth();
|
int panel_width = this->GetSize().GetWidth();
|
||||||
double line_pos = panel_width * (position / length);
|
double line_pos = panel_width * (position / length);
|
||||||
|
|
||||||
SH_LOG_DEBUG("Drawing playhead at: {}", line_pos);
|
|
||||||
|
|
||||||
m_PlayheadColour = wxColor(255, 0, 0, 255);
|
m_PlayheadColour = wxColor(255, 0, 0, 255);
|
||||||
|
|
||||||
// Draw the triangle
|
// Draw the triangle
|
||||||
|
|
@ -165,15 +162,7 @@ void cWaveformViewer::UpdateWaveformBitmap()
|
||||||
|
|
||||||
wxString selection = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
wxString selection = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
|
|
||||||
wxString filepath_with_extension = m_Database.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
wxString path = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selection).Path;
|
||||||
wxString filepath_without_extension = m_Database.GetSamplePathByFilename(selection.ToStdString());
|
|
||||||
|
|
||||||
std::string extension = serializer.DeserializeShowFileExtension() ?
|
|
||||||
m_Database.GetSampleFileExtension(selection.ToStdString()) :
|
|
||||||
m_Database.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
|
||||||
|
|
||||||
wxString path = selection.Contains(wxString::Format(".%s", extension)) ?
|
|
||||||
filepath_with_extension : filepath_without_extension;
|
|
||||||
|
|
||||||
SndfileHandle snd_file(path.ToStdString().c_str());
|
SndfileHandle snd_file(path.ToStdString().c_str());
|
||||||
|
|
||||||
|
|
@ -314,7 +303,7 @@ void cWaveformViewer::OnMouseMotion(wxMouseEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selected).Path.ToStdString();
|
||||||
|
|
||||||
SampleHive::cTags tags(path);
|
SampleHive::cTags tags(path);
|
||||||
|
|
||||||
|
|
@ -354,7 +343,7 @@ void cWaveformViewer::OnMouseLeftButtonDown(wxMouseEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selected).Path.ToStdString();
|
||||||
|
|
||||||
SampleHive::cTags tags(path);
|
SampleHive::cTags tags(path);
|
||||||
|
|
||||||
|
|
@ -403,7 +392,7 @@ void cWaveformViewer::OnMouseLeftButtonUp(wxMouseEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selected).Path.ToStdString();
|
||||||
|
|
||||||
SampleHive::cTags tags(path);
|
SampleHive::cTags tags(path);
|
||||||
|
|
||||||
|
|
@ -468,7 +457,7 @@ std::pair<double, double> cWaveformViewer::CalculateLoopPoints()
|
||||||
return { 0.0, 0.0 };
|
return { 0.0, 0.0 };
|
||||||
|
|
||||||
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selected).Path.ToStdString();
|
||||||
|
|
||||||
SampleHive::cTags tags(path);
|
SampleHive::cTags tags(path);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Database/Database.hpp"
|
|
||||||
|
|
||||||
#include <wx/bitmap.h>
|
#include <wx/bitmap.h>
|
||||||
#include <wx/colour.h>
|
#include <wx/colour.h>
|
||||||
#include <wx/dc.h>
|
#include <wx/dc.h>
|
||||||
|
|
@ -35,7 +33,7 @@
|
||||||
class cWaveformViewer : public wxPanel
|
class cWaveformViewer : public wxPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cWaveformViewer(wxWindow* window, wxMediaCtrl& mediaCtrl, cDatabase& database);
|
cWaveformViewer(wxWindow* window, wxMediaCtrl& mediaCtrl);
|
||||||
~cWaveformViewer();
|
~cWaveformViewer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -45,7 +43,6 @@ class cWaveformViewer : public wxPanel
|
||||||
wxBoxSizer* m_Sizer;
|
wxBoxSizer* m_Sizer;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
cDatabase& m_Database;
|
|
||||||
wxMediaCtrl& m_MediaCtrl;
|
wxMediaCtrl& m_MediaCtrl;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -34,26 +34,15 @@
|
||||||
namespace SampleHive {
|
namespace SampleHive {
|
||||||
|
|
||||||
SampleHive::cUtils::FileInfo SampleHive::cUtils::GetFilenamePathAndExtension(const wxString& selected,
|
SampleHive::cUtils::FileInfo SampleHive::cUtils::GetFilenamePathAndExtension(const wxString& selected,
|
||||||
bool checkExtension, bool doGetFilename) const
|
bool checkExtension, bool doGetFilename)
|
||||||
{
|
{
|
||||||
SampleHive::cSerializer serializer;
|
|
||||||
cDatabase db;
|
|
||||||
|
|
||||||
wxString path;
|
wxString path;
|
||||||
std::string extension, filename;
|
std::string extension, filename;
|
||||||
|
|
||||||
wxString filename_with_extension = db.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
path = GetSamplePath(selected);
|
||||||
wxString filename_without_extension = db.GetSamplePathByFilename(selected.ToStdString());
|
|
||||||
|
|
||||||
if (checkExtension)
|
if (checkExtension)
|
||||||
{
|
extension = path.AfterLast('/').AfterLast('.').ToStdString();
|
||||||
extension = serializer.DeserializeShowFileExtension() ?
|
|
||||||
db.GetSampleFileExtension(selected.ToStdString()) :
|
|
||||||
db.GetSampleFileExtension(selected.BeforeLast('.').ToStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
path = selected.Contains(wxString::Format(".%s", extension)) ?
|
|
||||||
filename_with_extension : filename_without_extension;
|
|
||||||
|
|
||||||
if (doGetFilename)
|
if (doGetFilename)
|
||||||
filename = path.AfterLast('/').BeforeLast('.').ToStdString();
|
filename = path.AfterLast('/').BeforeLast('.').ToStdString();
|
||||||
|
|
@ -222,4 +211,25 @@ namespace SampleHive {
|
||||||
SH_LOG_DEBUG("Done Importing Samples");
|
SH_LOG_DEBUG("Done Importing Samples");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string cUtils::GetSamplePath(const wxString& name)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
wxString sample_path;
|
||||||
|
|
||||||
|
if (m_PathCache.find(name.ToStdString()) != m_PathCache.end())
|
||||||
|
return m_PathCache[name.ToStdString()];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sample_path = serializer.DeserializeShowFileExtension() ?
|
||||||
|
db.GetSamplePathByFilename(name.BeforeLast('.').ToStdString()) :
|
||||||
|
db.GetSamplePathByFilename(name.ToStdString());
|
||||||
|
|
||||||
|
m_PathCache[name.ToStdString()] = sample_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sample_path.ToStdString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@
|
||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/window.h"
|
#include "wx/window.h"
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace SampleHive {
|
namespace SampleHive {
|
||||||
|
|
||||||
class cUtils
|
class cUtils
|
||||||
|
|
@ -30,10 +32,12 @@ namespace SampleHive {
|
||||||
cUtils() = default;
|
cUtils() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
cUtils(const cUtils&) = delete;
|
cUtils(const cUtils&) = delete;
|
||||||
cUtils& operator=(const cUtils) = delete;
|
cUtils& operator=(const cUtils) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
static cUtils& Get()
|
static cUtils& Get()
|
||||||
{
|
{
|
||||||
static cUtils s_cUtils;
|
static cUtils s_cUtils;
|
||||||
|
|
@ -41,6 +45,7 @@ namespace SampleHive {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
struct FileInfo
|
struct FileInfo
|
||||||
{
|
{
|
||||||
wxString Path;
|
wxString Path;
|
||||||
|
|
@ -51,9 +56,17 @@ namespace SampleHive {
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
cUtils::FileInfo GetFilenamePathAndExtension(const wxString& selected,
|
cUtils::FileInfo GetFilenamePathAndExtension(const wxString& selected,
|
||||||
bool checkExtension = true,
|
bool checkExtension = true,
|
||||||
bool doGetFilename = true) const;
|
bool doGetFilename = true);
|
||||||
void AddSamples(wxArrayString& files, wxWindow* parent);
|
void AddSamples(wxArrayString& files, wxWindow* parent);
|
||||||
void OnAutoImportDir(const wxString& pathToDirectory, wxWindow* parent);
|
void OnAutoImportDir(const wxString& pathToDirectory, wxWindow* parent);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
std::string GetSamplePath(const wxString& name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
std::unordered_map<std::string, std::string> m_PathCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue