Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HighBlueParsers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Best
HighBlueParsers
Commits
206e7fb0
Commit
206e7fb0
authored
5 years ago
by
Paul Best
Browse files
Options
Downloads
Patches
Plain Diff
Incude milliseconds in filename (all OS compatible)
parent
a54c42de
No related branches found
No related tags found
2 merge requests
!2
HighBlueParser dev branch merged to empty main branch
,
!1
High blue rec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/filewriter.cpp
+17
-4
17 additions, 4 deletions
src/filewriter.cpp
src/main.cpp
+1
-1
1 addition, 1 deletion
src/main.cpp
with
18 additions
and
5 deletions
src/filewriter.cpp
+
17
−
4
View file @
206e7fb0
...
...
@@ -8,7 +8,9 @@
#include
<stdexcept>
#include
<vector>
#include
<iostream>
#include
<ctime>
#include
<chrono>
#include
<sstream>
#include
<iomanip>
FileWriter
::
FileWriter
(
std
::
string
&
filename_template
,
size_t
num_channels
,
size_t
sample_rate
)
:
filename_template
(
filename_template
),
num_channels
(
num_channels
),
sample_rate
(
sample_rate
)
{
...
...
@@ -22,9 +24,20 @@ FileWriter::~FileWriter() {
std
::
string
FileWriter
::
generate_filename
()
{
// this has of course nothing to do with file writing and could be pulled
// out, but I doubt anybody will ever care
time_t
timer
;
time
(
&
timer
);
struct
tm
*
timeinfo
=
localtime
(
&
timer
);
using
namespace
std
::
chrono
;
auto
miliseconds
=
duration_cast
<
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
long
seconds
=
miliseconds
/
1000
;
struct
tm
*
timeinfo
=
localtime
(
&
seconds
);
size_t
found
=
filename_template
.
find
(
"%z"
);
while
(
found
!=
std
::
string
::
npos
){
std
::
stringstream
ss
;
ss
<<
std
::
setw
(
3
)
<<
std
::
setfill
(
'0'
)
<<
miliseconds
%
1000
;
std
::
string
s
=
ss
.
str
();
filename_template
.
replace
(
found
,
2
,
s
);
found
=
filename_template
.
find
(
"%z"
,
found
+
3
);
}
size_t
length
=
0
;
size_t
space
=
0
;
std
::
vector
<
char
>
buffer
;
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
1
−
1
View file @
206e7fb0
...
...
@@ -20,7 +20,7 @@ void print_usage(char *name) {
std
::
cout
<<
" CHANNELS: number of channels to record (1 to 5)"
<<
std
::
endl
;
std
::
cout
<<
" RATE: sample rate in Hz to record at (integral number)"
<<
std
::
endl
;
std
::
cout
<<
" FILENAME: output file name; should include strftime() format specifiers"
<<
std
::
endl
;
std
::
cout
<<
" if CHUNKLEN is specified. Example: location/recording_%Y%m%dT%H%M%S.wav"
<<
std
::
endl
;
std
::
cout
<<
" if CHUNKLEN is specified.
For miliseconds, use %z.
Example: location/recording_%Y%m%dT%H%M%S
%z
.wav"
<<
std
::
endl
;
std
::
cout
<<
" CHUNKLEN: length per output file in seconds; will start a new file whenever"
<<
std
::
endl
;
std
::
cout
<<
" this length is reached. If not given or zero, will record a single file."
<<
std
::
endl
;
std
::
cout
<<
" TOTALLEN: total recording length; will stop when this length is reached."
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment