aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2023-09-08 01:07:38 +0200
committerDaniil Cherednik <dan.cherednik@gmail.com>2023-09-08 01:07:38 +0200
commitf0456e6642047976b407a80cafec3ccb473e3332 (patch)
tree119a50ef1bddbc04d641bf2564d93f35f07bee23
parent52271de4d7dbb11379cfc1b3dddc0a35852a06d8 (diff)
downloadatracdenc-f0456e6642047976b407a80cafec3ccb473e3332.tar.gz
Some ux improvements
- help page - remove noise messages
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/atrac/atrac3.h4
-rw-r--r--src/help.cpp34
-rw-r--r--src/help.h4
-rw-r--r--src/main.cpp65
5 files changed, 74 insertions, 34 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6f63ef0..eb7a8d9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -90,6 +90,7 @@ add_library(atracdenc_impl STATIC ${SOURCE_ATRACDENC_IMPL})
target_link_libraries(atracdenc_impl fft_impl pcm_io oma bitstream ${SNDFILE_LIBRARIES})
set(SOURCE_EXE
main.cpp
+ help.cpp
)
add_executable(atracdenc ${SOURCE_EXE})
target_link_libraries(atracdenc pcm_io oma atracdenc_impl ${SNDFILE_LIBRARIES})
diff --git a/src/atrac/atrac3.h b/src/atrac/atrac3.h
index 7834956..caf49f7 100644
--- a/src/atrac/atrac3.h
+++ b/src/atrac/atrac3.h
@@ -256,9 +256,7 @@ struct TAtrac3EncoderSettings {
, NoTonalComponents(noTonalComponents)
, SourceChannels(sourceChannels)
, BfuIdxConst(bfuIdxConst)
- {
- std::cout << bitrate << " " << ConteinerParams->Bitrate << std::endl;
- }
+ { }
const TContainerParams* ConteinerParams;
const bool NoGainControll;
const bool NoTonalComponents;
diff --git a/src/help.cpp b/src/help.cpp
new file mode 100644
index 0000000..45d17b3
--- /dev/null
+++ b/src/help.cpp
@@ -0,0 +1,34 @@
+#include "help.h"
+#include <string>
+
+const std::string& GetHelp() {
+ const static std::string txt = R"(
+atracdenc is a tool to encode in to ATRAC1 or ATRAC3, decode from ATRAC1 formats
+
+Usage:
+atracdenc {-e <codec> | --encode=<codec> | -d | --decode} -i <in> -o <out>
+
+-e or --encode encode file using one of codecs
+ {atrac1 | atrac3 | atrac3_lp}
+-d or --decode decode file (only ATRAC1 supported for decoding)
+-i path to input file
+-o path to output file
+-h print help and exit
+
+--bitrate allow to specify bitrate (for ATRAC3 + RealMedia container only)
+
+Advanced options:
+--bfuidxconst Set constant amount of used BFU (ATRAC1, ATRAC3).
+--bfuidxfast Enable fast search of BFU amount (ATRAC1)
+--notransient[=mask] Disable transient detection and use optional mask
+ to set bands with forced short MDCT window
+
+Examples:
+Encode in to ATRAC1 (SP)
+ atracdenc -e atrac1 -i my_file.wav -o my_file.aea
+Encode in to ATRAC3 (LP2)
+ atracdenc -e atrac3 -i my_file.wav -o my_file.oma
+)";
+
+ return txt;
+}
diff --git a/src/help.h b/src/help.h
new file mode 100644
index 0000000..a4d0b59
--- /dev/null
+++ b/src/help.h
@@ -0,0 +1,4 @@
+#pragma once
+#include <string>
+
+const std::string& GetHelp();
diff --git a/src/main.cpp b/src/main.cpp
index 708c24a..2e64aed 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,6 +22,8 @@
#include <getopt.h>
+#include "help.h"
+
#include "pcmengin.h"
#include "wav.h"
#include "aea.h"
@@ -47,13 +49,12 @@ using namespace NAtracDEnc;
typedef std::unique_ptr<TPCMEngine<TFloat>> TPcmEnginePtr;
typedef std::unique_ptr<IProcessor<TFloat>> TAtracProcessorPtr;
-static void printUsage(const char* myName)
+static void printUsage(const char* myName, const string& err = string())
{
- cout << "\tusage: " << myName << " <-e <atrac1|atrac3>|-d> <-i input> <-o output>\n" << endl;
- cout << "-e atrac1|atrac3|atrac3_lp4 encode mode (PCM -> ATRAC), -i wav file, -o aea/oma file" << endl;
- cout << "-d decode mode (ATRAC -> PCM), -i aea file, -o wav file" << endl;
- cout << "-h get help" << endl;
-
+ if (!err.empty()) {
+ cerr << err << endl;
+ }
+ cerr << "\tuse: " << myName << " -h to get help" << endl;
}
static void printProgress(int percent)
@@ -65,21 +66,6 @@ static void printProgress(int percent)
fflush(stdout);
}
-static string GetHelp()
-{
- return "\n--encode [atrac1|atrac3|atrac3_lp4] -e <atrac1|atrac3> \t - encode mode (default codec is ATRAC1)"
- "\n--decode -d \t - decode mode (only ATRAC1 supported)"
- "\n -i input file"
- "\n -o output file"
- "\n --bitrate (only if supported by codec)"
- "\nAdvanced options:\n --bfuidxconst\t Set constant amount of used BFU (ATRAC1, ATRAC3). "
- "WARNING: It is not a lowpass filter! Do not use it to cut off hi frequency."
- "\n --bfuidxfast\t enable fast search of BFU amount (ATRAC1)"
- "\n --notransient[=mask] disable transient detection and use optional mask to set bands with short MDCT window "
- "(ATRAC1)";
- /*"\n --nogaincontrol disable gain control (ATRAC3)"*/
-}
-
static string GetFileExt(const string& path) {
size_t dotPos = path.rfind('.');
std::string ext;
@@ -163,10 +149,12 @@ static void PrepareAtrac1Encoder(const string& inFile,
numChannels,
TPCMEngine<TFloat>::TReaderPtr((*wavIO)->GetPCMReader<TFloat>())));
if (!noStdOut)
- cout << "Input file: " << inFile
+ cout << "Input\n Filename: " << inFile
<< "\n Channels: " << (int)numChannels
<< "\n SampleRate: " << (*wavIO)->GetSampleRate()
- << "\n TotalSamples: " << totalSamples
+ << "\n Duration (sec): " << *totalSamples / (*wavIO)->GetSampleRate()
+ << "\nOutput:\n Filename: " << outFile
+ << "\n Codec: ATRAC1"
<< endl;
atracProcessor->reset(new TAtrac1Encoder(std::move(aeaIO), std::move(encoderSettings)));
}
@@ -181,11 +169,12 @@ static void PrepareAtrac1Decoder(const string& inFile,
{
TCompressedInputPtr aeaIO = CreateAeaInput(inFile);
*totalSamples = aeaIO->GetLengthInSamples();
- uint64_t length = aeaIO->GetLengthInSamples();
if (!noStdOut)
- cout << "Name: " << aeaIO->GetName()
- << "\n Channels: " << aeaIO->GetChannelNum()
- << "\n Length: " << length
+ cout << "Input\n Filename: " << inFile
+ << "\n Name: " << aeaIO->GetName()
+ << "\n Channels: " << (int)aeaIO->GetChannelNum()
+ << "\nOutput:\n Filename: " << outFile
+ << "\n Codec: PCM"
<< endl;
wavIO->reset(new TWav(outFile, aeaIO->GetChannelNum(), 44100));
pcmEngine->reset(new TPCMEngine<TFloat>(4096,
@@ -204,8 +193,6 @@ static void PrepareAtrac3Encoder(const string& inFile,
TAtracProcessorPtr* atracProcessor)
{
std::cout << "WARNING: ATRAC3 is uncompleted, result will be not good )))" << std::endl;
- if (!noStdOut)
- std::cout << "bitrate " << encoderSettings.ConteinerParams->Bitrate << std::endl;
const int numChannels = encoderSettings.SourceChannels;
*totalSamples = wavIO->GetTotalSamples();
const uint64_t numFrames = (*totalSamples) / 1024;
@@ -218,16 +205,19 @@ static void PrepareAtrac3Encoder(const string& inFile,
TCompressedOutputPtr omaIO;
+ string contName;
if (ext == "wav" || ext == "at3") {
+ contName = "AT3 (RIFF)";
omaIO = CreateAt3Output(outFile, numChannels, numFrames,
encoderSettings.ConteinerParams->FrameSz,
encoderSettings.ConteinerParams->Js);
} else if (ext == "rm") {
+ contName = "RealMedia";
omaIO = CreateRmOutput(outFile, "test", numChannels,
numFrames, encoderSettings.ConteinerParams->FrameSz,
encoderSettings.ConteinerParams->Js);
} else {
-
+ contName = "OMA";
omaIO.reset(new TOma(outFile,
"test",
numChannels,
@@ -236,6 +226,17 @@ static void PrepareAtrac3Encoder(const string& inFile,
encoderSettings.ConteinerParams->Js));
}
+ if (!noStdOut)
+ cout << "Input:\n Filename: " << inFile
+ << "\n Channels: " << (int)numChannels
+ << "\n SampleRate: " << wavIO->GetSampleRate()
+ << "\n Duration (sec): " << *totalSamples / wavIO->GetSampleRate()
+ << "\nOutput:\n Filename: " << outFile
+ << "\n Codec: ATRAC3"
+ << "\n Container: " << contName
+ << "\n Bitrate: " << encoderSettings.ConteinerParams->Bitrate
+ << endl;
+
pcmEngine->reset(new TPCMEngine<TFloat>(4096,
numChannels,
TPCMEngine<TFloat>::TReaderPtr(wavIO->GetPCMReader<TFloat>())));
@@ -285,7 +286,9 @@ int main_(int argc, char* const* argv)
// this is the default
} else {
// bad value
- printUsage(myName);
+ string err = "unrecognized encoding codec: ";
+ err.append(optarg);
+ printUsage(myName, err);
return 1;
}
}