32#ifndef RCSC_PLAYER_AUDIO_CODEC_H
33#define RCSC_PLAYER_AUDIO_CODEC_H
37#include <unordered_map>
59 std::string M_char_set;
86 void createMap(
const int shift );
95 std::int32_t posToBit18(
const Vector2D & pos )
const;
102 void bit18ToPos(
const std::int32_t & val,
110 std::int32_t posToBit19(
const Vector2D & pos )
const;
117 void bit19ToPos(
const std::int32_t & val,
126 std::int32_t posVelToBit31(
const Vector2D & pos,
135 void bit31ToPosVel(
const std::int32_t & val,
147 return M_char_to_int_map;
156 return M_int_to_char_map;
168 std::string & to )
const;
177 std::int64_t * to )
const;
207 std::string & to )
const;
231 std::string & to )
const;
256 std::string & to )
const;
286 const double & norm_factor )
const;
300 const double & norm_factor )
const;
communication message encoder/decorder
Definition: audio_codec.h:49
static const double ERROR_VALUE
constant error value (= std::numeric_limits< double >::max())
Definition: audio_codec.h:55
std::vector< char > IntToCharCont
map from int to char
Definition: audio_codec.h:52
static char unum2hex(const int unum)
convert decimal uniform number to hex number
bool encodePosToStr3(const Vector2D &pos, std::string &to) const
encode position to 3 characters.
static AudioCodec & instance()
singleton interface
static int hex2unum(const char hex)
convert hex number character to decimal uniform number.
static const AudioCodec & i()
singleton interface
bool encodePosVelToStr5(const Vector2D &pos, const Vector2D &vel, std::string &to) const
encode position and velocity to 5 characters.
bool decodeStrToInt64(const std::string &from, std::int64_t *to) const
decode the message string to the decimal (64bit) integer
bool encodeInt64ToStr(const std::int64_t &ival, const int len, std::string &to) const
encode decimal (64bit) integer to the encoded string.
std::string encodeCoordToStr2(const double &xy, const double &norm_factor) const
encode coordinate value( x or y ) to 2 characters.
const IntToCharCont & intToCharMap() const
get integer to character map object
Definition: audio_codec.h:154
double decodeStr2ToCoord(const char ch1, const char ch2, const double &norm_factor) const
decode 2 characters to coordinate value( x or y )
std::string encodePosToStr4(const Vector2D &pos) const
encode position value to 4 characters with 0.1 step
double decodeCharToPercentage(const char ch) const
decode 1 character to the real number [0,1]
bool encodeUnumPosToStr4(const int unum, const Vector2D &pos, std::string &to) const
encode uniform number and position to 4 characters.
std::unordered_map< char, int > CharToIntCont
map from char to int
Definition: audio_codec.h:51
Vector2D decodeStr4ToPos(const std::string &from) const
decode 4 characters to position value
bool decodeStr4ToUnumPos(const std::string &from, int *unum, Vector2D *pos) const
decode 4 characters to uniform number and position
const CharToIntCont & charToIntMap() const
get character to interger map object
Definition: audio_codec.h:145
double decodeCharToSpeed(const char ch) const
decode 1 character to speed value
char encodeSpeedToChar(const double &xy) const
encode speed value to 1 character.
bool decodeStr5ToPosVel(const std::string &from, Vector2D *pos, Vector2D *vel) const
decode 5 characters to position and velocity
bool decodeStr3ToPos(const std::string &from, Vector2D *pos) const
decode 3 characters to and position
char encodePercentageToChar(const double &value) const
encode % value to 1 character
2D point vector class
Definition: vector_2d.h:46
2d vector class Header File.