sliding window

This commit is contained in:
Selim Mustafaev 2016-02-05 00:30:49 +03:00
parent e65935b08c
commit 95b0032de1

View File

@ -26,17 +26,22 @@ int main(int argc, char** argv) {
Camera::instance()->init();
AudioPlayer player(musicFile);
float* line = new float[1024];
float* line = new float[2048];
memset(line, 0, 2048);
player.setStreamListener([&mesh, line](float *data, std::size_t framesCount, std::size_t depth, std::size_t channels) {
// if we have more than one channel, take the first
if(channels > 1) {
memmove(line, line + 1024, 1024);
if(channels > 1) { // if we have more than one channel, use the first
for(std::size_t i = 0, j = 0; i < framesCount; i += channels, ++j) {
line[j] = data[i];
line[1024 + j] = data[i];
}
mesh.addLine(line, depth);
} else {
mesh.addLine(data, depth);
memcpy(line + 1024, data, 1024);
}
mesh.addLine(line, depth);
mesh.addLine(line + 256, depth);
mesh.addLine(line + 512, depth);
mesh.addLine(line + 768, depth);
});
player.play();