Skip to content

Commit

Permalink
Namespace changed from cnl::dsp to cdsp
Browse files Browse the repository at this point in the history
  • Loading branch information
hbe72 committed May 14, 2018
1 parent 6b3aeb1 commit 3a406b6
Show file tree
Hide file tree
Showing 22 changed files with 319 additions and 351 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ install(TARGETS Cdsp EXPORT CdspTargets)

install(EXPORT CdspTargets
FILE CdspConfig.cmake
NAMESPACE Cnl::
NAMESPACE Cdsp::
DESTINATION lib/cmake/cdsp)

install(DIRECTORY ${Cnl_DESTDIR}/ DESTINATION ${CMAKE_INSTALL_PREFIX})
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cd /some/directory
git clone https://github.com/hbe72/dsp.git
```

###Build
### Build
1. Generate the build system
```
mkdir build
Expand Down
17 changes: 7 additions & 10 deletions include/dsp/biquad.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(CNL_DSP_BIQUAD)
#define CNL_DSP_BIQUAD
#if !defined(CDSP_BIQUAD)
#define CDSP_BIQUAD

#include <array>
#include <vector>

#include "circular_buffer.h"
#include "dsp_types.h"

namespace cnl
{
namespace dsp
namespace cdsp
{

///Direct form I second order IIR
Expand Down Expand Up @@ -57,8 +55,8 @@ class biquad
unsigned int m_channelCount;

/// Delay lines of the IIR.
std::vector<cnl::dsp::circular_buffer<T> > m_stateX;
std::vector<cnl::dsp::circular_buffer<T> > m_stateY;
std::vector<cdsp::circular_buffer<T> > m_stateX;
std::vector<cdsp::circular_buffer<T> > m_stateY;
};

template<class T>
Expand Down Expand Up @@ -164,6 +162,5 @@ inline std::vector<q4_20> biquad<q4_20>::filter_interleaved(std::vector<q4_20> c
return out;
}

} //namespace dsp
} //namespace cnl
#endif //CNL_DSP_BIQUAD
} //namespace cdsp
#endif //CDSP_BIQUAD
15 changes: 6 additions & 9 deletions include/dsp/biquad_cascade.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(CNL_DSP_BIQUAD_CASCADE)
#define CNL_DSP_BIQUAD_CASCADE
#if !defined(CDSP_BIQUAD_CASCADE)
#define CDSP_BIQUAD_CASCADE

#include <algorithm>
#include <vector>

#include "biquad.h"

namespace cnl
{
namespace dsp
namespace cdsp
{

/// Cascaded Second Order IIR sections
Expand Down Expand Up @@ -55,7 +53,7 @@ class biquad_cascade
void filter_channels(std::vector<std::vector<T> >& in);

private:
std::vector<cnl::dsp::biquad<T> > m_biquad;
std::vector<cdsp::biquad<T> > m_biquad;
};

template<class T>
Expand Down Expand Up @@ -124,6 +122,5 @@ void biquad_cascade<T>::filter_channels(std::vector<std::vector<T> >& in)
}
}

} // namespace dsp
} // namespace cnl
#endif //CNL_DSP_BIQUAD_CASCADE
} // namespace cdsp
#endif //CDSP_BIQUAD_CASCADE
13 changes: 5 additions & 8 deletions include/dsp/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(CNL_DSP_CIRCULAR_BUFFER)
#define CNL_DSP_CIRCULAR_BUFFER
#if !defined(CDSP_CIRCULAR_BUFFER)
#define CDSP_CIRCULAR_BUFFER

#include <algorithm>
#include <vector>

namespace cnl
{
namespace dsp
namespace cdsp
{

template<typename T>
Expand Down Expand Up @@ -71,6 +69,5 @@ void circular_buffer<T>::push_back(T const& data)
m_buffer[m_last] = data;
}

} //namespace dsp
} //namespace cnl
#endif //CNL_DSP_CIRCULAR_BUFFER
} //namespace cdsp
#endif //CDSP_CIRCULAR_BUFFER
19 changes: 8 additions & 11 deletions include/dsp/complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(CNL_DSP_COMPLEX)
#define CNL_DSP_COMPLEX
#if !defined(CDSP_COMPLEX)
#define CDSP_COMPLEX

//#include <cmath>

#include "dsp_types.h"
#include "dsp_math.h"

