Minor corrections and optimizations.
This commit is contained in:
parent
5f8e7a2693
commit
4464da159d
|
|
@ -73,9 +73,10 @@ void Database::CreateDatabase()
|
|||
}
|
||||
}
|
||||
|
||||
///Loops through a Sample array and adds them to the database
|
||||
void Database::InsertSamples(std::vector<Sample> samples) {
|
||||
try
|
||||
//Loops through a Sample array and adds them to the database
|
||||
void Database::InsertSamples(std::vector<Sample> samples)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sqlite3_open("sample.hive", &m_Database) != SQLITE_OK)
|
||||
{
|
||||
|
|
@ -99,7 +100,7 @@ void Database::InsertSamples(std::vector<Sample> samples) {
|
|||
if (rc != SQLITE_OK)
|
||||
wxLogDebug("Cannot prepare sql statement..");
|
||||
|
||||
Sample sample_object;
|
||||
Sample sample;
|
||||
|
||||
std::string filename;
|
||||
std::string file_extension;
|
||||
|
|
@ -109,25 +110,25 @@ void Database::InsertSamples(std::vector<Sample> samples) {
|
|||
|
||||
for(unsigned int i = 0; i < samples.size(); i++)
|
||||
{
|
||||
sample_object = samples[i];
|
||||
sample = samples[i];
|
||||
|
||||
filename = sample_object.GetFilename();
|
||||
file_extension = sample_object.GetFileExtension();
|
||||
sample_pack = sample_object.GetSamplePack();
|
||||
type = sample_object.GetType();
|
||||
path = sample_object.GetPath();
|
||||
filename = sample.GetFilename();
|
||||
file_extension = sample.GetFileExtension();
|
||||
sample_pack = sample.GetSamplePack();
|
||||
type = sample.GetType();
|
||||
path = sample.GetPath();
|
||||
|
||||
rc = sqlite3_bind_int(m_Stmt, 1, sample_object.GetFavorite());
|
||||
rc = sqlite3_bind_int(m_Stmt, 1, sample.GetFavorite());
|
||||
rc = sqlite3_bind_text(m_Stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC);
|
||||
rc = sqlite3_bind_text(m_Stmt, 3, file_extension.c_str(), file_extension.size(), SQLITE_STATIC);
|
||||
rc = sqlite3_bind_text(m_Stmt, 4, sample_pack.c_str(), sample_pack.size(), SQLITE_STATIC);
|
||||
rc = sqlite3_bind_text(m_Stmt, 5, type.c_str(), type.size(), SQLITE_STATIC);
|
||||
rc = sqlite3_bind_int(m_Stmt, 6, sample_object.GetChannels());
|
||||
rc = sqlite3_bind_int(m_Stmt, 7, sample_object.GetLength());
|
||||
rc = sqlite3_bind_int(m_Stmt, 8, sample_object.GetSampleRate());
|
||||
rc = sqlite3_bind_int(m_Stmt, 9, sample_object.GetBitrate());
|
||||
rc = sqlite3_bind_int(m_Stmt, 6, sample.GetChannels());
|
||||
rc = sqlite3_bind_int(m_Stmt, 7, sample.GetLength());
|
||||
rc = sqlite3_bind_int(m_Stmt, 8, sample.GetSampleRate());
|
||||
rc = sqlite3_bind_int(m_Stmt, 9, sample.GetBitrate());
|
||||
rc = sqlite3_bind_text(m_Stmt, 10, path.c_str(),path.size(), SQLITE_STATIC);
|
||||
rc = sqlite3_bind_int(m_Stmt, 11, sample_object.GetTrashed());
|
||||
rc = sqlite3_bind_int(m_Stmt, 11, sample.GetTrashed());
|
||||
|
||||
rc = sqlite3_step(m_Stmt);
|
||||
rc = sqlite3_clear_bindings(m_Stmt);
|
||||
|
|
@ -168,7 +169,12 @@ void Database::InsertSamples(std::vector<Sample> samples) {
|
|||
if (rc == SQLITE_INTERNAL)
|
||||
wxLogDebug("SQLITE_INTERNAL");
|
||||
|
||||
sqlite3_close(m_Database);
|
||||
rc = sqlite3_close(m_Database);
|
||||
|
||||
if (rc == SQLITE_OK)
|
||||
wxLogDebug("DB Closed..");
|
||||
else
|
||||
wxLogDebug("Error! Cannot close DB, Error code: %d, Error message: %s", rc, m_ErrMsg);
|
||||
}
|
||||
catch (const std::exception &exception)
|
||||
{
|
||||
|
|
@ -759,28 +765,31 @@ Database::FilterDatabaseBySampleName(wxVector<wxVector<wxVariant>>& sampleVec, c
|
|||
}
|
||||
|
||||
//Compares the input array with the database and removes duplicates.
|
||||
wxArrayString Database::CheckDuplicates(wxArrayString files)
|
||||
wxArrayString Database::CheckDuplicates(const wxArrayString& files)
|
||||
{
|
||||
wxArrayString sorted_files;
|
||||
|
||||
std::string filename;
|
||||
std::string sample;
|
||||
|
||||
try
|
||||
{
|
||||
rc = sqlite3_open("sample.hive", &m_Database);
|
||||
|
||||
std::string select = "SELECT * FROM SAMPLES WHERE FILENAME = ?;";
|
||||
|
||||
rc = sqlite3_prepare_v2(m_Database, select.c_str(), select.size(), &m_Stmt, NULL);
|
||||
|
||||
for(unsigned int i = 0; i < files.size(); i++)
|
||||
{
|
||||
filename = files[i].AfterLast('/').BeforeLast('.').ToStdString();
|
||||
|
||||
rc = sqlite3_bind_text(m_Stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC);
|
||||
|
||||
if (sqlite3_step(m_Stmt) != SQLITE_ROW)
|
||||
{
|
||||
sorted_files.push_back(files[i]);
|
||||
}
|
||||
else
|
||||
wxLogDebug("Already added: %s. Skipping..", files[i]);
|
||||
|
||||
rc = sqlite3_clear_bindings(m_Stmt);
|
||||
rc = sqlite3_reset(m_Stmt);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Database
|
|||
// -------------------------------------------------------------------
|
||||
// Check database
|
||||
bool IsTrashed(const std::string& filename);
|
||||
wxArrayString CheckDuplicates(wxArrayString files);
|
||||
wxArrayString CheckDuplicates(const wxArrayString& files);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Remove from database
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include <wx/log.h>
|
||||
#include <wx/menu.h>
|
||||
#include <wx/msgdlg.h>
|
||||
// #include <wx/progdlg.h>
|
||||
#include <wx/progdlg.h>
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/variant.h>
|
||||
#include <wx/vector.h>
|
||||
|
|
@ -28,8 +28,8 @@
|
|||
#include "TagEditorDialog.hpp"
|
||||
#include "Tags.hpp"
|
||||
// #include "TreeItemDialog.hpp"
|
||||
#include "Serialize.hpp"
|
||||
#include "Sample.hpp"
|
||||
#include "Serialize.hpp"
|
||||
|
||||
#include <wx/fswatcher.h>
|
||||
|
||||
|
|
@ -350,21 +350,22 @@ wxString TagLibTowx(const TagLib::String& in)
|
|||
}
|
||||
|
||||
// Adds multiple samples to the database.
|
||||
void MainFrame::AddSamples(wxArrayString files)
|
||||
void MainFrame::AddSamples(wxArrayString& files)
|
||||
{
|
||||
Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath);
|
||||
|
||||
Database db(*m_InfoBar);
|
||||
|
||||
wxBusyCursor busy_cursor;
|
||||
wxWindowDisabler window_disabler;
|
||||
|
||||
wxProgressDialog* progressDialog = new wxProgressDialog("Adding files..", "Adding files, please wait...",
|
||||
(int)files.size(), this,
|
||||
wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_CAN_ABORT |
|
||||
wxPD_AUTO_HIDE);
|
||||
(int)files.size(), this,
|
||||
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;
|
||||
|
|
@ -374,15 +375,18 @@ void MainFrame::AddSamples(wxArrayString files)
|
|||
|
||||
//Check All Files At Once
|
||||
wxArrayString sorted_files;
|
||||
|
||||
sorted_files = db.CheckDuplicates(files);
|
||||
files = sorted_files;
|
||||
|
||||
if(files.size() < 1) {
|
||||
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('/')));
|
||||
|
|
@ -395,23 +399,27 @@ void MainFrame::AddSamples(wxArrayString files)
|
|||
|
||||
path = files[i].ToStdString();
|
||||
filename_with_extension = files[i].AfterLast('/').ToStdString();
|
||||
filename = files[i].AfterLast('/').BeforeLast('.').ToStdString();
|
||||
filename_without_extension = files[i].AfterLast('/').BeforeLast('.').ToStdString();
|
||||
extension = files[i].AfterLast('.').ToStdString();
|
||||
|
||||
Sample sample_object;
|
||||
sample_object.SetPath(path);
|
||||
filename = settings.IsShowFileExtension() ?
|
||||
filename_with_extension : filename_without_extension;
|
||||
|
||||
sample_object.SetFilename(filename);
|
||||
sample_object.SetFileExtension(extension);
|
||||
Sample sample;
|
||||
|
||||
sample.SetPath(path);
|
||||
sample.SetFilename(filename_without_extension);
|
||||
sample.SetFileExtension(extension);
|
||||
|
||||
Tags tags(path);
|
||||
|
||||
artist = tags.GetAudioInfo().artist.ToStdString();
|
||||
|
||||
sample_object.SetSamplePack(artist);
|
||||
sample_object.SetChannels(tags.GetAudioInfo().channels);
|
||||
sample_object.SetLength(tags.GetAudioInfo().length);
|
||||
sample_object.SetSampleRate(tags.GetAudioInfo().sample_rate);
|
||||
sample_object.SetBitrate(tags.GetAudioInfo().bitrate);
|
||||
sample.SetSamplePack(artist);
|
||||
sample.SetChannels(tags.GetAudioInfo().channels);
|
||||
sample.SetLength(tags.GetAudioInfo().length);
|
||||
sample.SetSampleRate(tags.GetAudioInfo().sample_rate);
|
||||
sample.SetBitrate(tags.GetAudioInfo().bitrate);
|
||||
|
||||
wxVector<wxVariant> data;
|
||||
|
||||
|
|
@ -419,31 +427,29 @@ void MainFrame::AddSamples(wxArrayString files)
|
|||
{
|
||||
data.clear();
|
||||
data.push_back(false);
|
||||
|
||||
if(settings.IsShowFileExtension())
|
||||
data.push_back(filename_with_extension);
|
||||
else
|
||||
data.push_back(filename);
|
||||
|
||||
data.push_back(sample_object.GetSamplePack());
|
||||
data.push_back(filename);
|
||||
data.push_back(sample.GetSamplePack());
|
||||
data.push_back("");
|
||||
data.push_back(wxString::Format("%d", sample_object.GetChannels()));
|
||||
data.push_back(wxString::Format("%d", sample_object.GetLength()));
|
||||
data.push_back(wxString::Format("%d", sample_object.GetSampleRate()));
|
||||
data.push_back(wxString::Format("%d", sample_object.GetBitrate()));
|
||||
data.push_back(wxString::Format("%d", sample.GetChannels()));
|
||||
data.push_back(wxString::Format("%d", sample.GetLength()));
|
||||
data.push_back(wxString::Format("%d", sample.GetSampleRate()));
|
||||
data.push_back(wxString::Format("%d", sample.GetBitrate()));
|
||||
|
||||
wxLogDebug("Will Add file: %s :: Extension: %s", sample_object.GetFilename(), sample_object.GetFileExtension());
|
||||
wxLogDebug("Adding file: %s :: Extension: %s", sample.GetFilename(), sample.GetFileExtension());
|
||||
|
||||
m_SampleListView->AppendItem(data);
|
||||
sample_array.push_back(sample_object);
|
||||
|
||||
sample_array.push_back(sample);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxString msg = wxString::Format("Error! Cannot open %s, Invalid file type.", sample_object.GetFilename());
|
||||
wxString msg = wxString::Format("Error! Cannot open %s, Invalid file type.", filename_with_extension);
|
||||
m_InfoBar->ShowMessage(msg, wxICON_ERROR);
|
||||
}
|
||||
}
|
||||
progressDialog->Pulse("Updating Database",NULL);
|
||||
|
||||
progressDialog->Pulse("Updating Database..",NULL);
|
||||
|
||||
db.InsertSamples(sample_array);
|
||||
|
||||
progressDialog->Destroy();
|
||||
|
|
@ -473,6 +479,7 @@ void MainFrame::OnDragAndDropToSampleListView(wxDropFilesEvent& event)
|
|||
wxString name;
|
||||
wxString filepath;
|
||||
wxArrayString filepath_array;
|
||||
|
||||
wxProgressDialog* progressDialog = new wxProgressDialog("Reading files..", "Reading files, please wait...",
|
||||
event.GetNumberOfFiles(), this,
|
||||
wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_CAN_ABORT |
|
||||
|
|
@ -494,10 +501,12 @@ void MainFrame::OnDragAndDropToSampleListView(wxDropFilesEvent& event)
|
|||
{
|
||||
wxDir::GetAllFiles(filepath, &filepath_array);
|
||||
}
|
||||
|
||||
progressDialog->Pulse("Reading Samples",NULL);
|
||||
}
|
||||
|
||||
progressDialog->Destroy();
|
||||
|
||||
AddSamples(filepath_array);
|
||||
|
||||
wxLogDebug("Done Inserting Samples:");
|
||||
|
|
@ -508,7 +517,7 @@ void MainFrame::OnAutoImportDir()
|
|||
{
|
||||
wxLogDebug("Start Importing Samples:");
|
||||
|
||||
Settings settings(this,m_ConfigFilepath, m_DatabaseFilepath);
|
||||
Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath);
|
||||
|
||||
wxBusyCursor busy_cursor;
|
||||
wxWindowDisabler window_disabler;
|
||||
|
|
@ -539,10 +548,11 @@ void MainFrame::OnAutoImportDir()
|
|||
wxDir::GetAllFiles(filepath, &filepath_array);
|
||||
}
|
||||
|
||||
progressDialog->Pulse("Reading Samples",NULL);
|
||||
progressDialog->Pulse("Reading Samples", NULL);
|
||||
}
|
||||
|
||||
progressDialog->Destroy();
|
||||
|
||||
AddSamples(filepath_array);
|
||||
|
||||
wxLogDebug("Done Importing Samples:");
|
||||
|
|
@ -1263,7 +1273,8 @@ void MainFrame::RefreshDatabase()
|
|||
// m_FsWatcher->SetOwner(this);
|
||||
// }
|
||||
|
||||
FileInfo MainFrame::GetFileNamePathAndExtension(const wxString& selected, bool checkExtension, bool doGetFilename)
|
||||
FileInfo
|
||||
MainFrame::GetFileNamePathAndExtension(const wxString& selected, bool checkExtension, bool doGetFilename) const
|
||||
{
|
||||
Database db(*m_InfoBar);
|
||||
Settings settings(m_ConfigFilepath, m_DatabaseFilepath);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
#include <wx/mediactrl.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/progdlg.h>
|
||||
#include <wx/setup.h>
|
||||
#include <wx/srchctrl.h>
|
||||
#include <wx/sizer.h>
|
||||
|
|
@ -183,8 +182,9 @@ class MainFrame : public wxFrame
|
|||
void UpdateElapsedTime(wxTimerEvent& event);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
void AddSamples(wxArrayString& files);
|
||||
void OnAutoImportDir();
|
||||
void AddSamples(wxArrayString files);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
void LoadDatabase();
|
||||
void RefreshDatabase();
|
||||
|
|
@ -193,7 +193,7 @@ class MainFrame : public wxFrame
|
|||
// -------------------------------------------------------------------
|
||||
// Getters
|
||||
FileInfo GetFileNamePathAndExtension(const wxString& selected,
|
||||
bool checkExtension = true, bool doGetFilename = true);
|
||||
bool checkExtension = true, bool doGetFilename = true) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Directory watchers
|
||||
|
|
@ -202,5 +202,6 @@ class MainFrame : public wxFrame
|
|||
|
||||
// wxString TagLibTowx(const TagLib::String& in);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
friend class App;
|
||||
};
|
||||
|
|
|
|||
110
src/Sample.cpp
110
src/Sample.cpp
|
|
@ -12,73 +12,67 @@
|
|||
Sample::Sample(){}
|
||||
|
||||
///Overloaded Constructor, Creates a sample profile with supplied data. @see Set()
|
||||
Sample::Sample(int favorite, std::string filename,
|
||||
std::string fileExtension, std::string samplePack,
|
||||
std::string type, int channels, int length,
|
||||
int sampleRate, int bitrate, std::string path,
|
||||
int trashed)
|
||||
Sample::Sample(int favorite, const std::string& filename, const std::string& fileExtension,
|
||||
const std::string& samplePack, const std::string& type, int channels, int length,
|
||||
int sampleRate, int bitrate, const std::string& path, int trashed)
|
||||
{
|
||||
Set(favorite, filename, fileExtension, samplePack, type,
|
||||
channels, length, sampleRate, bitrate, path, trashed);
|
||||
channels, length, sampleRate, bitrate, path, trashed);
|
||||
}
|
||||
|
||||
|
||||
///Clears all sample data;
|
||||
///Clears all sample data
|
||||
void Sample::Clear()
|
||||
{
|
||||
sFavorite = 0;
|
||||
sFilename = "";
|
||||
sFileExtension = "";
|
||||
sSamplePack = "";
|
||||
sType = "";
|
||||
sChannels = 0;
|
||||
sLength = 0;
|
||||
sSampleRate = 0;
|
||||
sBitrate = 0;
|
||||
sPath = "";
|
||||
sTrashed = 0;
|
||||
m_Favorite = 0;
|
||||
m_Channels = 0;
|
||||
m_Length = 0;
|
||||
m_SampleRate = 0;
|
||||
m_Bitrate = 0;
|
||||
m_Trashed = 0;
|
||||
m_Filename = "";
|
||||
m_FileExtension = "";
|
||||
m_SamplePack = "";
|
||||
m_Type = "";
|
||||
m_Path = "";
|
||||
}
|
||||
|
||||
// int Sample::GetFavorite() { return m_Favorite; }
|
||||
// int Sample::GetChannels() { return m_Channels; }
|
||||
// int Sample::GetLength() { return m_Length; }
|
||||
// int Sample::GetSampleRate() { return m_SampleRate; }
|
||||
// int Sample::GetBitrate() { return m_Bitrate; }
|
||||
// int Sample::GetTrashed () { return m_Trashed; }
|
||||
// std::string Sample::GetFilename() { return m_Filename; }
|
||||
// std::string Sample::GetFileExtension() { return m_FileExtension; }
|
||||
// std::string Sample::GetSamplePack() { return m_SamplePack; }
|
||||
// std::string Sample::GetType() { return m_Type; }
|
||||
// std::string Sample::GetPath() { return m_Path; }
|
||||
|
||||
int Sample::GetFavorite(){return sFavorite;}
|
||||
std::string Sample::GetFilename(){return sFilename;}
|
||||
std::string Sample::GetFileExtension(){return sFileExtension;}
|
||||
std::string Sample::GetSamplePack(){return sSamplePack;}
|
||||
std::string Sample::GetType(){return sType;}
|
||||
int Sample::GetChannels(){return sChannels;}
|
||||
int Sample::GetLength(){return sLength;}
|
||||
int Sample::GetSampleRate(){return sSampleRate;}
|
||||
int Sample::GetBitrate(){return sBitrate;}
|
||||
std::string Sample::GetPath(){return sPath;}
|
||||
int Sample::GetTrashed (){return sTrashed;}
|
||||
|
||||
void Sample::Set(int favorite, std::string filename,
|
||||
std::string fileExtension, std::string samplePack,
|
||||
std::string type, int channels, int length,
|
||||
int sampleRate, int bitrate, std::string path,
|
||||
int trashed)
|
||||
void Sample::Set(int favorite, const std::string& filename, const std::string& fileExtension,
|
||||
const std::string& samplePack, const std::string& type, int channels, int length,
|
||||
int sampleRate, int bitrate, const std::string& path, int trashed)
|
||||
{
|
||||
sFavorite = favorite;
|
||||
sFilename = filename;
|
||||
sFileExtension = fileExtension;
|
||||
sSamplePack = samplePack;
|
||||
sType = type;
|
||||
sChannels = channels;
|
||||
sLength = length;
|
||||
sSampleRate = sampleRate;
|
||||
sBitrate = bitrate;
|
||||
sPath = path;
|
||||
sTrashed = trashed;
|
||||
m_Favorite = favorite;
|
||||
m_Filename = filename;
|
||||
m_FileExtension = fileExtension;
|
||||
m_SamplePack = samplePack;
|
||||
m_Type = type;
|
||||
m_Channels = channels;
|
||||
m_Length = length;
|
||||
m_SampleRate = sampleRate;
|
||||
m_Bitrate = bitrate;
|
||||
m_Path = path;
|
||||
m_Trashed = trashed;
|
||||
}
|
||||
|
||||
void Sample::SetFavorite(int favorite){sFavorite = favorite;}
|
||||
void Sample::SetFilename(std::string filename){sFilename = filename;}
|
||||
void Sample::SetFileExtension(std::string fileExtension){sFileExtension = fileExtension;}
|
||||
void Sample::SetSamplePack(std::string samplePack){sSamplePack = samplePack;}
|
||||
void Sample::SetType(std::string type){sType = type;}
|
||||
void Sample::SetChannels(int channels){sChannels = channels;}
|
||||
void Sample::SetLength(int length){sLength = length;}
|
||||
void Sample::SetSampleRate(int sampleRate){sSampleRate = sampleRate;}
|
||||
void Sample::SetBitrate(int bitrate){sBitrate = bitrate;}
|
||||
void Sample::SetPath(std::string path){sPath = path;}
|
||||
void Sample::SetTrashed (int trashed){sTrashed = trashed;}
|
||||
// void Sample::SetFavorite(int favorite) { m_Favorite = favorite; }
|
||||
// void Sample::SetChannels(int channels) { m_Channels = channels; }
|
||||
// void Sample::SetLength(int length) { m_Length = length; }
|
||||
// void Sample::SetSampleRate(int sampleRate) { m_SampleRate = sampleRate; }
|
||||
// void Sample::SetBitrate(int bitrate) { m_Bitrate = bitrate; }
|
||||
// void Sample::SetTrashed (int trashed) { m_Trashed = trashed; }
|
||||
// void Sample::SetFilename(std::string filename) { m_Filename = filename; }
|
||||
// void Sample::SetFileExtension(std::string fileExtension) { m_FileExtension = fileExtension; }
|
||||
// void Sample::SetSamplePack(std::string samplePack) { m_SamplePack = samplePack; }
|
||||
// void Sample::SetType(std::string type) { m_Type = type; }
|
||||
// void Sample::SetPath(std::string path) { m_Path = path; }
|
||||
|
|
|
|||
122
src/Sample.hpp
122
src/Sample.hpp
|
|
@ -11,66 +11,94 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
|
||||
/**
|
||||
* @class Sample
|
||||
* @brief This class holds data for one sample.
|
||||
*/
|
||||
|
||||
class Sample {
|
||||
private:
|
||||
int sFavorite = 0;
|
||||
std::string sFilename = "";
|
||||
std::string sFileExtension = "";
|
||||
std::string sSamplePack = "";
|
||||
std::string sType = "";
|
||||
int sChannels = 0;
|
||||
int sLength = 0;
|
||||
int sSampleRate = 0;
|
||||
int sBitrate = 0;
|
||||
std::string sPath = "";
|
||||
int sTrashed = 0;
|
||||
class Sample
|
||||
{
|
||||
public:
|
||||
Sample();
|
||||
|
||||
Sample(int favorite, std::string filename,
|
||||
std::string fileExtension, std::string samplePack,
|
||||
std::string type, int channels, int length,
|
||||
int sampleRate, int bitrate, std::string path,
|
||||
int trashed);
|
||||
Sample(int favorite, const std::string& filename, const std::string& fileExtension,
|
||||
const std::string& samplePack, const std::string& type, int channels, int length,
|
||||
int sampleRate, int bitrate, const std::string& path, int trashed);
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------
|
||||
int m_Favorite = 0;
|
||||
int m_Channels = 0;
|
||||
int m_Length = 0;
|
||||
int m_SampleRate = 0;
|
||||
int m_Bitrate = 0;
|
||||
int m_Trashed = 0;
|
||||
std::string m_Filename;
|
||||
std::string m_FileExtension;
|
||||
std::string m_SamplePack;
|
||||
std::string m_Type;
|
||||
std::string m_Path;
|
||||
|
||||
public:
|
||||
// -------------------------------------------------------------------
|
||||
// Getters
|
||||
// int GetFavorite();
|
||||
// int GetChannels();
|
||||
// int GetLength();
|
||||
// int GetSampleRate();
|
||||
// int GetBitrate();
|
||||
// int GetTrashed ();
|
||||
// std::string GetFilename();
|
||||
// std::string GetFileExtension();
|
||||
// std::string GetSamplePack();
|
||||
// std::string GetType();
|
||||
// std::string GetPath();
|
||||
|
||||
int GetFavorite() const { return m_Favorite; }
|
||||
int GetChannels() const { return m_Channels; }
|
||||
int GetLength() const { return m_Length; }
|
||||
int GetSampleRate() const { return m_SampleRate; }
|
||||
int GetBitrate() const { return m_Bitrate; }
|
||||
int GetTrashed() const { return m_Trashed; }
|
||||
std::string GetFilename() const { return m_Filename; }
|
||||
std::string GetFileExtension() const { return m_FileExtension; }
|
||||
std::string GetSamplePack() const { return m_SamplePack; }
|
||||
std::string GetType() const { return m_Type; }
|
||||
std::string GetPath() const { return m_Path; }
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Clear sample data
|
||||
void Clear();
|
||||
|
||||
int GetFavorite();
|
||||
std::string GetFilename();
|
||||
std::string GetFileExtension();
|
||||
std::string GetSamplePack();
|
||||
std::string GetType();
|
||||
int GetChannels();
|
||||
int GetLength();
|
||||
int GetSampleRate();
|
||||
int GetBitrate();
|
||||
std::string GetPath();
|
||||
int GetTrashed ();
|
||||
// -------------------------------------------------------------------
|
||||
// Setters
|
||||
void Set(int favorite, const std::string& filename, const std::string& fileExtension,
|
||||
const std::string& samplePack, const std::string& type, int channels, int length,
|
||||
int sampleRate, int bitrate, const std::string& path, int trashed);
|
||||
|
||||
void Set(int favorite, std::string filename,
|
||||
std::string fileExtension, std::string samplePack,
|
||||
std::string type, int channels, int length,
|
||||
int sampleRate, int bitrate, std::string path,
|
||||
int trashed);
|
||||
|
||||
void SetFavorite(int favorite);
|
||||
void SetFilename(std::string filename);
|
||||
void SetFileExtension(std::string fileExtension);
|
||||
void SetSamplePack(std::string samplePack);
|
||||
void SetType(std::string type);
|
||||
void SetChannels(int channels);
|
||||
void SetLength(int length);
|
||||
void SetSampleRate(int sampleRate);
|
||||
void SetBitrate(int bitrate);
|
||||
void SetPath(std::string path);
|
||||
void SetTrashed ( int trashed);
|
||||
// void SetFavorite(int favorite);
|
||||
// void SetChannels(int channels);
|
||||
// void SetLength(int length);
|
||||
// void SetSampleRate(int sampleRate);
|
||||
// void SetBitrate(int bitrate);
|
||||
// void SetTrashed(int trashed);
|
||||
// void SetFilename(std::string filename);
|
||||
// void SetFileExtension(std::string fileExtension);
|
||||
// void SetSamplePack(std::string samplePack);
|
||||
// void SetType(std::string type);
|
||||
// void SetPath(std::string path);
|
||||
|
||||
void SetFavorite(int favorite) { m_Favorite = favorite; }
|
||||
void SetChannels(int channels) { m_Channels = channels; }
|
||||
void SetLength(int length) { m_Length = length; }
|
||||
void SetSampleRate(int sampleRate) { m_SampleRate = sampleRate; }
|
||||
void SetBitrate(int bitrate) { m_Bitrate = bitrate; }
|
||||
void SetTrashed(int trashed) { m_Trashed = trashed; }
|
||||
void SetFilename(const std::string& filename) { m_Filename = filename; }
|
||||
void SetFileExtension(const std::string& fileExtension) { m_FileExtension = fileExtension; }
|
||||
void SetSamplePack(const std::string& samplePack) { m_SamplePack = samplePack; }
|
||||
void SetType(const std::string& type) { m_Type = type; }
|
||||
void SetPath(const std::string& path) { m_Path = path; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue