sptk
-
namespace sptk
Functions
-
template<typename T>
bool ReadStream(T *data_to_read, std::istream *input_stream) - Parameters:
data_to_read – [out] Scalar.
input_stream – [out] Stream to be read.
- Returns:
True on success, false on failure.
-
bool ReadStream(sptk::Matrix *matrix_to_read, std::istream *input_stream)
- Parameters:
matrix_to_read – [out] Matrix.
input_stream – [out] Stream to be read.
- Returns:
True on success, false on failure.
-
bool ReadStream(sptk::SymmetricMatrix *matrix_to_read, std::istream *input_stream)
- Parameters:
matrix_to_read – [out] Symmetric matrix.
input_stream – [out] Stream to be read.
- Returns:
True on success, false on failure.
-
template<typename T>
bool ReadStream(bool zero_padding, int stream_skip, int read_point, int read_size, std::vector<T> *sequence_to_read, std::istream *input_stream, int *actual_read_size) - Parameters:
zero_padding – [in] If true and \(L'>0\), pad \(L-L'\) elements with zeros and return true. If false, padding is not performed and return false.
stream_skip – [in] Skip size.
read_point – [in] Insert index in vector.
read_size – [in] Target read size, \(L\).
sequence_to_read – [out] Vector.
input_stream – [out] Stream to be read.
actual_read_size – [out] Actual read size, \(L'\).
- Returns:
True on success, false on failure.
-
template<typename T>
bool WriteStream(T data_to_write, std::ostream *output_stream) - Parameters:
data_to_write – [in] Scalar.
output_stream – [out] Stream to be write.
- Returns:
True on success, false on failure.
-
bool WriteStream(const sptk::Matrix &matrix_to_write, std::ostream *output_stream)
- Parameters:
matrix_to_write – [in] Matrix.
output_stream – [out] Stream to be write.
- Returns:
True on success, false on failure.
-
bool WriteStream(const sptk::SymmetricMatrix &matrix_to_write, std::ostream *output_stream)
- Parameters:
matrix_to_write – [in] Symmetric matrix.
output_stream – [out] Stream to be write.
- Returns:
True on success, false on failure.
-
template<typename T>
bool WriteStream(int write_point, int write_size, const std::vector<T> &sequence_to_write, std::ostream *output_stream, int *actual_write_size) - Parameters:
write_point – [in] Start index.
write_size – [in] Target write size.
sequence_to_write – [in] Vector.
output_stream – [out] Stream to be write.
actual_write_size – [out] Actual write size.
- Returns:
True on success, false on failure.
-
template<typename T>
bool SnPrintf(T data, const std::string &print_format, std::size_t buffer_size, char *buffer) - Parameters:
data – [in] Data.
print_format – [in] Print format.
buffer_size – [in] Buffer size.
buffer – [out] Formatted data.
- Returns:
True on success, false on failure.
-
const char *ConvertBooleanToString(bool input)
- Parameters:
input – [in] Boolean.
- Returns:
Converted string, “TRUE” or “FALSE”.
-
bool ConvertStringToInteger(const std::string &input, int *output)
- Parameters:
input – [in] String.
output – [out] Converted integer value.
- Returns:
True on success, false on failure.
-
bool ConvertStringToDouble(const std::string &input, double *output)
- Parameters:
input – [in] String.
output – [out] Converted float value.
- Returns:
True on success, false on failure.
-
bool ConvertSpecialStringToDouble(const std::string &input, double *output)
- Parameters:
input – [in] String can be “pi”, “db”, “cent”, “semitone”, “octave”, “sqrtX”, “lnX”, “expX”, and “X”, where “X” is a number.
output – [out] Converted float value.
- Returns:
True on success, false on failure.
-
bool IsEven(int num)
- Parameters:
num – [in] A number.
- Returns:
True if given number is even, false otherwise.
-
bool IsInRange(int num, int min, int max)
- Parameters:
num – [in] A number.
min – [in] Minimum value.
max – [in] Maximum value.
- Returns:
True if given number is in [min, max], false otherwise.
-
bool IsInRange(double num, double min, double max)
- Parameters:
num – [in] A number.
min – [in] Minimum value.
max – [in] Maximum value.
- Returns:
True if given number is in [min, max], false otherwise.
-
bool IsPowerOfTwo(int num)
- Parameters:
num – [in] A number.
- Returns:
True if given number is \(2^n\), where \(n\) is a non-negative number, false otherwise.
-
bool IsValidAlpha(double alpha)
- Parameters:
alpha – [in] All-pass constant, \(\alpha\).
- Returns:
True if given alpha satisfy \(|\alpha| < 1\), false otherwise.
-
bool IsValidGamma(double gamma)
- Parameters:
gamma – [in] Gamma, \(\gamma\).
- Returns:
True if given gamma satisfy \(|\gamma| \le 1\), false otherwise.
-
int NextPowTwo(int num)
- Parameters:
num – [in] A number, \(x\).
- Returns:
The smallest \(2^n\) greater than or equal to \(x\), where \(n\) is a non-negative number.
-
int ExtractSign(double num)
- Parameters:
num – [in] A number, \(x\).
- Returns:
\(\mathrm{sgn}(x)\).
-
double FloorLog(double num)
- Parameters:
num – [in] A number, \(x\).
- Returns:
\(\max(\ln(x), -1 \times 10^{10})\).
-
double FloorLog2(double num)
- Parameters:
num – [in] A number, \(x\).
- Returns:
\(\max(\log_2(x), -1 \times 10^{10})\).
-
double FloorLog10(double num)
- Parameters:
num – [in] A number, \(x\).
- Returns:
\(\max(\log_{10}(x), -1 \times 10^{10})\).
-
double AddInLogSpace(double log_x, double log_y)
- Parameters:
log_x – [in] \(\ln(x)\).
log_y – [in] \(\ln(y)\).
- Returns:
\(\ln(x + y)\).
-
double Warp(double omega, double alpha)
- Parameters:
omega – [in] Angle, \(\omega\).
alpha – [in] Frequency warping factor, \(\alpha\).
- Returns:
Output warped by the 1st order all-pass function.
-
double Warp(double omega, double alpha, double theta)
- Parameters:
omega – [in] Angle, \(\omega\).
alpha – [in] Frequency warping factor, \(\alpha\).
theta – [in] Frequency emphasis factor, \(\theta\).
- Returns:
Output warped by the 2nd order all-pass function.
-
void PrintDataType(const std::string &symbol, std::ostream *stream)
- Parameters:
symbol – [in] A character represents data type.
stream – [out] Stream to be written readable data type.
-
void PrintErrorMessage(const std::string &program_name, const std::ostringstream &message)
Print error message to standard error.
- Parameters:
program_name – [in] Name of SPTK command.
message – [in] Error message.
-
bool SetBinaryMode()
Set standard input/output to binary mode.
-
template<typename T>