29 #ifndef AUDIO_STREAM_RESAMPLED_H 30 #define AUDIO_STREAM_RESAMPLED_H 32 #include "scene/resources/audio_stream.h" 42 uint32_t read_buff_len;
46 volatile int rb_read_pos;
47 volatile int rb_write_pos;
52 MIX_FRAC_LEN=(1<<MIX_FRAC_BITS),
53 MIX_FRAC_MASK=MIX_FRAC_LEN-1,
61 uint32_t _resample(int32_t *p_dest,
int p_todo,int32_t p_increment);
66 _FORCE_INLINE_
int get_total()
const {
71 _FORCE_INLINE_
int get_todo()
const {
74 int read_pos_cache=rb_read_pos;
76 if (read_pos_cache==rb_write_pos) {
78 }
else if (read_pos_cache>rb_write_pos) {
80 todo=read_pos_cache-rb_write_pos-1;
83 todo=(rb_len-rb_write_pos)+read_pos_cache-1;
90 virtual int get_channel_count()
const;
91 virtual bool mix(int32_t *p_dest,
int p_frames);
93 _FORCE_INLINE_
void _flush() {
98 _FORCE_INLINE_ int16_t *get_write_buffer() {
return read_buf; }
99 _FORCE_INLINE_
void write(uint32_t p_frames) {
101 ERR_FAIL_COND(p_frames >= rb_len);
106 for(uint32_t i=0;i<p_frames;i++) {
108 rb[ rb_write_pos ] = read_buf[i];
109 rb_write_pos=(rb_write_pos+1)&rb_mask;
114 for(uint32_t i=0;i<p_frames;i++) {
116 rb[ (rb_write_pos<<1)+0 ] = read_buf[(i<<1)+0];
117 rb[ (rb_write_pos<<1)+1 ] = read_buf[(i<<1)+1];
118 rb_write_pos=(rb_write_pos+1)&rb_mask;
123 for(uint32_t i=0;i<p_frames;i++) {
125 rb[ (rb_write_pos<<2)+0 ] = read_buf[(i<<2)+0];
126 rb[ (rb_write_pos<<2)+1 ] = read_buf[(i<<2)+1];
127 rb[ (rb_write_pos<<2)+2 ] = read_buf[(i<<2)+2];
128 rb[ (rb_write_pos<<2)+3 ] = read_buf[(i<<2)+3];
129 rb_write_pos=(rb_write_pos+1)&rb_mask;
134 for(uint32_t i=0;i<p_frames;i++) {
136 rb[ (rb_write_pos*6)+0 ] = read_buf[(i*6)+0];
137 rb[ (rb_write_pos*6)+1 ] = read_buf[(i*6)+1];
138 rb[ (rb_write_pos*6)+2 ] = read_buf[(i*6)+2];
139 rb[ (rb_write_pos*6)+3 ] = read_buf[(i*6)+3];
140 rb[ (rb_write_pos*6)+4 ] = read_buf[(i*6)+4];
141 rb[ (rb_write_pos*6)+5 ] = read_buf[(i*6)+5];
142 rb_write_pos=(rb_write_pos+1)&rb_mask;
151 virtual bool _can_mix()
const =0;
153 _FORCE_INLINE_
bool _is_ready()
const{
157 Error _setup(
int p_channels,
int p_mix_rate,
int p_minbuff_needed=-1);
161 AudioStreamResampled();
162 ~AudioStreamResampled();
165 #endif // AUDIO_STREAM_RESAMPLED_H Definition: audio_stream.h:68