Klang C++ 0.7.15
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

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

Public Attributes

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

Private Member Functions

signal & operator+= (const signal &in)
 

Detailed Description

Definition at line 4273 of file klang.h.

Member Enumeration Documentation

◆ Content

Values
Empty 0 
Notes 1 
Effect 2 
Synth 3 

Definition at line 4286 of file klang.h.

4286 {
4287 Empty = 0,
4288 Notes = 1,
4289 Effect = 2,
4290 Synth = 3,
4291 } content = Empty;
enum klang::Debug::Buffer::Content content

Constructor & Destructor Documentation

◆ Buffer()

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

Definition at line 4284 of file klang.h.

4284: buffer(16384) {}
static THREAD_LOCAL Buffer buffer
Definition klang.h:4361

Member Function Documentation

◆ clear() [1/2]

void klang::buffer::clear ( )
inline

Definition at line 2673 of file klang.h.

2673 {
2674 memset(samples, 0, sizeof(float) * size);
2675 }
float * samples
Definition klang.h:2626
const int size
Definition klang.h:2631

◆ clear() [2/2]

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

Definition at line 2677 of file klang.h.

2677 {
2678 memset(samples, 0, sizeof(float) * (size < buffer::size ? size : buffer::size));
2679 }

◆ get()

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

Definition at line 4306 of file klang.h.

4306 {
4307#if HAS_KLANG_DEBUG
4308 if (active) {
4309 active = false;
4310 return data();
4311 }
4312 else {
4313 return nullptr;
4314 }
4315#else
4316 return nullptr;
4317#endif
4318 }
float * data()
Definition klang.h:2762

◆ operator const signal &()

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

Definition at line 4351 of file klang.h.

4351 {
4352#if HAS_KLANG_DEBUG
4353 return *ptr;
4354#else
4355 static const signal silence = 0;
4356 return silence;
4357#endif
4358 }
signal signal
Definition klang.h:2630
signal * ptr
Definition klang.h:2627

◆ operator++()

signal & klang::Debug::Buffer::operator++ ( int )
inline

Definition at line 4280 of file klang.h.

4280{ return *ptr; }

◆ operator+=() [1/2]

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

Definition at line 4320 of file klang.h.

4320 {
4321#if HAS_KLANG_DEBUG
4322 active = true;
4324 return *this;
4325#else
4326 return *this;
4327#endif
4328 }
signal & operator+=(const signal &in)
Definition klang.h:2742

◆ operator+=() [2/2]

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

Definition at line 4331 of file klang.h.

4331 {
4332#if HAS_KLANG_DEBUG
4333 active = true;
4335 return *this;
4336#else
4337 return *this;
4338#endif
4339 }

◆ operator>>()

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

Definition at line 4341 of file klang.h.

4341 {
4342#if HAS_KLANG_DEBUG
4343 destination << *ptr;
4344 return destination;
4345#else
4346 destination = 0;
4347 return destination;
4348#endif
4349 }

◆ rewind()

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

Definition at line 2665 of file klang.h.

2665 {
2666#ifdef _MSC_VER
2667 _controlfp_s(nullptr, _DN_FLUSH, _MCW_DN);
2668#endif
2669 ptr = (signal*)&samples[offset];
2670 end = (signal*)&samples[size];
2671 }
int offset() const
Definition klang.h:2681
signal * end
Definition klang.h:2628

Member Data Documentation

◆ active

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

Definition at line 4303 of file klang.h.

◆ content

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

◆ used

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

Definition at line 4304 of file klang.h.