mirror of
https://gitlab.com/samplehive/sample-hive.git
synced 2026-10-23 13:15:00 +02:00
Show milliseconds in addition to minutes and seconds for the length of a sample in the ISO 8601 standard.
This commit is contained in:
+21
-4
@@ -30,6 +30,7 @@
|
||||
#include <wx/dir.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/progdlg.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
namespace SampleHive {
|
||||
|
||||
@@ -125,9 +126,7 @@ namespace SampleHive {
|
||||
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());
|
||||
wxString length = CalculateAndGetISOStandardTime(sample.GetLength());
|
||||
|
||||
wxVector<wxVariant> data;
|
||||
|
||||
@@ -141,7 +140,7 @@ namespace SampleHive {
|
||||
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(length);
|
||||
data.push_back(wxString::Format("%d", sample.GetSampleRate()));
|
||||
data.push_back(wxString::Format("%d", sample.GetBitrate()));
|
||||
data.push_back(path);
|
||||
@@ -232,4 +231,22 @@ namespace SampleHive {
|
||||
return sample_path.ToStdString();
|
||||
}
|
||||
|
||||
wxString cUtils::CalculateAndGetISOStandardTime(wxLongLong length)
|
||||
{
|
||||
const int min_digits = 2;
|
||||
const size_t max_digits = 2;
|
||||
wxString iso_length;
|
||||
|
||||
int min = static_cast<int>((length / 60000).GetValue());
|
||||
int sec = static_cast<int>(((length % 60000) / 1000).GetValue());
|
||||
int ms = static_cast<int>((length % 1000).GetValue());
|
||||
|
||||
iso_length = wxString::Format("%s:%s.%s",
|
||||
wxString::Format("%0*i", min_digits, min).Left(max_digits),
|
||||
wxString::Format("%0*i", min_digits, sec).Left(max_digits),
|
||||
wxString::Format("%0*i", min_digits + 1, ms).Left(max_digits + 1));
|
||||
|
||||
return iso_length;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace SampleHive {
|
||||
bool doGetFilename = true);
|
||||
void AddSamples(wxArrayString& files, wxWindow* parent);
|
||||
void OnAutoImportDir(const wxString& pathToDirectory, wxWindow* parent);
|
||||
wxString CalculateAndGetISOStandardTime(wxLongLong length);
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user