diff options
author | Wohlstand <admin@wohlnet.ru> | 2017-10-20 04:28:53 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2017-10-20 04:28:53 +0300 |
commit | eb45a7913d83fe2a3dc03033230950e78fb9755d (patch) | |
tree | d7318e79b08404f293fb99bb22e0ed202e07d890 /utils/gen_adldata/file_formats/common.h | |
parent | e95cde9fea4f9daf3e19492021b8a153acae0404 (diff) | |
download | libADLMIDI-eb45a7913d83fe2a3dc03033230950e78fb9755d.tar.gz libADLMIDI-eb45a7913d83fe2a3dc03033230950e78fb9755d.tar.bz2 libADLMIDI-eb45a7913d83fe2a3dc03033230950e78fb9755d.zip |
Added CMake support
Diffstat (limited to 'utils/gen_adldata/file_formats/common.h')
-rw-r--r-- | utils/gen_adldata/file_formats/common.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/utils/gen_adldata/file_formats/common.h b/utils/gen_adldata/file_formats/common.h new file mode 100644 index 0000000..d06059e --- /dev/null +++ b/utils/gen_adldata/file_formats/common.h @@ -0,0 +1,28 @@ +#ifndef COMMON_H +#define COMMON_H + +#include <stdint.h> + +inline uint16_t toUint16BE(const uint8_t *arr) +{ + uint16_t num = arr[1]; + num |= ((arr[0] << 8) & 0xFF00); + return num; +} + +inline int16_t toSint16BE(const uint8_t *arr) +{ + int16_t num = *reinterpret_cast<const int8_t *>(&arr[0]); + num *= 1 << 8; + num |= arr[1]; + return num; +} + +inline uint16_t toUint16LE(const uint8_t *arr) +{ + uint16_t num = arr[0]; + num |= ((arr[1] << 8) & 0xFF00); + return num; +} + +#endif // COMMON_H |