sliding window
This commit is contained in:
parent
e65935b08c
commit
95b0032de1
17
src/main.cpp
17
src/main.cpp
@ -26,17 +26,22 @@ int main(int argc, char** argv) {
|
|||||||
Camera::instance()->init();
|
Camera::instance()->init();
|
||||||
|
|
||||||
AudioPlayer player(musicFile);
|
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) {
|
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
|
memmove(line, line + 1024, 1024);
|
||||||
if(channels > 1) {
|
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) {
|
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 {
|
} 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();
|
player.play();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user