namespace cnl
{
namespace dsp
namespace cdsp
{

/// Complex numbers
Expand Down Expand Up @@ -146,8 +144,8 @@ complex<T>& complex<T>::operator/=(complex<T> const& rhs)
T real = m_real * rhs.m_real + m_imag * rhs.m_imag;
T imag = m_imag * rhs.m_real - m_real * rhs.m_imag;
T div = rhs.m_real * rhs.m_real + rhs.m_imag * rhs.m_imag;
m_real = cnl::dsp::math::divides<T,T>()(real, div);
m_imag = cnl::dsp::math::divides<T,T>()(imag, div);
m_real = cdsp::math::divides<T,T>()(real, div);
m_imag = cdsp::math::divides<T,T>()(imag, div);
return *this;
}

Expand Down Expand Up @@ -187,7 +185,7 @@ template<typename T>
T complex<T>::abs() const
{
T val = m_real * m_real + m_imag * m_imag;
T res = cnl::dsp::math::sqrt(val);
T res = cdsp::math::sqrt(val);
return res;
}

Expand All @@ -211,6 +209,5 @@ complex<T> conj(complex<T> const& value)
return ret;
}

} // namespace dsp
} // namespace cnl
#endif //CNL_DSP_COMPLEX
} // namespace cdsp
#endif //CDSP_COMPLEX
23 changes: 10 additions & 13 deletions include/dsp/complex_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(CNL_DSP_COMPLEX_VECTOR)
#define CNL_DSP_COMPLEX_VECTOR
#if !defined(CDSP_COMPLEX_VECTOR)
#define CDSP_COMPLEX_VECTOR

#include <algorithm>
#include <cassert>
Expand All @@ -15,9 +15,7 @@
#include <dsp/dsp_math.h>
#include <dsp/trig.h>

namespace cnl
{
namespace dsp
namespace cdsp
{

/// Defines maximum size for the complex Vector
Expand Down Expand Up @@ -219,9 +217,9 @@ complex_vector<T>& complex_vector<T>::operator+=(complex_vector<T> const& rhs)
{
assert(size() == rhs.size());
std::transform(m_real.begin(), m_real.end(), rhs.m_real.begin(),
m_real.begin(), cnl::dsp::math::plus<T>());
m_real.begin(), cdsp::math::plus<T>());
std::transform(m_imag.begin(), m_imag.end(), rhs.m_imag.begin(),
m_imag.begin(), cnl::dsp::math::plus<T>());
m_imag.begin(), cdsp::math::plus<T>());
return *this;
}

Expand All @@ -230,9 +228,9 @@ complex_vector<T>& complex_vector<T>::operator-=(complex_vector<T> const& rhs)
{
assert(size() == rhs.size());
std::transform(m_real.begin(), m_real.end(), rhs.m_real.begin(),
m_real.begin(), cnl::dsp::math::minus<T>());
m_real.begin(), cdsp::math::minus<T>());
std::transform(m_imag.begin(), m_imag.end(), rhs.m_imag.begin(),
m_imag.begin(), cnl::dsp::math::minus<T>());
m_imag.begin(), cdsp::math::minus<T>());
return *this;
}

Expand Down Expand Up @@ -331,7 +329,7 @@ R correlate_with_exp(complex_vector<T> const& vector,
size_t end)
{
size_t last = std::min(end, vector.size());
cnl::dsp::trig<T>& exp = cnl::dsp::trig<T>::instance();
cdsp::trig<T>& exp = cdsp::trig<T>::instance();
std::size_t stride = static_cast<std::size_t>(step * exp.getTwoPiIndex() / fftsize);
R sum(0.);
for (std::size_t index = begin; index < last; ++index)
Expand Down Expand Up @@ -360,6 +358,5 @@ R energy(complex_vector<T> const& vector,
}


} // namespace dsp
} // namespace cnl
#endif //CNL_DSP_COMPLEX_VECTOR
} // namespace cdsp
#endif //CDSP_COMPLEX_VECTOR
14 changes: 5 additions & 9 deletions include/dsp/dsp_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(CNL_DSP_MATH)
#define CNL_DSP_MATH
#if !defined(CDSP_MATH)
#define CDSP_MATH

#include <cstdint>
#include "dsp_types.h"

namespace cnl
{
namespace dsp
namespace cdsp
{
namespace math
{
Expand Down Expand Up @@ -154,8 +152,6 @@ inline int leading_bits(const cnl::fixed_point<Rep, Exponent> a)
}

} // namespace math
} // namespace dsp
} // namespace cnl

} // namespace cdsp

#endif //CNL_DSP_MATH
#endif //CDSP_MATH
6 changes: 3 additions & 3 deletions include/dsp/dsp_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(CNL_DSP_TYPES)
#define CNL_DSP_TYPES
#if !defined(CDSP_TYPES)
#define CDSP_TYPES

#include <cnl.h>

// Elastic fixed point types equivalent to Cirrus ADSP2
typedef cnl::elastic_number<24, -20> q4_20;
typedef cnl::elastic_number<48, -40> q8_40;

#endif //CNL_DSP_TYPES
#endif //CDSP_TYPES
Loading

0 comments on commit 3a406b6

Please sign in to comment.