// convert channels, src is interlaced as LRLRLR... // return: # of samples rendered size_t DSD2PCM::Render(uint8_t* src, size_t src_size, size_t block_size, int lsbf, uint8_t* dst, size_t samplesToRender) { std::vector<float> float_data(src_size, 0), resample_data(src_size, 0); size_t idone = 0, odone = 0; if (flush_phase) { return 0; // RenderFlush(dst, samplesToRender); } for (int ch = 0; ch < channels; ++ch) { ds[ch].translate(src_size / channels, src + ch * block_size, (block_size > 1) ? 1 : channels, lsbf, float_data.data() + ch, channels); } soxr_process(soxr, float_data.data(), src_size / channels, &idone, resample_data.data(), src_size / channels, &odone); if (odone > 0) { buffer.insert(buffer.end(), resample_data.begin(), resample_data.begin() + odone * channels); buffer_stored += odone; } if (buffer_stored >= samplesToRender) { size_t samplesWritten = writeFinal(buffer, samplesToRender, dst); if (samplesWritten > 0) { buffer.erase(buffer.begin(), buffer.begin() + samplesToRender * channels); buffer_stored -= samplesWritten; return samplesWritten; } } return 0; }
//////////////////////////////////////////////// // TextureForNode methods void TextureForNode:: bind_texture(GLenum ptexture_unit) { WRATHassert(ptexture_unit==m_texture_unit); WRATHunused(ptexture_unit); if(m_rgba8_data.empty() or !m_active) { return; } /* convert from FP32 to our wierd 8+8.8+8 format. */ if(m_texture_name==0) { glGenTextures(1, &m_texture_name); glBindTexture(1, m_texture_name); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_texture_width(), 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); } else { glBindTexture(GL_TEXTURE_2D, m_texture_name); } /* convert from fp32 to 8+8.8+8: */ const_c_array<float> float_data(m_source.data_to_pack_to_GL_restrict()); int number_nodes(m_source.number_slots_to_pack_to_GL()); convert_from_fp32(float_data, number_nodes); /* now upload it to GL */ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_texture_width, number_nodes, GL_RGBA GL_UNSIGNED_BYTES, &m_rgba8_data[0]); }