audio-buffer.h (1089B)
1 #pragma once 2 3 #include "private/std.h" 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 // Sample code for reading a stereo buffer: 10 // 11 // bool isLeftConstant = (buffer->constant_mask & (1 << 0)) != 0; 12 // bool isRightConstant = (buffer->constant_mask & (1 << 1)) != 0; 13 // 14 // for (int i = 0; i < N; ++i) { 15 // float l = data32[0][isLeftConstant ? 0 : i]; 16 // float r = data32[1][isRightConstant ? 0 : i]; 17 // } 18 // 19 // Note: checking the constant mask is optional, and this implies that 20 // the buffer must be filled with the constant value. 21 // Rationale: if a buffer reader doesn't check the constant mask, then it may 22 // process garbage samples and in result, garbage samples may be transmitted 23 // to the audio interface with all the bad consequences it can have. 24 // 25 // The constant mask is a hint. 26 typedef struct clap_audio_buffer { 27 // Either data32 or data64 pointer will be set. 28 float **data32; 29 double **data64; 30 uint32_t channel_count; 31 uint32_t latency; // latency from/to the audio interface 32 uint64_t constant_mask; 33 } clap_audio_buffer_t; 34 35 #ifdef __cplusplus 36 } 37 #endif