Klang C++
Language Reference (draft)
Loading...
Searching...
No Matches
klang::Debug::Buffer

Audio buffer for debug output. More...

#include <klang.h>

+ Inheritance diagram for klang::Debug::Buffer:

Public Types

enum  Content { Empty = 0 , Notes = 1 , Effect = 2 , Synth = 3 }
 

Public Member Functions

 Buffer ()
 
const float * get ()
 
Bufferoperator+= (const signal in)
 
template<typename TYPE >
Bufferoperator+= (TYPE &in)
 
signaloperator>> (signal &destination) const
 
 operator const signal & () const
 
void clear ()
 
void clear (int size)
 
void rewind (int offset=0)
 
signaloperator++ (int)
 

Public Attributes

enum klang::Debug::Buffer::Content content = Empty
 
bool active = false
 
int used = 0
 

Private Member Functions

signaloperator+= (const signal &in)
 

Detailed Description

Definition at line 2233 of file klang.h.

Member Enumeration Documentation

◆ Content

Values
Empty 
Notes 
Effect 
Synth 

Definition at line 2241 of file klang.h.

2241 {
2242 Empty = 0,
2243 Notes = 1,
2244 Effect = 2,
2245 Synth = 3,
2246 } content = Empty;
enum klang::Debug::Buffer::Content content

Constructor & Destructor Documentation

◆ Buffer()

klang::Debug::Buffer::Buffer ( )
inline

Definition at line 2239 of file klang.h.

2239: buffer(16384) { }
static THREAD_LOCAL Buffer buffer
Definition klang.h:2294

References klang::buffer::buffer().

Member Function Documentation

◆ clear() [1/2]

void klang::buffer::clear ( )
inline

Definition at line 1241 of file klang.h.

1241 {
1242 memset(samples, 0, sizeof(float) * size);
1243 }
float * samples
Definition klang.h:1204
const int size
Definition klang.h:1209

◆ clear() [2/2]

void klang::buffer::clear ( int size)
inline

Definition at line 1245 of file klang.h.

1245 {
1246 memset(samples, 0, sizeof(float) * (size < buffer::size ? size : buffer::size));
1247 }

◆ get()

const float * klang::Debug::Buffer::get ( )
inline

Definition at line 2261 of file klang.h.

2261 {
2262 if (active) {
2263 active = false;
2264 return data();
2265 }
2266 else {
2267 return nullptr;
2268 }
2269 }
const float * data() const
Definition klang.h:1327

References active, and klang::buffer::data().

◆ operator const signal &()

klang::Debug::Buffer::operator const signal & ( ) const
inline

Definition at line 2289 of file klang.h.

2289 {
2290 return *ptr;
2291 }
signal * ptr
Definition klang.h:1205

References klang::buffer::ptr.

Referenced by klang::Debug::operator const signal &().

◆ operator++()

signal & klang::buffer::operator++ ( int )
inline

Definition at line 1298 of file klang.h.

1298 {
1299 return *ptr++;
1300 }

◆ operator+=() [1/2]

Buffer & klang::Debug::Buffer::operator+= ( const signal in)
inline

Definition at line 2271 of file klang.h.

2271 {
2272 active = true;
2274 return *this;
2275 }
signal & operator+=(const signal &in)
Definition klang.h:1306

References active, and klang::buffer::operator+=().

Referenced by klang::Debug::input().

◆ operator+=() [2/2]

template<typename TYPE >
Buffer & klang::Debug::Buffer::operator+= ( TYPE & in)
inline

Definition at line 2278 of file klang.h.

2278 {
2279 active = true;
2281 return *this;
2282 }

◆ operator>>()

signal & klang::Debug::Buffer::operator>> ( signal & destination) const
inline

Definition at line 2284 of file klang.h.

2284 {
2285 destination << *ptr;
2286 return destination;
2287 }

References klang::buffer::ptr.

◆ rewind()

void klang::buffer::rewind ( int offset = 0)
inline

Definition at line 1233 of file klang.h.

1233 {
1234#ifdef _MSC_VER
1235 _controlfp_s(nullptr, _DN_FLUSH, _MCW_DN);
1236#endif
1237 ptr = (signal*)&samples[offset];
1238 end = (signal*)&samples[size];
1239 }
int offset() const
Definition klang.h:1249
signal signal
Definition klang.h:1208
signal * end
Definition klang.h:1206

Member Data Documentation

◆ active

bool klang::Debug::Buffer::active = false

Definition at line 2258 of file klang.h.

Referenced by get(), and operator+=().

◆ content

enum klang::Debug::Buffer::Content klang::Debug::Buffer::content = Empty

◆ used

int klang::Debug::Buffer::used = 0

Definition at line 2259 of file klang.h.