diff --git a/libs/getLoudness/win32/coder_array.h b/libs/getLoudness/win32/coder_array.h new file mode 100644 index 0000000..f9ec234 --- /dev/null +++ b/libs/getLoudness/win32/coder_array.h @@ -0,0 +1,786 @@ +/* Copyright 2019 The Mathworks, Inc. */ +/* Copied from + * fullfile(matlabroot,'extern','include','coder','coder_array','coder_array_rtw_cpp11.h') */ + +#ifndef _mw_coder_array_cpp11_h +#define _mw_coder_array_cpp11_h + +// Usage: +// +// coder::array: T base type of data, N number of dimensions +// +// coder::array() +// : default constructor +// coder::array(coder::array const &) +// : copy constructor (always make a deep copy of other array) +// coder::array(T const *data, SizeType const *sz) +// : Set data with sizes of this array. +// : (Data is not copied, data is not deleted) +// coder::array::operator = (coder coder::array &) +// : Assign into this array; +// : delete its previous contents (if owning the data.) +// set(T const *data, SizeType sz1, SizeType sz2, ...) +// : Set data with dimensions. +// : (Data is not copied, data is not deleted) +// set_size(SizeType sz1, SizeType sz2, ...) +// : Set sizes of array. Reallocate memory of data if needed. +// bool is_owner() : Return true if the data is owned by the class. +// void set_owner(b) : Set if the data is owned by the class. +// SizeType capacity() : How many entries are reserved by memory allocation. +// reshape( SizeType sz1, SizeType sz2, ...) +// : Reshape array to a different ND shape. Do not copy the data. +// : The number of elements must not be changed (numel()==sz1*sz2*...) +// : Return the array with possibly new number of dimensions. +// clear() : Reset array to be empty. +// SizeType numel() : Return the number of elements. +// operator [] (SizeType index) : Extract element at linear index (0 based.) +// size(SizeType dimension) : Size of array of the provided dimension. +// SizeType * size() : Return the pointer to all the sizes of this array. +// SizeType index(SizeType i1, SizeType i2, ...) +// : Compute the linear index from ND index (i1,i2,...) +// at(SizeType i1, SizeType i2, ...) : The element at index (i1,i2,...) + +#include +#include +#include +#include +#include + +#ifndef INT32_T +#include "rtwtypes.h" +#endif + +namespace coder { + +#ifndef CODER_ARRAY_NEW_DELETE +#define CODER_ARRAY_NEW_DELETE +#define CODER_NEW(T, N) new T[N] +#define CODER_DELETE(P) delete[](P) +#endif + +#ifndef CODER_ARRAY_SIZE_TYPE_DEFINED +using SizeType = int; +#endif + +namespace std = ::std; + +namespace detail { + +#ifndef CODER_ARRAY_DATA_PTR_DEFINED +template +class data_ptr { + public: + using value_type = T; + using size_type = SZ; + + data_ptr() + : data_(nullptr) + , size_(0) + , capacity_(0) + , owner_(false) { + } + data_ptr(T* _data, SZ _sz) + : data_(_data) + , size_(_sz) + , capacity_(_sz) + , owner_(false) { + } + + data_ptr(data_ptr const& _other) + : data_(_other.owner_ ? nullptr : _other.data_) + , size_(_other.owner_ ? 0 : _other.size_) + , capacity_(_other.owner_ ? 0 : _other.capacity_) + , owner_(_other.owner_) { + if (owner_) { + resize(_other.size_); + (void)std::copy(_other.data_, _other.data_ + size_, data_); + } + } + + ~data_ptr() { + if (owner_) { + CODER_DELETE(data_); + } + } + SZ capacity() const { + return capacity_; + } + void reserve(SZ _n) { + if (_n > capacity_) { + T* const new_data{CODER_NEW(T, _n)}; + (void)std::copy(data_, data_ + size_, new_data); + if (owner_) { + CODER_DELETE(data_); + } + data_ = new_data; + capacity_ = _n; + owner_ = true; + } + } + void resize(SZ _n) { + reserve(_n); + size_ = _n; + } + + private: + // Prohibit use of assignment operator to prevent subtle bugs + void operator=(data_ptr const& _other); + + public: + void set(T* _data, SZ _sz) { + if (owner_) { + CODER_DELETE(data_); + } + data_ = _data; + size_ = _sz; + owner_ = false; + capacity_ = size_; + } + + void copy(T const* const _data, SZ _size) { + if (data_ == _data) { + size_ = _size; + return; + } + if (owner_) { + CODER_DELETE(data_); + } + data_ = CODER_NEW(T, _size); + owner_ = true; + size_ = _size; + capacity_ = size_; + (void)std::copy(_data, _data + _size, data_); + } + + void copy(data_ptr const& _other) { + copy(_other.data_, _other.size_); + } + + operator T*() { + return &data_[0]; + } + + operator T const *() const { + return &data_[0]; + } + + T& operator[](SZ _index) { + return data_[_index]; + } + T const& operator[](SZ _index) const { + return data_[_index]; + } + + T* operator->() { + return data_; + } + + T const* operator->() const { + return data_; + } + + bool is_null() const { + return data_ == nullptr; + } + + void clear() { + if (owner_) { + CODER_DELETE(data_); + } + data_ = nullptr; + size_ = 0; + capacity_ = 0; + owner_ = false; + } + + bool is_owner() const { + return owner_; + } + + void set_owner(bool _b) { + owner_ = _b; + } + + private: + T* data_; + SZ size_; + SZ capacity_; + bool owner_; +}; +#endif + +} // namespace detail + +// Implementing the random access iterator class so coder::array can be +// used in STL iterators. +template +class array_iterator : public std::iterator { + public: + array_iterator() + : arr_(nullptr) + , i_(0) { + } + array_iterator(array_iterator const& other) + : arr_(other.arr_) + , i_(other.i_) { + } + ~array_iterator() { + } + typename T::value_type& operator*() const { + return (*arr_)[i_]; + } + typename T::value_type* operator->() const { + return &(*arr_)[i_]; + } + typename T::value_type& operator[](typename T::size_type _di) const { + return (*arr_)[i_ + _di]; + } + array_iterator& operator++() { + ++i_; + return *this; + } + array_iterator& operator--() { + --i_; + return *this; + } + array_iterator operator++(int) { + array_iterator cp{*this}; + ++i_; + return cp; + } + array_iterator operator--(int) { + array_iterator cp{*this}; + --i_; + return cp; + } + array_iterator& operator=(array_iterator const& _other) { + this->i_ = _other.i_; + return *this; + } + bool operator==(array_iterator const& _other) const { + return i_ == _other.i_; + } + bool operator!=(array_iterator const& _other) const { + return i_ != _other.i_; + } + bool operator<(array_iterator const& _other) const { + return i_ < _other.i_; + } + bool operator>(array_iterator const& _other) const { + return i_ > _other.i_; + } + bool operator<=(array_iterator const& _other) const { + return i_ <= _other.i_; + } + bool operator>=(array_iterator const& _other) const { + return i_ >= _other.i_; + } + array_iterator operator+(typename T::size_type _add) const { + array_iterator cp{*this}; + cp.i_ += _add; + return cp; + } + array_iterator& operator+=(typename T::size_type _add) { + this->i_ += _add; + return *this; + } + array_iterator operator-(typename T::size_type _subtract) const { + array_iterator cp{*this}; + cp.i_ -= _subtract; + return cp; + } + array_iterator& operator-=(typename T::size_type _subtract) { + this->i_ -= _subtract; + return *this; + } + typename T::size_type operator-(array_iterator const& _other) const { + return static_cast(this->i_ - _other.i_); + } + + array_iterator(T* _arr, typename T::size_type _i) + : arr_(_arr) + , i_(_i) { + } + + private: + T* arr_; + typename T::size_type i_; +}; + +// Const version of the array iterator. +template +class const_array_iterator : public std::iterator { + public: + const_array_iterator() + : arr_(nullptr) + , i_(0) { + } + const_array_iterator(const_array_iterator const& other) + : arr_(other.arr_) + , i_(other.i_) { + } + ~const_array_iterator() { + } + typename T::value_type const& operator*() const { + return (*arr_)[i_]; + } + typename T::value_type const* operator->() const { + return &(*arr_)[i_]; + } + typename T::value_type const& operator[](typename T::size_type _di) const { + return (*arr_)[i_ + _di]; + } + const_array_iterator& operator++() { + ++i_; + return *this; + } + const_array_iterator& operator--() { + --i_; + return *this; + } + const_array_iterator operator++(int) { + const_array_iterator copy{*this}; + ++i_; + return copy; + } + const_array_iterator operator--(int) { + const_array_iterator copy{*this}; + --i_; + return copy; + } + const_array_iterator& operator=(const_array_iterator const& _other) { + this->i_ = _other.i_; + return *this; + } + bool operator==(const_array_iterator const& _other) const { + return i_ == _other.i_; + } + bool operator!=(const_array_iterator const& _other) const { + return i_ != _other.i_; + } + bool operator<(const_array_iterator const& _other) const { + return i_ < _other.i_; + } + bool operator>(const_array_iterator const& _other) const { + return i_ > _other.i_; + } + bool operator<=(const_array_iterator const& _other) const { + return i_ <= _other.i_; + } + bool operator>=(const_array_iterator const& _other) const { + return i_ >= _other.i_; + } + const_array_iterator operator+(typename T::size_type _add) const { + const_array_iterator cp{*this}; + cp.i_ += _add; + return cp; + } + const_array_iterator& operator+=(typename T::size_type _add) { + this->i_ += _add; + return *this; + } + const_array_iterator operator-(typename T::size_type _subtract) const { + const_array_iterator cp{*this}; + cp.i_ -= _subtract; + return cp; + } + + const_array_iterator& operator-=(typename T::size_type _subtract) { + this->i_ -= _subtract; + return *this; + } + + typename T::size_type operator-(const_array_iterator const& _other) const { + return static_cast(this->i_ - _other.i_); + } + + const_array_iterator(T const* _arr, typename T::size_type _i) + : arr_(_arr) + , i_(_i) { + } + + private: + T const* arr_; + typename T::size_type i_; + typename T::size_type n_; +}; + +namespace detail { + +// detail::numel: Compile-time product of the given size vector of length N. +template +class numel { + public: + template + static SZ compute(SZ _size[]) { + return _size[N - 1] * numel::compute(_size); + } +}; +template <> +class numel<0> { + public: + template + static SZ compute(SZ[]) { + return 1; + } +}; + +// Compute the product for a set of numeric arguments: product(10, 20, 30, ...) => +// 10*20*30*... +template +struct product_i { + static SZ compute(First _f, Rest... _rest) { + return _f * product_i::compute(_rest...); + } +}; +template +struct product_i { + static SZ compute(Last _l) { + return _l; + } +}; + +template +SZ product(Args... args) { + return product_i::compute(args...); +} + +// Compute flat index from (column-major) ND size vector and a list of indices. +template +class index_nd { + public: + template + static SZ compute(SZ const _size[], SZ const _indices[]) { + SZ const weight{numel::compute(_size)}; + return weight * _indices[I - 1] + index_nd::compute(_size, _indices); + } +}; + +template <> +class index_nd<0> { + public: + template + static SZ compute(SZ[], SZ[]) { + return 0; + } +}; + +template +struct match_dimensions {}; + +template <> +struct match_dimensions { + static void check() { + } +}; + +} // namespace detail + +// Base class for code::array. SZ is the type used for sizes (currently int32_t.) +// Overloading up to 10 dimensions (not using variadic templates to +// stay compatible with C++98.) +template +class array_base { + public: + using value_type = T; + using size_type = SZ; + + array_base() { + (void)::memset(size_, 0, sizeof(SZ) * N); + } + + array_base(T* _data, SZ const* _sz) + : data_(_data, coder::detail::numel::compute(_sz)) { + (void)std::copy(_sz, _sz + N, size_); + } + + array_base& operator=(array_base const& _other) { + data_.copy(_other.data_); + (void)std::copy(_other.size_, _other.size_ + N, size_); + return *this; + } + + template + void set(T* _data, Dims... dims) { + coder::detail::match_dimensions::check(); + data_.set(_data, coder::detail::product(dims...)); + set_size_i<0>(dims...); + } + + bool is_owner() const { + return data_.is_owner(); + } + + void set_owner(bool b) { + data_.set_owner(b); + } + + SZ capacity() const { + return data_.capacity(); + } + + private: + template + void set_size_i(First f, Rest... rest) { + size_[_i] = f; + set_size_i<_i + 1, Rest...>(rest...); + } + template + void set_size_i(Last l) { + size_[_i] = l; + } + + public: + template + void set_size(Dims... dims) { + coder::detail::match_dimensions::check(); + set_size_i<0>(dims...); + ensureCapacity(numel()); + } + + template + array_base reshape_n(SZ const (&_ns)[N1]) const { + array_base reshaped{const_cast(&data_[0]), _ns}; + return reshaped; + } + + template + array_base(sizeof...(Dims))> reshape(Dims... dims) const { + SZ const ns[]{static_cast(dims)...}; + return reshape_n(ns); + } + + T& operator[](SZ _index) { + return data_[_index]; + } + + T const& operator[](SZ _index) const { + return data_[_index]; + } + + void clear() { + data_.clear(); + } + + T* data() { + return data_; + } + + T const* data() const { + return data_; + } + + SZ const* size() const { + return &size_[0]; + } + + SZ size(SZ _index) const { + return size_[_index]; + } + + SZ numel() const { + return coder::detail::numel::compute(size_); + } + + template + SZ index(Dims... _dims) const { + coder::detail::match_dimensions::check(); + SZ const indices[]{static_cast(_dims)...}; + return coder::detail::index_nd(sizeof...(_dims))>::compute(size_, indices); + } + + template + T& at(Dims... _i) { + coder::detail::match_dimensions::check(); + return data_[index(_i...)]; + } + + template + T const& at(Dims... _i) const { + coder::detail::match_dimensions::check(); + return data_[index(_i...)]; + } + + array_iterator > begin() { + return array_iterator >(this, 0); + } + array_iterator > end() { + return array_iterator >(this, this->numel()); + } + const_array_iterator > begin() const { + return const_array_iterator >(this, 0); + } + const_array_iterator > end() const { + return const_array_iterator >(this, this->numel()); + } + + protected: + coder::detail::data_ptr data_; + SZ size_[N]; + + private: + void ensureCapacity(SZ _newNumel) { + if (_newNumel > data_.capacity()) { + SZ i{data_.capacity()}; + if (i < 16) { + i = 16; + } + + while (i < _newNumel) { + if (i > 1073741823) { + i = MAX_int32_T; + } else { + i *= 2; + } + } + data_.reserve(i); + } + data_.resize(_newNumel); + } +}; + +// The standard coder::array class with base type and number of dimensions. +template +class array : public array_base { + private: + using Base = array_base; + + public: + array() + : Base() { + } + array(array const& _other) + : Base(_other) { + } + array(Base const& _other) + : Base(_other) { + } + array(T* _data, SizeType const* _sz) + : Base(_data, _sz) { + } +}; + +// Specialize on char_T (row vector) for better support on strings. +template <> +class array : public array_base { + private: + using Base = array_base; + + public: + array() + : array_base() { + } + array(array const& _other) + : Base(_other) { + } + array(Base const& _other) + : Base(_other) { + } + + array(std::string const& _str) { + operator=(_str); + } + + array(char_T const* const _str) { + operator=(_str); + } + + array(std::vector const& _vec) { + SizeType const n{static_cast(_vec.size())}; + set_size(1, n); + data_.copy(&_vec[0], n); + } + + array& operator=(std::string const& _str) { + SizeType const n{static_cast(_str.size())}; + set_size(1, n); + data_.copy(_str.c_str(), n); + return *this; + } + + array& operator=(char_T const* const _str) { + SizeType const n{static_cast(strlen(_str))}; + set_size(1, n); + data_.copy(_str, n); + return *this; + } + + operator std::string() const { + return std::string(static_cast(&(*this)[0]), static_cast(size(1))); + } +}; + +// Specialize on 2 dimensions for better support interactions with +// std::vector and row vectors. +template +class array : public array_base { + private: + using Base = array_base; + + public: + array() + : Base() { + } + array(array const& _other) + : Base(_other) { + } + array(Base const& _other) + : Base(_other) { + } + array(std::vector const& _vec) { + operator=(_vec); + } + + array& operator=(std::vector const& _vec) { + SizeType n{static_cast(_vec.size())}; + Base::set_size(1, n); + Base::data_.copy(&_vec[0], n); + return *this; + } + + operator std::vector() const { + T const* p{&Base::data_[0]}; + return std::vector(p, p + Base::numel()); + } +}; + +// Specialize on 1 dimension for better support with std::vector and +// column vectors. +template +class array : public array_base { + private: + using Base = array_base; + + public: + array() + : Base() { + } + array(array const& _other) + : Base(_other) { + } + array(Base const& _other) + : Base(_other) { + } + array(std::vector const& _vec) { + operator=(_vec); + } + + array& operator=(std::vector const& _vec) { + SizeType n{static_cast(_vec.size())}; + Base::set_size(n); + Base::data_.copy(&_vec[0], n); + return *this; + } + + operator std::vector() const { + T const* p{&Base::data_[0]}; + return std::vector(p, p + Base::numel()); + } +}; +} // namespace coder + +#endif diff --git a/libs/getLoudness/win32/designKWeightingFilter.h b/libs/getLoudness/win32/designKWeightingFilter.h new file mode 100644 index 0000000..576784c --- /dev/null +++ b/libs/getLoudness/win32/designKWeightingFilter.h @@ -0,0 +1,30 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// designKWeightingFilter.h +// +// Code generation for function 'designKWeightingFilter' +// + +#ifndef DESIGNKWEIGHTINGFILTER_H +#define DESIGNKWEIGHTINGFILTER_H + +// Include files +#include "rtwtypes.h" +#include +#include + +// Function Declarations +namespace coder { +namespace audio { +namespace internal { +void convertToFs(float sos_48kHz[6], float Fs); + +} +} // namespace audio +} // namespace coder + +#endif +// End of code generation (designKWeightingFilter.h) diff --git a/libs/getLoudness/win32/getLoudness.h b/libs/getLoudness/win32/getLoudness.h new file mode 100644 index 0000000..4a0134a --- /dev/null +++ b/libs/getLoudness/win32/getLoudness.h @@ -0,0 +1,25 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// getLoudness.h +// +// Code generation for function 'getLoudness' +// + +#ifndef GETLOUDNESS_H +#define GETLOUDNESS_H + +// Include files +#include "rtwtypes.h" +#include "coder_array.h" +#include +#include + +// Function Declarations +extern void getLoudness(const coder::array &data, float fs, + coder::array &loudness); + +#endif +// End of code generation (getLoudness.h) diff --git a/libs/getLoudness/win32/getLoudness.lib b/libs/getLoudness/win32/getLoudness.lib new file mode 100644 index 0000000..12423fa Binary files /dev/null and b/libs/getLoudness/win32/getLoudness.lib differ diff --git a/libs/getLoudness/win32/getLoudness_d.lib b/libs/getLoudness/win32/getLoudness_d.lib new file mode 100644 index 0000000..356dae2 Binary files /dev/null and b/libs/getLoudness/win32/getLoudness_d.lib differ diff --git a/libs/getLoudness/win32/getLoudness_data.h b/libs/getLoudness/win32/getLoudness_data.h new file mode 100644 index 0000000..a3d4d72 --- /dev/null +++ b/libs/getLoudness/win32/getLoudness_data.h @@ -0,0 +1,20 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// getLoudness_data.h +// +// Code generation for function 'getLoudness_data' +// + +#ifndef GETLOUDNESS_DATA_H +#define GETLOUDNESS_DATA_H + +// Include files +#include "rtwtypes.h" +#include +#include + +#endif +// End of code generation (getLoudness_data.h) diff --git a/libs/getLoudness/win32/getLoudness_initialize.h b/libs/getLoudness/win32/getLoudness_initialize.h new file mode 100644 index 0000000..23ef5c6 --- /dev/null +++ b/libs/getLoudness/win32/getLoudness_initialize.h @@ -0,0 +1,23 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// getLoudness_initialize.h +// +// Code generation for function 'getLoudness_initialize' +// + +#ifndef GETLOUDNESS_INITIALIZE_H +#define GETLOUDNESS_INITIALIZE_H + +// Include files +#include "rtwtypes.h" +#include +#include + +// Function Declarations +extern void getLoudness_initialize(); + +#endif +// End of code generation (getLoudness_initialize.h) diff --git a/libs/getLoudness/win32/getLoudness_terminate.h b/libs/getLoudness/win32/getLoudness_terminate.h new file mode 100644 index 0000000..1ccf69a --- /dev/null +++ b/libs/getLoudness/win32/getLoudness_terminate.h @@ -0,0 +1,23 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// getLoudness_terminate.h +// +// Code generation for function 'getLoudness_terminate' +// + +#ifndef GETLOUDNESS_TERMINATE_H +#define GETLOUDNESS_TERMINATE_H + +// Include files +#include "rtwtypes.h" +#include +#include + +// Function Declarations +extern void getLoudness_terminate(); + +#endif +// End of code generation (getLoudness_terminate.h) diff --git a/libs/getLoudness/win32/getLoudness_types.h b/libs/getLoudness/win32/getLoudness_types.h new file mode 100644 index 0000000..2c345d0 --- /dev/null +++ b/libs/getLoudness/win32/getLoudness_types.h @@ -0,0 +1,18 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// getLoudness_types.h +// +// Code generation for function 'getLoudness' +// + +#ifndef GETLOUDNESS_TYPES_H +#define GETLOUDNESS_TYPES_H + +// Include files +#include "rtwtypes.h" + +#endif +// End of code generation (getLoudness_types.h) diff --git a/libs/getLoudness/win32/rtGetInf.h b/libs/getLoudness/win32/rtGetInf.h new file mode 100644 index 0000000..c1e30db --- /dev/null +++ b/libs/getLoudness/win32/rtGetInf.h @@ -0,0 +1,30 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// rtGetInf.h +// +// Code generation for function 'getLoudness' +// + +#ifndef RTGETINF_H +#define RTGETINF_H + +// Include files +#include "rtwtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern real_T rtGetInf(void); +extern real32_T rtGetInfF(void); +extern real_T rtGetMinusInf(void); +extern real32_T rtGetMinusInfF(void); + +#ifdef __cplusplus +} +#endif +#endif +// End of code generation (rtGetInf.h) diff --git a/libs/getLoudness/win32/rtGetNaN.h b/libs/getLoudness/win32/rtGetNaN.h new file mode 100644 index 0000000..32a87ef --- /dev/null +++ b/libs/getLoudness/win32/rtGetNaN.h @@ -0,0 +1,28 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// rtGetNaN.h +// +// Code generation for function 'getLoudness' +// + +#ifndef RTGETNAN_H +#define RTGETNAN_H + +// Include files +#include "rtwtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern real_T rtGetNaN(void); +extern real32_T rtGetNaNF(void); + +#ifdef __cplusplus +} +#endif +#endif +// End of code generation (rtGetNaN.h) diff --git a/libs/getLoudness/win32/rt_nonfinite.h b/libs/getLoudness/win32/rt_nonfinite.h new file mode 100644 index 0000000..1339d50 --- /dev/null +++ b/libs/getLoudness/win32/rt_nonfinite.h @@ -0,0 +1,32 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// rt_nonfinite.h +// +// Code generation for function 'getLoudness' +// + +#ifndef RT_NONFINITE_H +#define RT_NONFINITE_H + +// Include files +#include "rtwtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern real_T rtInf; +extern real_T rtMinusInf; +extern real_T rtNaN; +extern real32_T rtInfF; +extern real32_T rtMinusInfF; +extern real32_T rtNaNF; + +#ifdef __cplusplus +} +#endif +#endif +// End of code generation (rt_nonfinite.h) diff --git a/libs/getLoudness/win32/rtwtypes.h b/libs/getLoudness/win32/rtwtypes.h new file mode 100644 index 0000000..43403ce --- /dev/null +++ b/libs/getLoudness/win32/rtwtypes.h @@ -0,0 +1,44 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// rtwtypes.h +// +// Code generation for function 'getLoudness' +// + +#ifndef RTWTYPES_H +#define RTWTYPES_H + +/*=======================================================================* + * Fixed width word size data types: * + * int64_T - signed 64 bit integers * + * uint64_T - unsigned 64 bit integers * + *=======================================================================*/ + +#if defined(__APPLE__) +#ifndef INT64_T +#define INT64_T long +#define FMT64 "l" +#if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG) +#define INT_TYPE_64_IS_LONG +#endif +#endif +#endif + +#if defined(__APPLE__) +#ifndef UINT64_T +#define UINT64_T unsigned long +#define FMT64 "l" +#if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG) +#define INT_TYPE_64_IS_LONG +#endif +#endif +#endif + +// Include files +#include "tmwtypes.h" + +#endif +// End of code generation (rtwtypes.h) diff --git a/libs/getLoudness/win32/sum.h b/libs/getLoudness/win32/sum.h new file mode 100644 index 0000000..fc13f94 --- /dev/null +++ b/libs/getLoudness/win32/sum.h @@ -0,0 +1,27 @@ +// +// Academic License - for use in teaching, academic research, and meeting +// course requirements at degree granting institutions only. Not for +// government, commercial, or other organizational use. +// +// sum.h +// +// Code generation for function 'sum' +// + +#ifndef SUM_H +#define SUM_H + +// Include files +#include "rtwtypes.h" +#include "coder_array.h" +#include +#include + +// Function Declarations +namespace coder { +void sum(const ::coder::array &x, float y_data[], int y_size[2]); + +} + +#endif +// End of code generation (sum.h) diff --git a/libs/getLoudness/win32/tmwtypes.h b/libs/getLoudness/win32/tmwtypes.h new file mode 100644 index 0000000..1810743 --- /dev/null +++ b/libs/getLoudness/win32/tmwtypes.h @@ -0,0 +1,886 @@ +/* + * Copyright 1984-2018 The MathWorks, Inc. + */ + +#if defined(_MSC_VER) +# pragma once +#endif +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) +# pragma once +#endif + +#ifndef tmwtypes_h +#define tmwtypes_h + +#ifndef __TMWTYPES__ +#define __TMWTYPES__ +/* + * File : tmwtypes.h + * Abstract: + * Data types for use with MATLAB/SIMULINK and the Real-Time Workshop. + * + * When compiling stand-alone model code, data types can be overridden + * via compiler switches. + * + * Define NO_FLOATS to eliminate reference to real_T, etc. + */ + +#ifdef MW_LIBTOOLING +#include "mwstdint.h" +#endif + +#include + +/* __STDC_VERSION__ version check below means "check for a C99 compiler". + + Visual Studio (checked on versions 2015 and 2017) does + not define __STDC_VERSION__, however it has stdbool.h available, + thus a separate check for _MSC_VER below. + */ +#if defined(__APPLE_CC__) \ + || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) \ + || (defined(_MSC_VER) && (_MSC_VER >= 1900)) +#ifndef tmwtypes_do_not_include_stdbool +#include +#endif +#endif + +#define LOGICAL_IS_A_TYPE +#define SPARSE_GENERALIZATION + +#ifdef NO_FLOATS +# define double double_not_allowed +# define float float_not_allowed +#endif /*NO_FLOATS*/ + +#ifndef NO_FLOATS + +#ifndef __MWERKS__ +# ifdef __STDC__ +# include +# else +# ifndef FLT_MANT_DIG +# define FLT_MANT_DIG 24 +# endif +# ifndef DBL_MANT_DIG +# define DBL_MANT_DIG 53 +# endif +# endif +#endif + +#endif /*NO_FLOATS*/ + +/* + * The following data types cannot be overridden when building MEX files. + */ +#ifdef MATLAB_MEX_FILE +# undef CHARACTER_T +# undef INTEGER_T +# undef BOOLEAN_T +# undef REAL_T +# undef TIME_T +#endif + +/* + * The uchar_T, ushort_T and ulong_T types are needed for compilers which do + * not allow defines to be specified, at the command line, with spaces in them. + */ + +typedef unsigned char uchar_T; +typedef unsigned short ushort_T; +typedef unsigned long ulong_T; + +#if (defined(_MSC_VER) && _MSC_VER >= 1500) \ + || defined(__x86_64__) || defined(__LP64__) \ + || defined(__LCC64__) + +typedef unsigned long long ulonglong_T; +#endif + + + +/*=======================================================================* + * Fixed width word size data types: * + * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers * + * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers * + * real32_T, real64_T - 32 and 64 bit floating point numbers * + *=======================================================================*/ + +/* When used with Real Time Workshop generated code, this + * header file can be used with a variety of compilers. + * + * The compiler could be for an 8 bit embedded processor that + * only had 8 bits per integer and 16 bits per long. + * In that example, a 32 bit integer size is not even available. + * This header file should be robust to that. + * + * For the case of an 8 bit processor, the preprocessor + * may be limited to 16 bit math like its target. That limitation + * would mean that 32 bit comparisons can't be done accurately. + * To increase robustness to this, comparisons are done against + * smaller values first. An inaccurate 32 bit comparison isn't + * attempted if the 16 bit comparison has already succeeded. + * + * Limitations on preprocessor math can also be stricter than + * for the target. There are known cases where a compiler + * targeting processors with 64 bit longs can't do accurate + * preprocessor comparisons on more than 32 bits. + */ + +/* Determine the number of bits for int, long, short, and char. + * If one fails to be determined, set the number of bits to -1 + */ + +#ifndef TMW_BITS_PER_INT +# if INT_MAX == 0x7FL +# define TMW_BITS_PER_INT 8 +# elif INT_MAX == 0x7FFFL +# define TMW_BITS_PER_INT 16 +# elif INT_MAX == 0x7FFFFFFFL +# define TMW_BITS_PER_INT 32 +# else +# define TMW_BITS_PER_INT -1 +# endif +#endif + +#ifndef TMW_BITS_PER_LONG +# if LONG_MAX == 0x7FL +# define TMW_BITS_PER_LONG 8 +# elif LONG_MAX == 0x7FFFL +# define TMW_BITS_PER_LONG 16 +# elif LONG_MAX == 0x7FFFFFFFL +# define TMW_BITS_PER_LONG 32 +# else +# define TMW_BITS_PER_LONG -1 +# endif +#endif + +#ifndef TMW_BITS_PER_SHRT +# if SHRT_MAX == 0x7FL +# define TMW_BITS_PER_SHRT 8 +# elif SHRT_MAX == 0x7FFFL +# define TMW_BITS_PER_SHRT 16 +# elif SHRT_MAX == 0x7FFFFFFFL +# define TMW_BITS_PER_SHRT 32 +# else +# define TMW_BITS_PER_SHRT -1 +# endif +#endif + +#ifndef TMW_BITS_PER_SCHAR +# if SCHAR_MAX == 0x7FL +# define TMW_BITS_PER_SCHAR 8 +# elif SCHAR_MAX == 0x7FFFL +# define TMW_BITS_PER_SCHAR 16 +# elif SCHAR_MAX == 0x7FFFFFFFL +# define TMW_BITS_PER_SCHAR 32 +# else +# define TMW_BITS_PER_SCHAR -1 +# endif +#endif + +#ifndef TMW_CHAR_SIGNED +# if SCHAR_MAX == CHAR_MAX +# define TMW_CHAR_SIGNED 1 +# else +# define TMW_CHAR_SIGNED 0 +# endif +#endif + +/* It is common for one or more of the integer types + * to be the same size. For example, on many embedded + * processors, both shorts and ints are 16 bits. On + * processors used for workstations, it is quite common + * for both int and long to be 32 bits. + * When there is more than one choice for typdef'ing + * a portable type like int16_T or uint32_T, in + * concept, it should not matter which choice is made. + * However, some style guides and some code checking + * tools do identify and complain about seemingly + * irrelevant differences. For example, a code + * checking tool may complain about an implicit + * conversion from int to short even though both + * are 16 bits. To reduce these types of + * complaints, it is best to make int the + * preferred choice when more than one is available. + */ + +#ifndef INT8_T +# if defined(MW_LIBTOOLING) +# define INT8_T int8_t +# elif TMW_BITS_PER_INT == 8 +# define INT8_T int +# elif TMW_BITS_PER_LONG == 8 +# define INT8_T long +# elif TMW_BITS_PER_SCHAR == 8 +# define INT8_T signed char +# elif TMW_BITS_PER_SHRT == 8 +# define INT8_T short +# endif +#endif +#ifdef INT8_T + typedef INT8_T int8_T; +#endif + +#ifndef UINT8_T +# if defined(MW_LIBTOOLING) +# define UINT8_T uint8_t +# elif TMW_BITS_PER_INT == 8 +# define UINT8_T unsigned int +# elif TMW_BITS_PER_LONG == 8 +# define UINT8_T unsigned long +# elif TMW_BITS_PER_SCHAR == 8 +# define UINT8_T unsigned char +# elif TMW_BITS_PER_SHRT == 8 +# define UINT8_T unsigned short +# endif +#endif +#ifdef UINT8_T + typedef UINT8_T uint8_T; +#endif + + +#ifndef INT16_T +# if defined(MW_LIBTOOLING) +# define INT16_T int16_t +# elif TMW_BITS_PER_INT == 16 +# define INT16_T int +# elif TMW_BITS_PER_LONG == 16 +# define INT16_T long +# elif TMW_BITS_PER_SCHAR == 16 +# define INT16_T signed char +# elif TMW_BITS_PER_SHRT == 16 +# define INT16_T short +# endif +#endif +#ifdef INT16_T + typedef INT16_T int16_T; +#endif + + +#ifndef UINT16_T +# if defined(MW_LIBTOOLING) +# define UINT16_T uint16_t +# elif TMW_BITS_PER_INT == 16 +# define UINT16_T unsigned int +# elif TMW_BITS_PER_LONG == 16 +# define UINT16_T unsigned long +# elif TMW_BITS_PER_SCHAR == 16 +# define UINT16_T unsigned char +# elif TMW_BITS_PER_SHRT == 16 +# define UINT16_T unsigned short +# endif +#endif +#ifdef UINT16_T + typedef UINT16_T uint16_T; +#endif + + +#ifndef INT32_T +# if defined(MW_LIBTOOLING) +# define INT32_T int32_t +# elif TMW_BITS_PER_INT == 32 +# define INT32_T int +# elif TMW_BITS_PER_LONG == 32 +# define INT32_T long +# elif TMW_BITS_PER_SCHAR == 32 +# define INT32_T signed char +# elif TMW_BITS_PER_SHRT == 32 +# define INT32_T short +# endif +#endif +#ifdef INT32_T + typedef INT32_T int32_T; +#endif + + +#ifndef UINT32_T +# if defined(MW_LIBTOOLING) +# define UINT32_T uint32_t +# elif TMW_BITS_PER_INT == 32 +# define UINT32_T unsigned int +# elif TMW_BITS_PER_LONG == 32 +# define UINT32_T unsigned long +# elif TMW_BITS_PER_SCHAR == 32 +# define UINT32_T unsigned char +# elif TMW_BITS_PER_SHRT == 32 +# define UINT32_T unsigned short +# endif +#endif +#ifdef UINT32_T + typedef UINT32_T uint32_T; +#endif + +/* The following is used to emulate smaller integer types when only + * larger types are available. For example, compilers for TI C3x/C4x DSPs + * define char and short to be 32 bits, so 8 and 16 bits are not directly + * available. This target is commonly used with RTW rapid prototyping. + * Other DSPs define char to be 16 bits, so 8 bits is not directly + * available. + */ +#ifndef INT8_T +# ifdef INT16_T +# define INT8_T INT16_T + typedef INT8_T int8_T; +# else +# ifdef INT32_T +# define INT8_T INT32_T + typedef INT8_T int8_T; +# endif +# endif +#endif + +#ifndef UINT8_T +# ifdef UINT16_T +# define UINT8_T UINT16_T + typedef UINT8_T uint8_T; +# else +# ifdef UINT32_T +# define UINT8_T UINT32_T + typedef UINT8_T uint8_T; +# endif +# endif +#endif + +#ifndef INT16_T +# ifdef INT32_T +# define INT16_T INT32_T + typedef INT16_T int16_T; +# endif +#endif + +#ifndef UINT16_T +# ifdef UINT32_T +# define UINT16_T UINT32_T + typedef UINT16_T uint16_T; +# endif +#endif + + +#ifndef NO_FLOATS + +#ifndef REAL32_T +# ifndef __MWERKS__ +# if FLT_MANT_DIG >= 23 +# define REAL32_T float +# endif +# else +# define REAL32_T float +# endif +#endif +#ifdef REAL32_T + typedef REAL32_T real32_T; +#endif + + +#ifndef REAL64_T +# ifndef __MWERKS__ +# if DBL_MANT_DIG >= 52 +# define REAL64_T double +# endif +# else +# define REAL64_T double +# endif +#endif +#ifdef REAL64_T + typedef REAL64_T real64_T; +#endif + +#endif /* NO_FLOATS*/ + +/*=======================================================================* + * Fixed width word size data types: * + * int64_T - signed 64 bit integers * + * uint64_T - unsigned 64 bit integers * + *=======================================================================*/ + +# if defined(MW_LIBTOOLING) +# ifdef INT64_T +# undef INT64_T +# endif +# define INT64_T int64_t +# ifdef UINT64_T +# undef UINT64_T +# endif +# define UINT64_T uint64_t +# endif +#if !defined(INT64_T) || !defined(UINT64_T) || !defined(FMT64) +# if defined(__APPLE__) || defined(__clang__) +# ifndef INT64_T +# define INT64_T long long +# endif +# ifndef UINT64_T +# define UINT64_T unsigned long long +# endif +# ifndef FMT64 +# define FMT64 "ll" +# endif +# if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG) +# define INT_TYPE_64_IS_LONG +# endif +# elif (defined(__x86_64__) || defined(__LP64__))&& !defined(__MINGW64__) +# ifndef INT64_T +# define INT64_T long +# endif +# ifndef UINT64_T +# define UINT64_T unsigned long +# endif +# ifndef FMT64 +# define FMT64 "l" +# endif +# if !defined(INT_TYPE_64_IS_LONG) +# define INT_TYPE_64_IS_LONG +# endif +# elif defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \ + || (defined(__WATCOMC__) && __WATCOMC__ >= 1100) +# ifndef INT64_T +# define INT64_T __int64 +# endif +# ifndef UINT64_T +# define UINT64_T unsigned __int64 +# endif +# ifndef FMT64 +# define FMT64 "I64" +# endif +# elif defined(__GNUC__) || defined(TMW_ENABLE_INT64) \ + || defined(__LCC64__) +# ifndef INT64_T +# define INT64_T long long +# endif +# ifndef UINT64_T +# define UINT64_T unsigned long long +# endif +# ifndef FMT64 +# define FMT64 "ll" +# endif +# endif + +#endif + +#if defined(INT64_T) +# if defined(__GNUC__) && \ + ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9))) + __extension__ +# endif + typedef INT64_T int64_T; +#endif + +#if defined(_WIN64) || (defined(__APPLE__) && defined(__LP64__)) \ + || defined(__x86_64__) \ + || defined(__LP64__) +# define INT_TYPE_64_IS_SUPPORTED +#endif + +#if defined(UINT64_T) +# if defined(__GNUC__) && \ + ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9))) + __extension__ +# endif + typedef UINT64_T uint64_T; +#endif + +/*===========================================================================* + * Format string modifiers for using size_t variables in printf statements. * + *===========================================================================*/ + +#ifndef FMT_SIZE_T +# if (defined( __GNUC__ ) || defined(_STDC_C99))&& !defined(__MINGW64__) +# define FMT_SIZE_T "z" +# elif defined (__WATCOMC__) +# define FMT_SIZE_T "l" +# elif defined (_WIN32 ) +# define FMT_SIZE_T "I" +# else +# define FMT_SIZE_T "l" +# endif +#endif + +#ifndef FMT_PTRDIFF_T +# if defined(__APPLE__) +# define FMT_PTRDIFF_T "l" +# elif defined( __GNUC__ ) || defined(_STDC_C99) +# define FMT_PTRDIFF_T "t" +# elif defined (__WATCOMC__) +# define FMT_PTRDIFF_T "l" +# elif defined (_WIN32 ) +# define FMT_PTRDIFF_T "I" +# else +# define FMT_PTRDIFF_T "l" +# endif +#endif + +/*===========================================================================* + * General or logical data types where the word size is not guaranteed. * + * real_T - possible settings include real32_T or real64_T * + * time_T - possible settings include real32_T or real64_T * + * boolean_T * + * char_T * + * int_T * + * uint_T * + * byte_T * + *===========================================================================*/ + +#ifndef NO_FLOATS + +#ifndef REAL_T +# ifdef REAL64_T +# define REAL_T real64_T +# else +# ifdef REAL32_T +# define REAL_T real32_T +# endif +# endif +#endif +#ifdef REAL_T + typedef REAL_T real_T; +#endif + +#ifndef TIME_T +# ifdef REAL_T +# define TIME_T real_T +# endif +#endif +#ifdef TIME_T + typedef TIME_T time_T; +#endif + +#endif /* NO_FLOATS */ + +#ifndef BOOLEAN_T +# if defined(UINT8_T) +# define BOOLEAN_T UINT8_T +# else +# define BOOLEAN_T unsigned int +# endif +#endif +typedef BOOLEAN_T boolean_T; + + +#ifndef CHARACTER_T +# define CHARACTER_T char +#endif +typedef CHARACTER_T char_T; + + +#ifndef INTEGER_T +# define INTEGER_T int +#endif +typedef INTEGER_T int_T; + + +#ifndef UINTEGER_T +# define UINTEGER_T unsigned +#endif +typedef UINTEGER_T uint_T; + + +#ifndef BYTE_T +# define BYTE_T unsigned char +#endif +typedef BYTE_T byte_T; + + +/*===========================================================================* + * Define Complex Structures * + *===========================================================================*/ +#ifndef NO_FLOATS + +#ifndef CREAL32_T +# ifdef REAL32_T + typedef struct { + real32_T re, im; + } creal32_T; +# define CREAL32_T creal32_T +# endif +#endif + +#ifndef CREAL64_T +# ifdef REAL64_T + typedef struct { + real64_T re, im; + } creal64_T; +# define CREAL64_T creal64_T +# endif +#endif + +#ifndef CREAL_T +# ifdef REAL_T + typedef struct { + real_T re, im; + } creal_T; +# define CREAL_T creal_T +# endif +#endif + +#endif /* NO_FLOATS */ + +#ifndef CINT8_T +# ifdef INT8_T + typedef struct { + int8_T re, im; + } cint8_T; +# define CINT8_T cint8_T +# endif +#endif + +#ifndef CUINT8_T +# ifdef UINT8_T + typedef struct { + uint8_T re, im; + } cuint8_T; +# define CUINT8_T cuint8_T +# endif +#endif + +#ifndef CINT16_T +# ifdef INT16_T + typedef struct { + int16_T re, im; + } cint16_T; +# define CINT16_T cint16_T +# endif +#endif + +#ifndef CUINT16_T +# ifdef UINT16_T + typedef struct { + uint16_T re, im; + } cuint16_T; +# define CUINT16_T cuint16_T +# endif +#endif + +#ifndef CINT32_T +# ifdef INT32_T + typedef struct { + int32_T re, im; + } cint32_T; +# define CINT32_T cint32_T +# endif +#endif + +#ifndef CUINT32_T +# ifdef UINT32_T + typedef struct { + uint32_T re, im; + } cuint32_T; +# define CUINT32_T cuint32_T +# endif +#endif + +#ifndef CINT64_T +# ifdef INT64_T + typedef struct { + int64_T re, im; + } cint64_T; +# define CINT64_T cint64_T +# endif +#endif + +#ifndef CUINT64_T +# ifdef UINT64_T + typedef struct { + uint64_T re, im; + } cuint64_T; +# define CUINT64_T cuint64_T +# endif +#endif + +/*=======================================================================* + * Min and Max: * + * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers * + * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers * + *=======================================================================*/ + +#define MAX_int8_T ((int8_T)(127)) /* 127 */ +#define MIN_int8_T ((int8_T)(-128)) /* -128 */ +#define MAX_uint8_T ((uint8_T)(255)) /* 255 */ +#define MIN_uint8_T ((uint8_T)(0)) + +#define MAX_int16_T ((int16_T)(32767)) /* 32767 */ +#define MIN_int16_T ((int16_T)(-32768)) /* -32768 */ +#define MAX_uint16_T ((uint16_T)(65535)) /* 65535 */ +#define MIN_uint16_T ((uint16_T)(0)) + +#define MAX_int32_T ((int32_T)(2147483647)) /* 2147483647 */ +#define MIN_int32_T ((int32_T)(-2147483647-1)) /* -2147483648 */ +#define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU)) /* 4294967295 */ +#define MIN_uint32_T ((uint32_T)(0)) + +#if defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \ + || (defined(__WATCOMC__) && __WATCOMC__ >= 1100) \ + || defined(__LCC64__) +# ifdef INT64_T +# define MAX_int64_T ((int64_T)(9223372036854775807LL)) +# define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL)) +# endif +# ifdef UINT64_T +# define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL)) +# define MIN_uint64_T ((uint64_T)(0)) +# endif +#else +# ifdef INT64_T +# ifdef INT_TYPE_64_IS_LONG +# define MAX_int64_T ((int64_T)(9223372036854775807L)) +# define MIN_int64_T ((int64_T)(-9223372036854775807L-1L)) +# else +# define MAX_int64_T ((int64_T)(9223372036854775807LL)) +# define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL)) +# endif +# endif +# ifdef UINT64_T +# ifdef INT_TYPE_64_IS_LONG +# define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFUL)) +# define MIN_uint64_T ((uint64_T)(0)) +# else +# define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL)) +# define MIN_uint64_T ((uint64_T)(0)) +# endif +# endif +#endif + +#if (defined(_MSC_VER) && !defined(__clang__)) + +/* Conversion from unsigned __int64 to double is not implemented in Visual Studio + * and results in a compile error, thus the value must first be cast to + * signed __int64, and then to double. + * + * If the 64 bit int value is greater than 2^63-1, which is the signed int64 max, + * the macro below provides a workaround for casting a uint64 value to a double + * in windows. + */ +# define uint64_to_double(u) ( ((u) > _I64_MAX) ? \ + (double)(__int64)((u) - _I64_MAX - 1) + (double)_I64_MAX + 1: \ + (double)(__int64)(u) ) + +/* The following inline function should only be used in the macro double_to_uint64, + * as it only handles the specfic range of double between 2^63 and 2^64-1 */ +__forceinline +uint64_T double_to_uint64_helper(double d) { + union double_to_uint64_union_type { + double dd; + uint64_T i64; + } di; + di.dd = d; + return (((di.i64 & 0x000fffffffffffff) | 0x0010000000000000) << 11); +} + +/* The largest double value that can be cast to uint64 in windows is the + * signed int64 max, which is 2^63-1. The macro below provides + * a workaround for casting large double values to uint64 in windows. + */ +/* The magic number 18446744073709551616.0 is 2^64 */ +/* The magic number 9223372036854775808.0 is 2^63 */ +# define double_to_uint64(d) ( ((d) >= 18446744073709551616.0) ? \ + 0xffffffffffffffffULL : \ + ((d) >= 0.0) ? \ + ((d) >= 9223372036854775808.0) ? \ + double_to_uint64_helper(d) : \ + (unsigned __int64)(d) : \ + 0ULL ) +#else +# define uint64_to_double(u) ((double)(u)) +# if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__TICCSC__) +/* double_to_uint64 defined only for MSVC and UNIX */ +# else +# define double_to_uint64(d) ( ((d) >= 18446744073709551616.0) ? \ + (unsigned long long) 0xffffffffffffffffULL : \ + ((d) >= 0) ? (unsigned long long)(d) : (unsigned long long) 0 ) +# endif +#endif + +#if !defined(__cplusplus) && !defined(__bool_true_false_are_defined) + +#ifndef _bool_T +#define _bool_T + +typedef boolean_T bool; + +#ifndef false +#define false (0) +#endif +#ifndef true +#define true (1) +#endif + +#endif /* _bool_T */ + +#endif /* !__cplusplus */ + +/* + * This software assumes that the code is being compiled on a target using a + * 2's complement representation for signed integer values. + */ +#if ((SCHAR_MIN + 1) != -SCHAR_MAX) +#error "This code must be compiled using a 2's complement representation for signed integer values" +#endif + +/* + * Maximum length of a MATLAB identifier (function/variable/model) + * including the null-termination character. + */ +#define TMW_NAME_LENGTH_MAX 64 + +/* + * Maximum values for indices and dimensions + */ +#include + +#ifdef MX_COMPAT_32 +typedef int mwSize; +typedef int mwIndex; +typedef int mwSignedIndex; +#else +typedef size_t mwSize; /* unsigned pointer-width integer */ +typedef size_t mwIndex; /* unsigned pointer-width integer */ +typedef ptrdiff_t mwSignedIndex; /* a signed pointer-width integer */ +#endif + + /* for the individual dim */ +#ifndef SLSIZE_SLINDEX + #define SLSIZE_SLINDEX + #ifdef INT_TYPE_64_IS_SUPPORTED + typedef int64_T SLIndex; + typedef int64_T SLSize; + #else + typedef int SLIndex; + typedef int SLSize; + #endif +#endif + +/* for the total size */ +#define SLIndexType size_t +#define INVALID_SIZET_VALUE (std::numeric_limits::max()) +#define MAX_VALID_SIZET_VALUE (std::numeric_limits::max() -1) + + +#if (defined(_LP64) || defined(_WIN64)) && !defined(MX_COMPAT_32) +/* Currently 2^48 based on hardware limitations */ +# define MWSIZE_MAX 281474976710655UL +# define MWINDEX_MAX 281474976710655UL +# define MWSINDEX_MAX 281474976710655L +# define MWSINDEX_MIN -281474976710655L +#else +# define MWSIZE_MAX 2147483647UL +# define MWINDEX_MAX 2147483647UL +# define MWSINDEX_MAX 2147483647L +# define MWSINDEX_MIN -2147483647L +#endif +#define MWSIZE_MIN 0UL +#define MWINDEX_MIN 0UL + +/** UTF-16 character type */ + +#if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT) +typedef char16_t CHAR16_T; +#define U16_STRING_LITERAL_PREFIX u +#elif defined(_MSC_VER) +typedef wchar_t CHAR16_T; +#define U16_STRING_LITERAL_PREFIX L +#else +typedef UINT16_T CHAR16_T; +#endif + +#endif /* __TMWTYPES__ */ + +#endif /* tmwtypes_h */ diff --git a/libs/libnyquist/lib-win32/libnyquist.lib b/libs/libnyquist/lib-win32/libnyquist.lib new file mode 100644 index 0000000..53b7fd9 Binary files /dev/null and b/libs/libnyquist/lib-win32/libnyquist.lib differ diff --git a/libs/libnyquist/lib-win32/libnyquist_d.lib b/libs/libnyquist/lib-win32/libnyquist_d.lib new file mode 100644 index 0000000..bdb9235 Binary files /dev/null and b/libs/libnyquist/lib-win32/libnyquist_d.lib differ diff --git a/libs/libnyquist/lib-win32/libwavpack.lib b/libs/libnyquist/lib-win32/libwavpack.lib new file mode 100644 index 0000000..7777a51 Binary files /dev/null and b/libs/libnyquist/lib-win32/libwavpack.lib differ diff --git a/libs/libnyquist/lib-win32/libwavpack_d.lib b/libs/libnyquist/lib-win32/libwavpack_d.lib new file mode 100644 index 0000000..9de0b0f Binary files /dev/null and b/libs/libnyquist/lib-win32/libwavpack_d.lib differ diff --git a/source/PA_Calculator.pro b/source/PA_Calculator.pro index ea4aac2..1bf4c12 100644 --- a/source/PA_Calculator.pro +++ b/source/PA_Calculator.pro @@ -76,29 +76,32 @@ DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\" \ APP_COPYRIGHT=\"\\\"$${QMAKE_TARGET_COPYRIGHT}\\\"\" # Library Libnyquist - -macx: LIBS += -L$$PWD/../libs/libnyquist/lib-macx/ -llibnyquist - INCLUDEPATH += $$PWD/../libs/libnyquist/include DEPENDPATH += $$PWD/../libs/libnyquist/include +macx: LIBS += -L$$PWD/../libs/libnyquist/lib-macx/ -llibnyquist macx: PRE_TARGETDEPS += $$PWD/../libs/libnyquist/lib-macx/liblibnyquist.a +win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../libs/libnyquist/lib-win32/ -llibnyquist +else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../libs/libnyquist/lib-win32/ -llibnyquist_d + macx: LIBS += -L$$PWD/../libs/libnyquist/lib-macx/ -llibwavpack - -INCLUDEPATH += $$PWD/../libs/libnyquist/include -DEPENDPATH += $$PWD/../libs/libnyquist/include - macx: PRE_TARGETDEPS += $$PWD/../libs/libnyquist/lib-macx/liblibwavpack.a +win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../libs/libnyquist/lib-win32/ -llibwavpack +else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../libs/libnyquist/lib-win32/ -llibwavpack_d + # Library getLoudness - -macx: LIBS += -L$$PWD/../libs/getLoudness/macx/ -lgetLoudness - macx: INCLUDEPATH += $$PWD/../libs/getLoudness/macx macx: DEPENDPATH += $$PWD/../libs/getLoudness/macx +macx: LIBS += -L$$PWD/../libs/getLoudness/macx/ -lgetLoudness macx: PRE_TARGETDEPS += $$PWD/../libs/getLoudness/macx/libgetLoudness.a +win32: INCLUDEPATH += $$PWD/../libs/getLoudness/win32/ +win32: DEPENDPATH += $$PWD/../libs/getLoudness/win32/ + +win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../libs/getLoudness/win32/ -lgetLoudness +else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../libs/getLoudness/win32/ -lgetLoudness_d diff --git a/source/csong.cpp b/source/csong.cpp index c76c1b5..3349ceb 100644 --- a/source/csong.cpp +++ b/source/csong.cpp @@ -6,6 +6,8 @@ #include "rt_nonfinite.h" #include "coder_array.h" #include + + csong::csong() { m_path=""; @@ -32,50 +34,97 @@ void csong::analyze(float preferedLoudness) using namespace nqr; NyquistIO loader; + try { + std::shared_ptr fileData = std::make_shared(); - std::shared_ptr fileData = std::make_shared(); - auto memory= ReadFile(m_path.toStdString()); - QFileInfo fi(m_path); - loader.Load(fileData.get(),fi.suffix().toStdString(),memory.buffer); +#ifdef Q_OS_WIN + FILE * audioFile = fopen(m_path.toLatin1().constData(), "rb"); - - coder::array loudness; - loudness.set_size(1,1); - coder::array data; - data.set_size(fileData->samples.size()/2,fileData->channelCount); - for (int idx0{0}; idx0 < data.size(0); idx0++) { - for (int idx1{0}; idx1 < data.size(1); idx1++) { - data[idx0 + data.size(0) * idx1] = fileData->samples[idx1+data.size(1)*idx0]; + if (!audioFile) + { + throw std::runtime_error("file not found"); } - } - getLoudness(data,fileData->sampleRate,loudness); - getLoudness_terminate(); - m_loudness=loudness[0]; - m_widgetItem[1].setText(QString::number(m_loudness)); + fseek(audioFile, 0, SEEK_END); + size_t lengthInBytes = ftell(audioFile); + fseek(audioFile, 0, SEEK_SET); - m_peakLevel=0; - for (unsigned int i=0;isamples.size();i++){ - if (abs(fileData->samples[i])>m_peakLevel){ - m_peakLevel=abs(fileData->samples[i]); + // Allocate temporary buffer + std::vector fileBuffer(lengthInBytes); + + size_t elementsRead = fread(fileBuffer.data(), 1, lengthInBytes, audioFile); + + if (elementsRead == 0 || fileBuffer.size() < 64) + { + throw std::runtime_error("error reading file or file too small"); } - } - m_peakLevel=linToDb(m_peakLevel); - if (m_peakLevel>0){ + + NyquistFileBuffer tempdata = {std::move(fileBuffer), elementsRead}; + + fclose(audioFile); + + auto memory=tempdata; +#else + auto memory= ReadFile(m_path.toStdString()); +#endif + + QFileInfo fi(m_path); + loader.Load(fileData.get(),fi.suffix().toStdString(),memory.buffer); + + coder::array loudness; + loudness.set_size(1,1); + coder::array data; + data.set_size(fileData->samples.size()/2,fileData->channelCount); + for (int idx0{0}; idx0 < data.size(0); idx0++) { + for (int idx1{0}; idx1 < data.size(1); idx1++) { + data[idx0 + data.size(0) * idx1] = fileData->samples[idx1+data.size(1)*idx0]; + } + } + getLoudness(data,fileData->sampleRate,loudness); + //getLoudness_terminate(); + m_loudness=loudness[0]; + m_widgetItem[1].setData(Qt::EditRole,QVariant(m_loudness)); + + m_peakLevel=0; - } - m_widgetItem[2].setText(QString::number(m_peakLevel)); + for (unsigned int i=0;isamples.size();i++){ + if (abs(fileData->samples[i])>m_peakLevel){ + m_peakLevel=abs(fileData->samples[i]); + } + } + m_peakLevel=linToDb(m_peakLevel); + if (m_peakLevel>0){ + m_peakLevel=0; + } + m_widgetItem[2].setData(Qt::EditRole,QVariant(m_peakLevel)); - m_correction=preferedLoudness-m_loudness; - m_widgetItem[4].setText(QString::number(m_correction)); + m_correction=preferedLoudness-m_loudness; + m_widgetItem[4].setData(Qt::EditRole,QVariant(m_correction)); - m_correctedPeakLevel=m_peakLevel+m_correction; - m_widgetItem[3].setText(QString::number(m_correctedPeakLevel)); - if (m_correctedPeakLevel>0){ - m_widgetItem[3].setBackground(Qt::red); - }else { - m_widgetItem[3].setBackground(Qt::white); + m_correctedPeakLevel=m_peakLevel+m_correction; + m_widgetItem[3].setData(Qt::EditRole,QVariant(m_correctedPeakLevel)); + if (m_correctedPeakLevel>0){ + m_widgetItem[3].setBackground(Qt::red); + }else { + m_widgetItem[3].setBackground(QBrush()); + } + } catch (const UnsupportedExtensionEx & e) + { + std::cerr << "Caught: " << e.what() << std::endl; } + catch (const LoadPathNotImplEx & e) + { + std::cerr << "Caught: " << e.what() << std::endl; + } + catch (const LoadBufferNotImplEx & e) + { + std::cerr << "Caught: " << e.what() << std::endl; + } + catch (const std::exception & e) + { + std::cerr << "Caught: " << e.what() << std::endl; + } + } void csong::setNewPreferedLoudness(float preferedLoudness) @@ -88,7 +137,7 @@ void csong::setNewPreferedLoudness(float preferedLoudness) if (m_correctedPeakLevel>0){ m_widgetItem[3].setBackground(Qt::red); }else { - m_widgetItem[3].setBackground(Qt::white); + m_widgetItem[3].setBackground(QBrush()); } } @@ -121,7 +170,7 @@ float csong::get_correction() const float csong::linToDb(float linValue) { - return 20*std::log10f(linValue); + return 20*std::log10(linValue); } void csong::setWidgetProperties()