mirror of
https://github.com/AlexandreRouma/dsp2.git
synced 2026-04-20 07:22:44 +00:00
bugfix
This commit is contained in:
@@ -6,6 +6,7 @@ namespace dsp {
|
|||||||
* Re-allocation behavior of buffers.
|
* Re-allocation behavior of buffers.
|
||||||
*/
|
*/
|
||||||
enum ReallocBehavior {
|
enum ReallocBehavior {
|
||||||
|
|
||||||
// Discard the exiting content of the buffer.
|
// Discard the exiting content of the buffer.
|
||||||
REALLOC_DISCARD = 0,
|
REALLOC_DISCARD = 0,
|
||||||
|
|
||||||
@@ -105,14 +106,14 @@ namespace dsp {
|
|||||||
* @param index Index of the tap
|
* @param index Index of the tap
|
||||||
* @return Tap at index.
|
* @return Tap at index.
|
||||||
*/
|
*/
|
||||||
inline T& operator[](int index) { return buffer[index]; }
|
inline T& operator[](uintptr_t index) { return buffer[index]; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a sample by index.
|
* Get a sample by index.
|
||||||
* @param index Index of the tap
|
* @param index Index of the tap
|
||||||
* @return Tap at index.
|
* @return Tap at index.
|
||||||
*/
|
*/
|
||||||
inline const T& operator[](int index) const { return buffer[index]; }
|
inline const T& operator[](uintptr_t index) const { return buffer[index]; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t capacity = 0;
|
size_t capacity = 0;
|
||||||
|
|||||||
@@ -55,7 +55,52 @@ namespace dsp {
|
|||||||
re = b;
|
re = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Define in-place operators
|
// In-place real add operator
|
||||||
|
inline constexpr void operator+=(float b) {
|
||||||
|
re += b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In-place real subtract operator
|
||||||
|
inline constexpr void operator-=(float b) {
|
||||||
|
re -= b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In-place real multiply operator
|
||||||
|
inline constexpr void operator*=(float b) {
|
||||||
|
re *= b;
|
||||||
|
im *= b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In-place real divide operator
|
||||||
|
inline constexpr void operator/=(float b) {
|
||||||
|
re /= b;
|
||||||
|
im /= b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In-place complex add operator
|
||||||
|
inline constexpr void operator+=(const dsp::Complex& b) {
|
||||||
|
re += b.re;
|
||||||
|
im += b.im;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In-place complex subtract operator
|
||||||
|
inline constexpr void operator-=(const dsp::Complex& b) {
|
||||||
|
re -= b.re;
|
||||||
|
im -= b.im;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In-place real multiply operator
|
||||||
|
inline constexpr void operator*=(const dsp::Complex& b) {
|
||||||
|
re = re*b.re - im*b.im;
|
||||||
|
im = im*b.re + re*b.im;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In-place real divide operator
|
||||||
|
inline constexpr void operator/=(const dsp::Complex& b) {
|
||||||
|
float denom = b.re*b.re + b.im*b.im;
|
||||||
|
re = (re*b.re + im*b.im) / denom;
|
||||||
|
im = (im*b.re - re*b.im) / denom;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Real component.
|
* Real component.
|
||||||
|
|||||||
@@ -23,11 +23,17 @@ namespace dsp {
|
|||||||
Window& Window::operator=(const Window& b) {
|
Window& Window::operator=(const Window& b) {
|
||||||
// Copy the definition
|
// Copy the definition
|
||||||
def = b.def;
|
def = b.def;
|
||||||
|
|
||||||
|
// Return self
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window& Window::operator=(Window&& b) {
|
Window& Window::operator=(Window&& b) {
|
||||||
// Move the definition
|
// Move the definition
|
||||||
def = std::move(b.def);
|
def = std::move(b.def);
|
||||||
|
|
||||||
|
// Return self
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::generate(float* data, size_t len) const {
|
void Window::generate(float* data, size_t len) const {
|
||||||
@@ -53,7 +59,7 @@ namespace dsp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
template void Window::apply(float* data, size_t len) const;
|
template void Window::apply(float* data, size_t len) const;
|
||||||
//template void Window::apply(Complex* data, size_t len) const;
|
template void Window::apply(Complex* data, size_t len) const;
|
||||||
|
|
||||||
void Window::define() {
|
void Window::define() {
|
||||||
// Ensure an error is thrown if the undefined window is used
|
// Ensure an error is thrown if the undefined window is used
|
||||||
|
|||||||
4
todo.txt
4
todo.txt
@@ -1,6 +1,6 @@
|
|||||||
Create buffer class that replaces the BufferSet struct
|
Replaces the BufferSet struct using the Buffer class
|
||||||
|
|
||||||
Move the fixes from the SFAP library's stream.c to this one
|
Move the fixes from the SFAP library's stream.c to this one?
|
||||||
|
|
||||||
Think a lot about how multichannel streams are to be handled. Doing it all in one thread might not be possible so perhapse a built-in synchronisation system is worth it?
|
Think a lot about how multichannel streams are to be handled. Doing it all in one thread might not be possible so perhapse a built-in synchronisation system is worth it?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user