Merge branch 'experimental-encapsulation' into testing

This commit is contained in:
apoorv569
2022-02-04 17:42:36 +05:30
50 changed files with 6122 additions and 4949 deletions
-117
View File
@@ -1,117 +0,0 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <wx/defs.h>
enum ControlIDs
{
/*
** BC = Browser control
** SD = Settings dialog
** MN = Popup menu
** ET = Edit tag dialog
*/
// -------------------------------------------------------------------
// Browser controls
BC_Play = wxID_HIGHEST + 1,
BC_Settings,
BC_Loop,
BC_Stop,
BC_LoopABButton,
BC_Mute,
BC_Autoplay,
BC_Volume,
BC_SamplePosition,
BC_Hives,
BC_DirCtrl,
BC_Library,
BC_Search,
BC_MediaCtrl,
BC_Trash,
BC_RestoreTrashedItem,
BC_HiveAdd,
BC_HiveRemove,
// -------------------------------------------------------------------
// Setting dialog controls
SD_BrowseConfigDir,
SD_BrowseDatabaseDir,
SD_AutoImport,
SD_FollowSymLinks,
SD_RecursiveImport,
SD_ShowFileExtension,
SD_BrowseAutoImportDir,
SD_FontType,
SD_FontSize,
SD_FontBrowseButton,
SD_WaveformColourPickerCtrl,
// -------------------------------------------------------------------
// App Menu items
MN_AddFile,
MN_AddDirectory,
MN_ToggleExtension,
MN_ToggleMenuBar,
MN_ToggleStatusBar,
// -------------------------------------------------------------------
// Library Menu items
MN_FavoriteSample,
MN_DeleteSample,
MN_TrashSample,
MN_EditTagSample,
MN_OpenFile,
// -------------------------------------------------------------------
// Library Column Header Menu items
MN_ColumnFavorite,
MN_ColumnFilename,
MN_ColumnSamplePack,
MN_ColumnType,
MN_ColumnChannels,
MN_ColumnLength,
MN_ColumnSampleRate,
MN_ColumnBitrate,
MN_ColumnPath,
// -------------------------------------------------------------------
// Hives Menu items
MN_RenameHive,
MN_DeleteHive,
MN_RemoveSample,
MN_FilterLibrary,
MN_ShowInLibrary,
// -------------------------------------------------------------------
// Trash Menu items
MN_DeleteTrash,
MN_RestoreTrashedItem,
// -------------------------------------------------------------------
// Edit tags dialog controls
ET_TitleCheck,
ET_ArtistCheck,
ET_AlbumCheck,
ET_GenreCheck,
ET_CommentsCheck,
ET_TypeCheck,
ET_CustomTag,
};
+121
View File
@@ -0,0 +1,121 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <wx/defs.h>
namespace SampleHive { namespace ID {
enum ControlIDs
{
/*
** BC = Browser control
** SD = Settings dialog
** MN = Popup menu
** ET = Edit tag dialog
*/
// -------------------------------------------------------------------
// Browser controls
BC_Play = wxID_HIGHEST + 1,
BC_Settings,
BC_Loop,
BC_Stop,
BC_LoopABButton,
BC_Mute,
BC_Autoplay,
BC_Volume,
BC_SamplePosition,
BC_Hives,
BC_DirCtrl,
BC_Library,
BC_Search,
BC_MediaCtrl,
BC_Trash,
BC_RestoreTrashedItem,
BC_HiveAdd,
BC_HiveRemove,
// -------------------------------------------------------------------
// Setting dialog controls
SD_BrowseConfigDir,
SD_BrowseDatabaseDir,
SD_AutoImport,
SD_FollowSymLinks,
SD_RecursiveImport,
SD_ShowFileExtension,
SD_BrowseAutoImportDir,
SD_FontType,
SD_FontSize,
SD_FontBrowseButton,
SD_WaveformColourPickerCtrl,
// -------------------------------------------------------------------
// App Menu items
MN_AddFile,
MN_AddDirectory,
MN_ToggleExtension,
MN_ToggleMenuBar,
MN_ToggleStatusBar,
// -------------------------------------------------------------------
// Library Menu items
MN_FavoriteSample,
MN_DeleteSample,
MN_TrashSample,
MN_EditTagSample,
MN_OpenFile,
// -------------------------------------------------------------------
// Library Column Header Menu items
MN_ColumnFavorite,
MN_ColumnFilename,
MN_ColumnSamplePack,
MN_ColumnType,
MN_ColumnChannels,
MN_ColumnLength,
MN_ColumnSampleRate,
MN_ColumnBitrate,
MN_ColumnPath,
// -------------------------------------------------------------------
// Hives Menu items
MN_RenameHive,
MN_DeleteHive,
MN_RemoveSample,
MN_FilterLibrary,
MN_ShowInLibrary,
// -------------------------------------------------------------------
// Trash Menu items
MN_DeleteTrash,
MN_RestoreTrashedItem,
// -------------------------------------------------------------------
// Edit tags dialog controls
ET_TitleCheck,
ET_ArtistCheck,
ET_AlbumCheck,
ET_GenreCheck,
ET_CommentsCheck,
ET_TypeCheck,
ET_CustomTag,
};
}}
+119
View File
@@ -0,0 +1,119 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "Utility/Event.hpp"
namespace SampleHive
{
cLoopPointsEvent::cLoopPointsEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
cLoopPointsEvent::~cLoopPointsEvent()
{
}
wxDEFINE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, cLoopPointsEvent);
wxDEFINE_EVENT(SH_EVT_LOOP_POINTS_CLEAR, cLoopPointsEvent);
wxDEFINE_EVENT(SH_EVT_LOOP_AB_BUTTON_VALUE_CHANGE, cLoopPointsEvent);
// MediaEvent::MediaEvent(wxEventType eventType, int winId)
// : wxCommandEvent(eventType, winId)
// {
// }
// MediaEvent::~MediaEvent()
// {
// }
// wxDEFINE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, MediaEvent);
cStatusBarStatusEvent::cStatusBarStatusEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
cStatusBarStatusEvent::~cStatusBarStatusEvent()
{
}
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, cStatusBarStatusEvent);
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, cStatusBarStatusEvent);
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, cStatusBarStatusEvent);
cInfoBarMessageEvent::cInfoBarMessageEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
cInfoBarMessageEvent::~cInfoBarMessageEvent()
{
}
wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, cInfoBarMessageEvent);
cTimerEvent::cTimerEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
cTimerEvent::~cTimerEvent()
{
}
wxDEFINE_EVENT(SH_EVT_TIMER_STOP, cTimerEvent);
cCallFunctionEvent::cCallFunctionEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
cCallFunctionEvent::~cCallFunctionEvent()
{
}
wxDEFINE_EVENT(SH_EVT_CALL_FUNC_PLAY, cCallFunctionEvent);
cWaveformUpdateEvent::cWaveformUpdateEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
cWaveformUpdateEvent::~cWaveformUpdateEvent()
{
}
wxDEFINE_EVENT(SH_EVT_UPDATE_WAVEFORM, cWaveformUpdateEvent);
}
+167
View File
@@ -0,0 +1,167 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <utility>
#include <wx/event.h>
namespace SampleHive
{
class cLoopPointsEvent : public wxCommandEvent
{
public:
cLoopPointsEvent(wxEventType eventType, int winId);
~cLoopPointsEvent();
public:
virtual wxEvent* Clone() const { return new cLoopPointsEvent(*this); }
public:
std::pair<double, double> GetLoopPoints() const { return { m_LoopA, m_LoopB }; };
void SetLoopPoints(std::pair<double&, double&> loopPoints)
{ m_LoopA = loopPoints.first; m_LoopB = loopPoints.second; };
private:
double m_LoopA, m_LoopB;
};
wxDECLARE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, cLoopPointsEvent);
wxDECLARE_EVENT(SH_EVT_LOOP_POINTS_CLEAR, cLoopPointsEvent);
wxDECLARE_EVENT(SH_EVT_LOOP_AB_BUTTON_VALUE_CHANGE, cLoopPointsEvent);
// class cMediaEvent : public wxCommandEvent
// {
// public:
// cMediaEvent(wxEventType eventType, int winId);
// ~cMediaEvent();
// public:
// virtual wxEvent* Clone() const { return new cMediaEvent(*this); }
// public:
// void SetPath(const wxString& path) { m_Path = path; }
// wxString GetPath() const { return m_Path; }
// private:
// wxString m_Path;
// };
// wxDECLARE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, cMediaEvent);
class cStatusBarStatusEvent : public wxCommandEvent
{
public:
cStatusBarStatusEvent(wxEventType eventType, int winId);
~cStatusBarStatusEvent();
public:
virtual wxEvent* Clone() const { return new cStatusBarStatusEvent(*this); }
public:
std::pair<wxString, int> GetPushMessageAndSection() const { return { m_Msg, m_PushSection }; }
void SetPushMessageAndSection(std::pair<const wxString&, int> status)
{ m_Msg = status.first; m_PushSection = status.second; }
std::pair<wxString, int> GetStatusTextAndSection() const { return { m_Text, m_SetSection }; }
void SetStatusTextAndSection(std::pair<const wxString&, int> status)
{ m_Text = status.first, m_SetSection = status.second; }
int GetPopMessageSection() const { return m_PopSection; }
void SetPopMessageSection(int section) { m_PopSection = section; }
private:
wxString m_Msg, m_Text;
int m_PushSection, m_PopSection, m_SetSection;
};
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, cStatusBarStatusEvent);
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, cStatusBarStatusEvent);
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, cStatusBarStatusEvent);
class cInfoBarMessageEvent : public wxCommandEvent
{
public:
cInfoBarMessageEvent(wxEventType eventType, int winId);
~cInfoBarMessageEvent();
public:
virtual wxEvent* Clone() const { return new cInfoBarMessageEvent(*this); }
public:
std::pair<wxString, int> GetInfoBarMessage() const { return { m_Msg, m_Mode }; }
void SetInfoBarMessage(std::pair<const wxString&, int> info)
{ m_Msg = info.first; m_Mode = info.second; }
private:
wxString m_Msg;
int m_Mode;
};
wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, cInfoBarMessageEvent);
class cTimerEvent : public wxCommandEvent
{
public:
cTimerEvent(wxEventType eventType, int winId);
~cTimerEvent();
public:
virtual wxEvent* Clone() const { return new cTimerEvent(*this); }
};
wxDECLARE_EVENT(SH_EVT_TIMER_STOP, cTimerEvent);
class cCallFunctionEvent : public wxCommandEvent
{
public:
cCallFunctionEvent(wxEventType eventType, int winId);
~cCallFunctionEvent();
public:
virtual wxEvent* Clone() const { return new cCallFunctionEvent(*this); }
public:
wxString GetSlection() const { return m_Selection; }
bool GetAutoplayValue() const { return m_bCheckAutoplay; }
void SetSelection(const wxString& selection) { m_Selection = selection; }
void SetAutoplayValue(bool autoplay) { m_bCheckAutoplay = autoplay; }
private:
wxString m_Selection;
bool m_bCheckAutoplay;
};
wxDECLARE_EVENT(SH_EVT_CALL_FUNC_PLAY, cCallFunctionEvent);
class cWaveformUpdateEvent : public wxCommandEvent
{
public:
cWaveformUpdateEvent(wxEventType eventType, int winId);
~cWaveformUpdateEvent();
public:
virtual wxEvent* Clone() const { return new cWaveformUpdateEvent(*this); }
};
wxDECLARE_EVENT(SH_EVT_UPDATE_WAVEFORM, cWaveformUpdateEvent);
}
+115
View File
@@ -0,0 +1,115 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "wx/dataview.h"
#include "wx/string.h"
#include "wx/treectrl.h"
#include "wx/treebase.h"
#include "wx/variant.h"
#include "wx/vector.h"
#include <string>
namespace SampleHive {
class cHiveData
{
private:
cHiveData() = default;
public:
cHiveData(const cHiveData&) = delete;
cHiveData& operator=(const cHiveData) = delete;
public:
static cHiveData& Get()
{
static cHiveData s_HiveData;
return s_HiveData;
}
public:
// ===============================================================
// HivesPanel functions
void InitHiveData(wxDataViewListCtrl& listCtrl, wxDataViewTreeCtrl& hives, wxDataViewItem favoriteHive,
wxTreeCtrl& trash, wxTreeItemId trashRoot)
{
m_pListCtrl = &listCtrl;
m_FavoriteHive = favoriteHive;
m_pHives = &hives;
m_TrashRoot = trashRoot;
m_pTrash = &trash;
}
inline wxDataViewTreeCtrl& GetHivesObj() { return *m_pHives; }
inline wxDataViewItem& GetFavoritesHive() { return m_FavoriteHive; }
wxString GetHiveItemText(bool ofFavHive = false, wxDataViewItem hive = wxDataViewItem(0))
{
wxString item_text;
if (ofFavHive)
item_text = m_pHives->GetItemText(m_FavoriteHive);
else
item_text = m_pHives->GetItemText(hive);
return item_text;
}
inline wxDataViewItem GetHiveItemSelection() { return m_pHives->GetSelection(); }
inline bool IsHiveItemContainer(wxDataViewItem& hiveItem) { return m_pHives->IsContainer(hiveItem); }
inline int GetHiveChildCount(wxDataViewItem& root) { return m_pHives->GetChildCount(root); }
inline wxDataViewItem GetHiveNthChild(wxDataViewItem& root, int pos) { return m_pHives->GetNthChild(root, pos); }
inline void HiveAppendItem(wxDataViewItem& hiveItem, wxString name) { m_pHives->AppendItem(hiveItem, name); }
inline void HiveDeleteItem(wxDataViewItem& hiveItem) { m_pHives->DeleteItem(hiveItem); }
// ===============================================================
// TrashPanel functions
inline wxTreeCtrl& GetTrashObj() { return *m_pTrash; }
inline wxTreeItemId& GetTrashRoot() { return m_TrashRoot; }
inline void TrashAppendItem(const wxTreeItemId& parent, const wxString& text) { m_pTrash->AppendItem(parent, text); }
// ===============================================================
// ListCtrl functions
inline wxDataViewListCtrl& GetListCtrlObj() { return *m_pListCtrl; }
inline int GetListCtrlSelections(wxDataViewItemArray& items) { return m_pListCtrl->GetSelections(items); }
inline int GetListCtrlRowFromItem(wxDataViewItemArray& items, int index) { return m_pListCtrl->ItemToRow(items[index]); }
inline int GetListCtrlSelectedRow() { return m_pListCtrl->GetSelectedRow(); }
inline wxDataViewItem GetListCtrlItemFromRow(int row) { return m_pListCtrl->RowToItem(row); }
inline wxString GetListCtrlTextValue(unsigned int row, unsigned int col) { return m_pListCtrl->GetTextValue(row, col); }
inline int GetListCtrlItemCount() { return m_pListCtrl->GetItemCount(); }
inline void ListCtrlAppendItem(const wxVector<wxVariant>& values) { m_pListCtrl->AppendItem(values); }
inline void ListCtrlSetVariant(const wxVariant& variant, unsigned int row, unsigned int col)
{ m_pListCtrl->SetValue(variant, row, col); }
inline void ListCtrlUnselectAllItems() { m_pListCtrl->UnselectAll(); }
inline void ListCtrlSelectRow(int row) { m_pListCtrl->SelectRow(row); }
inline void ListCtrlEnsureVisible(const wxDataViewItem& item) { m_pListCtrl->EnsureVisible(item); }
inline void ListCtrlDeleteItem(unsigned int row) { m_pListCtrl->DeleteItem(row); }
inline void ListCtrlDeleteAllItems() { m_pListCtrl->DeleteAllItems(); }
private:
wxDataViewListCtrl* m_pListCtrl = nullptr;
wxDataViewItem m_FavoriteHive;
wxDataViewTreeCtrl* m_pHives = nullptr;
wxTreeCtrl* m_pTrash = nullptr;
wxTreeItemId m_TrashRoot;
};
}
+24 -4
View File
@@ -1,3 +1,23 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "Log.hpp"
#include <iostream>
@@ -6,16 +26,16 @@
namespace SampleHive {
std::shared_ptr<spdlog::logger> Log::s_Logger;
std::shared_ptr<spdlog::logger> cLog::s_pLogger;
void Log::InitLogger(const std::string& logger)
void cLog::InitLogger(const std::string& logger)
{
spdlog::set_pattern("%^[%-T] [%-n] [%l]: %v %@%$");
try
{
s_Logger = spdlog::stdout_color_mt(logger);
s_Logger->set_level(spdlog::level::trace);
s_pLogger = spdlog::stdout_color_mt(logger);
s_pLogger->set_level(spdlog::level::trace);
}
catch (const spdlog::spdlog_ex& ex)
{
+31 -11
View File
@@ -1,3 +1,23 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <memory>
@@ -8,24 +28,24 @@
namespace SampleHive {
class Log
class cLog
{
public:
static void InitLogger(const std::string& logger);
public:
inline static std::shared_ptr<spdlog::logger>& GetLogger() { return s_Logger; }
inline static std::shared_ptr<spdlog::logger>& GetLogger() { return s_pLogger; }
private:
static std::shared_ptr<spdlog::logger> s_Logger;
static std::shared_ptr<spdlog::logger> s_pLogger;
};
}
// Log macros
#define SH_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
#define SH_LOG_INFO(...) SPDLOG_LOGGER_INFO(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
#define SH_LOG_WARN(...) SPDLOG_LOGGER_WARN(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
#define SH_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
#define SH_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
#define SH_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
// Log macros
#define SH_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(::SampleHive::Log::GetLogger(), __VA_ARGS__)
#define SH_LOG_INFO(...) SPDLOG_LOGGER_INFO(::SampleHive::Log::GetLogger(), __VA_ARGS__)
#define SH_LOG_WARN(...) SPDLOG_LOGGER_WARN(::SampleHive::Log::GetLogger(), __VA_ARGS__)
#define SH_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(::SampleHive::Log::GetLogger(), __VA_ARGS__)
#define SH_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(::SampleHive::Log::GetLogger(), __VA_ARGS__)
#define SH_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(::SampleHive::Log::GetLogger(), __VA_ARGS__)
}
+50 -26
View File
@@ -1,31 +1,55 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "SampleHiveConfig.hpp"
// Path to all the assets
#define ICON_HIVE_16px SAMPLEHIVE_DATADIR "/icons/icon-hive_16x16.png"
#define ICON_HIVE_24px SAMPLEHIVE_DATADIR "/icons/icon-hive_24x24.png"
#define ICON_HIVE_32px SAMPLEHIVE_DATADIR "/icons/icon-hive_32x32.png"
#define ICON_HIVE_64px SAMPLEHIVE_DATADIR "/icons/icon-hive_64x64.png"
#define ICON_HIVE_128px SAMPLEHIVE_DATADIR "/icons/icon-hive_128x128.png"
#define ICON_HIVE_256px SAMPLEHIVE_DATADIR "/icons/icon-hive_256x256.png"
#define ICON_STAR_FILLED_16px SAMPLEHIVE_DATADIR "/icons/icon-star_filled_16x16.png"
#define ICON_STAR_EMPTY_16px SAMPLEHIVE_DATADIR "/icons/icon-star_empty_16x16.png"
#define ICON_PLAY_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-play-dark_16x16.png"
#define ICON_STOP_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-stop-dark_16x16.png"
#define ICON_AB_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-ab-dark_16x16.png"
#define ICON_LOOP_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-loop-dark_16x16.png"
#define ICON_MUTE_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-mute-dark_16x16.png"
#define ICON_PLAY_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-play-light_16x16.png"
#define ICON_STOP_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-stop-light_16x16.png"
#define ICON_AB_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-ab-light_16x16.png"
#define ICON_LOOP_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-loop-light_16x16.png"
#define ICON_MUTE_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-mute-light_16x16.png"
#define SPLASH_LOGO SAMPLEHIVE_DATADIR "/logo/logo-samplehive_768x432.png"
namespace SampleHive {
// Path to useful directories and files
#define USER_HOME_DIR wxGetUserHome()
#define APP_CONFIG_DIR USER_HOME_DIR + "/.config/SampleHive"
#define APP_DATA_DIR USER_HOME_DIR + "/.local/share/SampleHive"
#define CONFIG_FILEPATH APP_CONFIG_DIR + "/config.yaml"
#define DATABASE_FILEPATH APP_DATA_DIR "/sample.hive"
// Path to all the assets
#define ICON_HIVE_16px SAMPLEHIVE_DATADIR "/icons/icon-hive_16x16.png"
#define ICON_HIVE_24px SAMPLEHIVE_DATADIR "/icons/icon-hive_24x24.png"
#define ICON_HIVE_32px SAMPLEHIVE_DATADIR "/icons/icon-hive_32x32.png"
#define ICON_HIVE_64px SAMPLEHIVE_DATADIR "/icons/icon-hive_64x64.png"
#define ICON_HIVE_128px SAMPLEHIVE_DATADIR "/icons/icon-hive_128x128.png"
#define ICON_HIVE_256px SAMPLEHIVE_DATADIR "/icons/icon-hive_256x256.png"
#define ICON_STAR_FILLED_16px SAMPLEHIVE_DATADIR "/icons/icon-star_filled_16x16.png"
#define ICON_STAR_EMPTY_16px SAMPLEHIVE_DATADIR "/icons/icon-star_empty_16x16.png"
#define ICON_PLAY_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-play-dark_16x16.png"
#define ICON_STOP_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-stop-dark_16x16.png"
#define ICON_AB_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-ab-dark_16x16.png"
#define ICON_LOOP_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-loop-dark_16x16.png"
#define ICON_MUTE_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-mute-dark_16x16.png"
#define ICON_PLAY_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-play-light_16x16.png"
#define ICON_STOP_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-stop-light_16x16.png"
#define ICON_AB_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-ab-light_16x16.png"
#define ICON_LOOP_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-loop-light_16x16.png"
#define ICON_MUTE_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-mute-light_16x16.png"
#define SPLASH_LOGO SAMPLEHIVE_DATADIR "/logo/logo-samplehive_768x432.png"
// Path to useful directories and files
#define USER_HOME_DIR wxGetUserHome()
#define APP_CONFIG_DIR USER_HOME_DIR + "/.config/SampleHive"
#define APP_DATA_DIR USER_HOME_DIR + "/.local/share/SampleHive"
#define CONFIG_FILEPATH APP_CONFIG_DIR + "/config.yaml"
#define DATABASE_FILEPATH APP_DATA_DIR "/sample.hive"
}
-104
View File
@@ -1,104 +0,0 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "Utility/SH_Event.hpp"
namespace SampleHive
{
SH_LoopPointsEvent::SH_LoopPointsEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
SH_LoopPointsEvent::~SH_LoopPointsEvent()
{
}
wxDEFINE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, SH_LoopPointsEvent);
// SH_AddSampleEvent::SH_AddSampleEvent(wxEventType eventType, int winId)
// : wxCommandEvent(eventType, winId)
// {
// }
// SH_AddSampleEvent::~SH_AddSampleEvent()
// {
// }
// wxDEFINE_EVENT(SH_EVT_STATUS_ADD_SAMPLE, SH_AddSampleEvent);
// SH_MediaEvent::SH_MediaEvent(wxEventType eventType, int winId)
// : wxCommandEvent(eventType, winId)
// {
// }
// SH_MediaEvent::~SH_MediaEvent()
// {
// }
// wxDEFINE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
SH_StatusBarStatusEvent::SH_StatusBarStatusEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
SH_StatusBarStatusEvent::~SH_StatusBarStatusEvent()
{
}
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, SH_StatusBarStatusEvent);
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, SH_StatusBarStatusEvent);
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, SH_StatusBarStatusEvent);
SH_InfoBarMessageEvent::SH_InfoBarMessageEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
SH_InfoBarMessageEvent::~SH_InfoBarMessageEvent()
{
}
wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, SH_InfoBarMessageEvent);
SH_TimerEvent::SH_TimerEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
SH_TimerEvent::~SH_TimerEvent()
{
}
wxDEFINE_EVENT(SH_EVT_TIMER_STOP, SH_TimerEvent);
}
-149
View File
@@ -1,149 +0,0 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <utility>
#include <wx/event.h>
namespace SampleHive
{
class SH_LoopPointsEvent : public wxCommandEvent
{
public:
SH_LoopPointsEvent(wxEventType eventType, int winId);
~SH_LoopPointsEvent();
public:
virtual wxEvent* Clone() const { return new SH_LoopPointsEvent(*this); }
public:
std::pair<double, double> GetLoopPoints() const { return { m_LoopA, m_LoopB }; };
void SetLoopPoints(std::pair<double&, double&> loopPoints)
{ m_LoopA = loopPoints.first; m_LoopB = loopPoints.second; };
private:
double m_LoopA, m_LoopB;
};
wxDECLARE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, SH_LoopPointsEvent);
// class SH_AddSampleEvent : public wxCommandEvent
// {
// public:
// SH_AddSampleEvent(wxEventType eventType, int winId);
// ~SH_AddSampleEvent();
// public:
// virtual wxEvent* Clone() const { return new SH_AddSampleEvent(*this); }
// public:
// wxArrayString GetArrayString() const { return m_Files; };
// void SetArrayString(const wxArrayString& files) { m_Files = files; };
// private:
// wxArrayString m_Files;
// };
// wxDECLARE_EVENT(SH_EVT_STATUS_ADD_SAMPLE, SH_AddSampleEvent);
// class SH_MediaEvent : public wxCommandEvent
// {
// public:
// SH_MediaEvent(wxEventType eventType, int winId);
// ~SH_MediaEvent();
// public:
// virtual wxEvent* Clone() const { return new SH_MediaEvent(*this); }
// public:
// void SetPath(const wxString& path) { m_Path = path; }
// wxString GetPath() const { return m_Path; }
// private:
// wxString m_Path;
// };
// wxDECLARE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
class SH_StatusBarStatusEvent : public wxCommandEvent
{
public:
SH_StatusBarStatusEvent(wxEventType eventType, int winId);
~SH_StatusBarStatusEvent();
public:
virtual wxEvent* Clone() const { return new SH_StatusBarStatusEvent(*this); }
public:
std::pair<wxString, int> GetPushMessageAndSection() const { return { m_Msg, m_PushSection }; }
void SetPushMessageAndSection(std::pair<const wxString&, int> status)
{ m_Msg = status.first; m_PushSection = status.second; }
std::pair<wxString, int> GetStatusTextAndSection() const { return { m_Text, m_SetSection }; }
void SetStatusTextAndSection(std::pair<const wxString&, int> status)
{ m_Text = status.first, m_SetSection = status.second; }
int GetPopMessageSection() const { return m_PopSection; }
void SetPopMessageSection(int section) { m_PopSection = section; }
private:
wxString m_Msg, m_Text;
int m_PushSection, m_PopSection, m_SetSection;
};
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, SH_StatusBarStatusEvent);
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, SH_StatusBarStatusEvent);
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, SH_StatusBarStatusEvent);
class SH_InfoBarMessageEvent : public wxCommandEvent
{
public:
SH_InfoBarMessageEvent(wxEventType eventType, int winId);
~SH_InfoBarMessageEvent();
public:
virtual wxEvent* Clone() const { return new SH_InfoBarMessageEvent(*this); }
public:
std::pair<wxString, int> GetInfoBarMessage() const { return { m_Msg, m_Mode }; }
void SetInfoBarMessage(std::pair<const wxString&, int> info)
{ m_Msg = info.first; m_Mode = info.second; }
private:
wxString m_Msg;
int m_Mode;
};
wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, SH_InfoBarMessageEvent);
class SH_TimerEvent : public wxCommandEvent
{
public:
SH_TimerEvent(wxEventType eventType, int winId);
~SH_TimerEvent();
public:
virtual wxEvent* Clone() const { return new SH_TimerEvent(*this); }
};
wxDECLARE_EVENT(SH_EVT_TIMER_STOP, SH_TimerEvent);
}
+699 -695
View File
File diff suppressed because it is too large Load Diff
+56 -52
View File
@@ -42,67 +42,71 @@ typedef std::pair<int, int> WindowSize;
// typedef std::pair<wxString, int> FontType;
typedef std::pair<bool, wxString> ImportDirInfo;
class Serializer
{
public:
Serializer();
~Serializer();
namespace SampleHive {
private:
// -------------------------------------------------------------------
YAML::Emitter m_Emitter;
class cSerializer
{
public:
cSerializer();
~cSerializer();
public:
// -------------------------------------------------------------------
// Window size
void SerializeWinSize(int w, int h);
WindowSize DeserializeWinSize() const;
public:
// -------------------------------------------------------------------
// Window size
void SerializeWinSize(int w, int h);
WindowSize DeserializeWinSize() const;
// -------------------------------------------------------------------
// Menu and status bar
void SerializeShowMenuAndStatusBar(std::string key, bool value);
bool DeserializeShowMenuAndStatusBar(std::string key) const;
// -------------------------------------------------------------------
// Menu and status bar
void SerializeShowMenuAndStatusBar(std::string key, bool value);
bool DeserializeShowMenuAndStatusBar(std::string key) const;
// -------------------------------------------------------------------
// Splitter window sash pos
void SerializeSplitterSashPos(std::string key, int pos);
int DeserializeSplitterSashPos(std::string key) const;
// -------------------------------------------------------------------
// Splitter window sash pos
void SerializeSplitterSashPos(std::string key, int pos);
int DeserializeSplitterSashPos(std::string key) const;
// -------------------------------------------------------------------
// Browser controls
void SerializeMediaOptions(std::string key, bool value);
bool DeserializeMediaOptions(std::string key) const;
// -------------------------------------------------------------------
// Browser controls
void SerializeMediaOptions(std::string key, bool value);
bool DeserializeMediaOptions(std::string key) const;
void SerializeMediaVolume(int volume);
int DeserializeMediaVolume() const;
void SerializeMediaVolume(int volume);
int DeserializeMediaVolume() const;
// -------------------------------------------------------------------
// Display settings
void SerializeFontSettings(wxFont& font);
wxFont DeserializeFontSettings() const;
// -------------------------------------------------------------------
// Display settings
void SerializeFontSettings(wxFont& font);
wxFont DeserializeFontSettings() const;
// -------------------------------------------------------------------
// Waveform colour
void SerializeWaveformColour(wxColour& colour);
wxColour DeserializeWaveformColour() const;
// -------------------------------------------------------------------
// Waveform colour
void SerializeWaveformColour(wxColour& colour);
wxColour DeserializeWaveformColour() const;
// -------------------------------------------------------------------
// Auto import settings
void SerializeAutoImport(bool autoImport, const std::string& importDir);
ImportDirInfo DeserializeAutoImport() const;
// -------------------------------------------------------------------
// Auto import settings
void SerializeAutoImport(bool autoImport, const std::string& importDir);
ImportDirInfo DeserializeAutoImport() const;
// -------------------------------------------------------------------
// Follow symbolic links
void SerializeFollowSymLink(bool followSymLink);
bool DeserializeFollowSymLink() const;
// -------------------------------------------------------------------
// Follow symbolic links
void SerializeFollowSymLink(bool followSymLink);
bool DeserializeFollowSymLink() const;
// -------------------------------------------------------------------
// Recursive import
void SerializeRecursiveImport(bool recursiveImport);
bool DeserializeRecursiveImport() const;
// -------------------------------------------------------------------
// Recursive import
void SerializeRecursiveImport(bool recursiveImport);
bool DeserializeRecursiveImport() const;
// -------------------------------------------------------------------
// Show file extension
void SerializeShowFileExtension(bool showExtension);
bool DeserializeShowFileExtension() const;
};
// -------------------------------------------------------------------
// Show file extension
void SerializeShowFileExtension(bool showExtension);
bool DeserializeShowFileExtension() const;
private:
// -------------------------------------------------------------------
YAML::Emitter m_Emitter;
};
}
+150
View File
@@ -0,0 +1,150 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "Utility/Signal.hpp"
#include "Utility/Log.hpp"
#include "Utility/Event.hpp"
namespace SampleHive {
void cSignal::SendInfoBarMessage(const wxString& msg, int mode, wxWindow& window, bool isDialog)
{
SampleHive::cInfoBarMessageEvent event(SampleHive::SH_EVT_INFOBAR_MESSAGE_SHOW, window.GetId());
event.SetEventObject(&window);
event.SetInfoBarMessage({ msg, mode });
if (isDialog)
window.GetParent()->GetEventHandler()->ProcessEvent(event);
else
window.HandleWindowEvent(event);
}
void cSignal::SendPushStatusBarStatus(const wxString& msg, int section, wxWindow& window, bool isDialog)
{
SampleHive::cStatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_PUSH, window.GetId());
event.SetEventObject(&window);
event.SetPushMessageAndSection({ msg, section });
if (isDialog)
window.GetParent()->GetEventHandler()->ProcessEvent(event);
else
window.HandleWindowEvent(event);
}
void cSignal::SendPopStatusBarStatus(int section, wxWindow& window, bool isDialog)
{
SampleHive::cStatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_POP, window.GetId());
event.SetEventObject(&window);
event.SetPopMessageSection(section);
if (isDialog)
window.GetParent()->GetEventHandler()->ProcessEvent(event);
else
window.HandleWindowEvent(event);
}
void cSignal::SendSetStatusBarStatus(const wxString& text, int section, wxWindow& window, bool isDialog)
{
SampleHive::cStatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_SET, window.GetId());
event.SetEventObject(&window);
event.SetStatusTextAndSection({ text, section });
if (isDialog)
window.GetParent()->GetEventHandler()->ProcessEvent(event);
else
window.HandleWindowEvent(event);
}
void cSignal::SendCallFunctionPlay(const wxString& selection, bool checkAutoplay, wxWindow& window, bool isDialog)
{
SampleHive::cCallFunctionEvent event(SampleHive::SH_EVT_CALL_FUNC_PLAY, window.GetId());
event.SetEventObject(&window);
event.SetSelection(selection);
event.SetAutoplayValue(checkAutoplay);
if (isDialog)
window.GetParent()->GetEventHandler()->ProcessEvent(event);
else
window.HandleWindowEvent(event);
}
void cSignal::SendTimerStopStatus(wxWindow& window, bool isDialog)
{
SampleHive::cTimerEvent event(SampleHive::SH_EVT_TIMER_STOP, window.GetId());
event.SetEventObject(&window);
if (isDialog)
window.GetParent()->GetEventHandler()->ProcessEvent(event);
else
window.HandleWindowEvent(event);
}
void cSignal::SendLoopPoints(std::pair<double, double> loopPoint, wxWindow& window, bool isDialog)
{
SampleHive::cLoopPointsEvent event(SampleHive::SH_EVT_LOOP_POINTS_UPDATED, window.GetId());
event.SetEventObject(&window);
event.SetLoopPoints({loopPoint.first, loopPoint.second});
if (isDialog)
window.GetParent()->GetEventHandler()->ProcessEvent(event);
else
window.HandleWindowEvent(event);
}
void cSignal::SendClearLoopPointsStatus(wxWindow& window, bool isDialog)
{
SampleHive::cLoopPointsEvent event(SampleHive::SH_EVT_LOOP_POINTS_CLEAR, window.GetId());
event.SetEventObject(&window);
if (isDialog)
window.GetParent()->GetEventHandler()->ProcessEvent(event);
else
window.HandleWindowEvent(event);
}
void cSignal::SendLoopABButtonValueChange(wxWindow& window, bool isDialog)
{
SampleHive::cLoopPointsEvent event(SampleHive::SH_EVT_LOOP_AB_BUTTON_VALUE_CHANGE, window.GetId());
event.SetEventObject(&window);
if (isDialog)
window.GetParent()->GetEventHandler()->ProcessEvent(event);
else
window.HandleWindowEvent(event);
}
void cSignal::SendWaveformUpdateStatus(wxWindow& window, bool isDialog)
{
SampleHive::cWaveformUpdateEvent event(SampleHive::SH_EVT_UPDATE_WAVEFORM, window.GetId());
event.SetEventObject(&window);
if (isDialog)
window.GetParent()->GetEventHandler()->ProcessEvent(event);
else
window.HandleWindowEvent(event);
}
}
+47
View File
@@ -0,0 +1,47 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <wx/string.h>
#include <wx/window.h>
namespace SampleHive {
class cSignal
{
public:
cSignal();
~cSignal();
public:
static void SendInfoBarMessage(const wxString& msg, int mode, wxWindow& window, bool isDialog = false);
static void SendPushStatusBarStatus(const wxString& msg, int section, wxWindow& window, bool isDialog = false);
static void SendSetStatusBarStatus(const wxString& msg, int section, wxWindow& window, bool isDialog = false);
static void SendPopStatusBarStatus(int section, wxWindow& window, bool isDialog = false);
static void SendCallFunctionPlay(const wxString& selection, bool checkAutoplay, wxWindow& window, bool isDialog = false);
static void SendTimerStopStatus(wxWindow& window, bool isDialog = false);
static void SendLoopPoints(std::pair<double, double> loopPoint, wxWindow& window, bool isDialog = false);
static void SendClearLoopPointsStatus(wxWindow& window, bool isDialog = false);
static void SendLoopABButtonValueChange(wxWindow& window, bool isDialog = false);
static void SendWaveformUpdateStatus(wxWindow& window, bool isDialog = false);
};
}
+97 -114
View File
@@ -33,142 +33,125 @@
#include <taglib/tstring.h>
#endif
Tags::Tags(const std::string& filename)
: m_Filepath(filename)
{
namespace SampleHive {
}
Tags::~Tags()
{
}
AudioInfo Tags::GetAudioInfo()
{
wxString artist, album, genre, title, comment;
int channels = 0, length_ms = 0, length_s = 0, sample_rate = 0, bitrate = 0;
TagLib::FileRef f(static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
if (!f.isNull() && f.tag() && f.audioProperties())
cTags::cTags(const std::string& filename)
: m_Filepath(filename)
{
TagLib::Tag* tag = f.tag();
TagLib::AudioProperties* properties = f.audioProperties();
// TagLib::PropertyMap property_map = f.file()->properties();
TagLib::String Title = tag->title();
TagLib::String Artist = tag->artist();
TagLib::String Album = tag->album();
TagLib::String Genre = tag->genre();
TagLib::String Comment = tag->comment();
int seconds = properties->length() % 60;
int minutes = (properties->length() - seconds) / 60;
bitrate = properties->bitrate();
channels = properties->channels();
length_ms = properties->lengthInMilliseconds();
length_s = properties->lengthInSeconds();
sample_rate = properties->sampleRate();
title = wxString::FromUTF8(Title.toCString(true));
artist = wxString::FromUTF8(Artist.toCString(true));
album = wxString::FromUTF8(Album.toCString(true));
genre = wxString::FromUTF8(Genre.toCString(true));
comment = wxString::FromUTF8(Comment.toCString(true));
bValid = true;
// unsigned int longest = 0;
// for(TagLib::PropertyMap::ConstIterator i = property_map.begin(); i != property_map.end(); ++i)
// {
// if (i->first.size() > longest)
// {
// longest = i->first.size();
// }
// }
// std::cout << "-- TAG (properties) --" << std::endl;
// for(TagLib::PropertyMap::ConstIterator i = property_map.begin(); i != property_map.end(); ++i)
// {
// for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j)
// {
// std::cout << std::left << std::setw(longest) << i->first << " - " << '"' << *j << '"' << std::endl;
// }
// }
}
else
{
bValid = false;
}
return { title, artist, album, genre, comment, channels, length_ms, sample_rate, bitrate };
}
void Tags::SetTitle(std::string title)
{
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
if (!f.isNull() && f.tag() && f.audioProperties())
cTags::~cTags()
{
TagLib::Tag* tag = f.tag();
tag->setTitle(title);
f.save();
}
}
void Tags::SetArtist(std::string artist)
{
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
if (!f.isNull() && f.tag() && f.audioProperties())
cTags::AudioInfo cTags::GetAudioInfo()
{
TagLib::Tag* tag = f.tag();
wxString artist, album, genre, title, comment;
int channels = 0, length = 0, sample_rate = 0, bitrate = 0;
tag->setArtist(artist);
f.save();
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
if (!f.isNull() && f.tag() && f.audioProperties())
{
TagLib::Tag* tag = f.tag();
TagLib::AudioProperties* properties = f.audioProperties();
TagLib::String Title = tag->title();
TagLib::String Artist = tag->artist();
TagLib::String Album = tag->album();
TagLib::String Genre = tag->genre();
TagLib::String Comment = tag->comment();
int seconds = properties->length() % 60;
int minutes = (properties->length() - seconds) / 60;
bitrate = properties->bitrate();
channels = properties->channels();
length = properties->lengthInMilliseconds();
int length_sec = properties->lengthInSeconds();
sample_rate = properties->sampleRate();
title = wxString::FromUTF8(Title.toCString(true));
artist = wxString::FromUTF8(Artist.toCString(true));
album = wxString::FromUTF8(Album.toCString(true));
genre = wxString::FromUTF8(Genre.toCString(true));
comment = wxString::FromUTF8(Comment.toCString(true));
m_bValid = true;
}
else
{
m_bValid = false;
}
return { title, artist, album, genre, comment, channels, length, sample_rate, bitrate };
}
}
void Tags::SetAlbum(std::string album)
{
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
if (!f.isNull() && f.tag() && f.audioProperties())
void cTags::SetTitle(std::string title)
{
TagLib::Tag* tag = f.tag();
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
tag->setAlbum(album);
f.save();
if (!f.isNull() && f.tag() && f.audioProperties())
{
TagLib::Tag* tag = f.tag();
tag->setTitle(title);
f.save();
}
}
}
void Tags::SetGenre(std::string genre)
{
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
if (!f.isNull() && f.tag() && f.audioProperties())
void cTags::SetArtist(std::string artist)
{
TagLib::Tag* tag = f.tag();
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
tag->setGenre(genre);
f.save();
if (!f.isNull() && f.tag() && f.audioProperties())
{
TagLib::Tag* tag = f.tag();
tag->setArtist(artist);
f.save();
}
}
}
void Tags::SetComment(std::string comment)
{
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
if (!f.isNull() && f.tag() && f.audioProperties())
void cTags::SetAlbum(std::string album)
{
TagLib::Tag* tag = f.tag();
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
tag->setComment(comment);
f.save();
if (!f.isNull() && f.tag() && f.audioProperties())
{
TagLib::Tag* tag = f.tag();
tag->setAlbum(album);
f.save();
}
}
void cTags::SetGenre(std::string genre)
{
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
if (!f.isNull() && f.tag() && f.audioProperties())
{
TagLib::Tag* tag = f.tag();
tag->setGenre(genre);
f.save();
}
}
void cTags::SetComment(std::string comment)
{
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
if (!f.isNull() && f.tag() && f.audioProperties())
{
TagLib::Tag* tag = f.tag();
tag->setComment(comment);
f.save();
}
}
}
+37 -33
View File
@@ -24,42 +24,46 @@
#include <wx/string.h>
struct AudioInfo
{
wxString title;
wxString artist;
wxString album;
wxString genre;
wxString comment;
namespace SampleHive {
int channels;
int length;
int sample_rate;
int bitrate;
};
class cTags
{
struct AudioInfo
{
wxString title;
wxString artist;
wxString album;
wxString genre;
wxString comment;
class Tags
{
public:
Tags(const std::string& filepath);
~Tags();
int channels;
int length;
int sample_rate;
int bitrate;
};
private:
// -------------------------------------------------------------------
const std::string& m_Filepath;
public:
cTags(const std::string& filepath);
~cTags();
bool bValid = false;
public:
// -------------------------------------------------------------------
cTags::AudioInfo GetAudioInfo();
void SetTitle(std::string artist);
void SetArtist(std::string artist);
void SetAlbum(std::string album);
void SetGenre(std::string genre);
void SetComment(std::string comment);
public:
// -------------------------------------------------------------------
AudioInfo GetAudioInfo();
void SetTitle(std::string artist);
void SetArtist(std::string artist);
void SetAlbum(std::string album);
void SetGenre(std::string genre);
void SetComment(std::string comment);
public:
// -------------------------------------------------------------------
inline bool IsFileValid() { return m_bValid; }
public:
// -------------------------------------------------------------------
inline bool IsFileValid() { return bValid; }
};
private:
// -------------------------------------------------------------------
const std::string& m_Filepath;
bool m_bValid = false;
};
}
+221
View File
@@ -0,0 +1,221 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "Database/Database.hpp"
#include "Utility/HiveData.hpp"
#include "Utility/Log.hpp"
#include "Utility/Paths.hpp"
#include "Utility/Serialize.hpp"
#include "Utility/Signal.hpp"
#include "Utility/Tags.hpp"
#include "Utility/Utils.hpp"
#include <wx/dir.h>
#include <wx/progdlg.h>
namespace SampleHive {
SampleHive::cUtils::FileInfo SampleHive::cUtils::GetFilenamePathAndExtension(const wxString& selected,
bool checkExtension, bool doGetFilename) const
{
SampleHive::cSerializer serializer;
cDatabase db;
wxString path;
std::string extension, filename;
wxString filename_with_extension = db.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
wxString filename_without_extension = db.GetSamplePathByFilename(selected.ToStdString());
if (checkExtension)
{
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)
filename = path.AfterLast('/').BeforeLast('.').ToStdString();
return { path, extension, filename };
}
void SampleHive::cUtils::AddSamples(wxArrayString& files, wxWindow* parent)
{
SampleHive::cSerializer serializer;
cDatabase db;
wxBusyCursor busy_cursor;
wxWindowDisabler window_disabler;
wxProgressDialog* progressDialog = new wxProgressDialog(_("Adding files.."),
_("Adding files, please wait..."),
static_cast<int>(files.size()), parent,
wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_CAN_ABORT |
wxPD_AUTO_HIDE);
progressDialog->CenterOnParent(wxBOTH);
std::vector<Sample> sample_array;
std::string path;
std::string artist;
std::string filename_with_extension;
std::string filename_without_extension;
std::string extension;
std::string filename;
//Check All Files At Once
wxArrayString sorted_files;
sorted_files = db.CheckDuplicates(files);
files = sorted_files;
if (files.size() < 1)
{
progressDialog->Destroy();
return;
}
progressDialog->SetRange(files.size());
for (unsigned int i = 0; i < files.size(); i++)
{
progressDialog->Update(i, wxString::Format(_("Getting Data For %s"), files[i].AfterLast('/')));
if (progressDialog->WasCancelled())
{
progressDialog->Destroy();
return;
}
path = files[i].ToStdString();
filename_with_extension = files[i].AfterLast('/').ToStdString();
filename_without_extension = files[i].AfterLast('/').BeforeLast('.').ToStdString();
extension = files[i].AfterLast('.').ToStdString();
filename = serializer.DeserializeShowFileExtension() ?
filename_with_extension : filename_without_extension;
Sample sample;
sample.SetPath(path);
sample.SetFilename(filename_without_extension);
sample.SetFileExtension(extension);
cTags tags(path);
artist = tags.GetAudioInfo().artist.ToStdString();
sample.SetSamplePack(artist);
sample.SetChannels(tags.GetAudioInfo().channels);
sample.SetLength(tags.GetAudioInfo().length);
sample.SetSampleRate(tags.GetAudioInfo().sample_rate);
sample.SetBitrate(tags.GetAudioInfo().bitrate);
wxLongLong llLength = sample.GetLength();
int total_min = static_cast<int>((llLength / 60000).GetValue());
int total_sec = static_cast<int>(((llLength % 60000) / 1000).GetValue());
wxVector<wxVariant> data;
wxVariant icon = wxVariant(wxBitmap(ICON_STAR_EMPTY_16px));
if (tags.IsFileValid())
{
data.clear();
data.push_back(icon);
data.push_back(filename);
data.push_back(sample.GetSamplePack());
data.push_back("");
data.push_back(wxString::Format("%d", sample.GetChannels()));
data.push_back(wxString::Format("%2i:%02i", total_min, total_sec));
data.push_back(wxString::Format("%d", sample.GetSampleRate()));
data.push_back(wxString::Format("%d", sample.GetBitrate()));
data.push_back(path);
SH_LOG_INFO("Adding file: {}, Extension: {}", sample.GetFilename(), sample.GetFileExtension());
SampleHive::cHiveData::Get().ListCtrlAppendItem(data);
sample_array.push_back(sample);
}
else
{
wxString msg = wxString::Format(_("Error! Cannot open %s, Invalid file type."),
filename_with_extension);
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_ERROR, *parent);
}
}
progressDialog->Pulse(_("Updating Database.."), NULL);
db.InsertIntoSamples(sample_array);
progressDialog->Destroy();
}
void cUtils::OnAutoImportDir(const wxString& pathToDirectory, wxWindow* parent)
{
SH_LOG_DEBUG("Start Importing Samples");
wxBusyCursor busy_cursor;
wxWindowDisabler window_disabler;
wxString filepath;
wxArrayString filepath_array;
size_t number_of_files = wxDir::GetAllFiles(pathToDirectory, &filepath_array, wxEmptyString, wxDIR_DEFAULT);
wxProgressDialog* progressDialog = new wxProgressDialog(_("Adding files.."),
_("Adding files, please wait..."),
static_cast<int>(number_of_files), parent,
wxPD_APP_MODAL | wxPD_SMOOTH |
wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
progressDialog->CenterOnParent(wxBOTH);
for (size_t i = 0; i < number_of_files; i++)
{
filepath = filepath_array[i];
if (wxFileExists(filepath))
{
filepath_array.push_back(filepath);
}
else if (wxDirExists(filepath))
{
wxDir::GetAllFiles(filepath, &filepath_array);
}
progressDialog->Pulse(_("Reading Samples"), NULL);
}
progressDialog->Destroy();
AddSamples(filepath_array, parent);
SH_LOG_DEBUG("Done Importing Samples");
}
}
+59
View File
@@ -0,0 +1,59 @@
/* SampleHive
* Copyright (C) 2021 Apoorv Singh
* A simple, modern audio sample browser/manager for GNU/Linux.
*
* This file is a part of SampleHive
*
* SampleHive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SampleHive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "wx/arrstr.h"
#include "wx/string.h"
#include "wx/window.h"
namespace SampleHive {
class cUtils
{
private:
cUtils() = default;
public:
cUtils(const cUtils&) = delete;
cUtils& operator=(const cUtils) = delete;
public:
static cUtils& Get()
{
static cUtils s_cUtils;
return s_cUtils;
}
public:
struct FileInfo
{
wxString Path;
std::string Extension;
std::string Filename;
};
// -------------------------------------------------------------------
cUtils::FileInfo GetFilenamePathAndExtension(const wxString& selected,
bool checkExtension = true,
bool doGetFilename = true) const;
void AddSamples(wxArrayString& files, wxWindow* parent);
void OnAutoImportDir(const wxString& pathToDirectory, wxWindow* parent);
};
}