Everything is a buffer
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
#include "dsp_types.hpp"
|
||||
#include "test_common.hpp"
|
||||
#include <delay/buffer_multi.hpp>
|
||||
#include <delay/buffer.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
int test_buffer_multi_1()
|
||||
@@ -17,26 +21,26 @@ int test_buffer_multi_1()
|
||||
{
|
||||
for (int c=0; c < 5; c++)
|
||||
{
|
||||
buffer.at(c, 0) = i+1;
|
||||
buffer[c][0] = i+1;
|
||||
}
|
||||
buffer += 1;
|
||||
|
||||
}
|
||||
|
||||
buffer.reset();
|
||||
for (int c=0; c < 5; c++)
|
||||
{
|
||||
buffer[c].reset();
|
||||
}
|
||||
|
||||
for (int i=0; i < 10; i++)
|
||||
{
|
||||
for (int c=0; c < 5; c++)
|
||||
{
|
||||
int v = buffer.at(c, i);
|
||||
int v = buffer[c][i];
|
||||
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
||||
}
|
||||
}
|
||||
|
||||
for(const auto&i : buffer)
|
||||
{
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -53,8 +57,8 @@ int test_buffer_multi_2()
|
||||
{
|
||||
for (int c=0; c < 5; c++)
|
||||
{
|
||||
buffer.at(c, 0) = i+1;
|
||||
int v = buffer.at(c, -2);
|
||||
buffer[c][0] = i+1;
|
||||
int v = buffer[c][-2];
|
||||
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
||||
}
|
||||
buffer += 1;
|
||||
@@ -88,20 +92,89 @@ int test_buffer_multi_3()
|
||||
{
|
||||
for (int c=0; c < 5; c++)
|
||||
{
|
||||
buffer.at(c, 0) = i+1;
|
||||
int v = buffer.at(c, -c);
|
||||
buffer[c][0] = i+1;
|
||||
int v = buffer[c][-c];
|
||||
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_buffer_multi_4()
|
||||
{
|
||||
std::cout << "----------------------------------------------" << std::endl;
|
||||
std::cout << "Start test_buffer_multi_4()" << std::endl;
|
||||
std::cout << "----------------------------------------------" << std::endl;
|
||||
|
||||
dsp::BufferMulti<int>buffer(5, 10);
|
||||
printf("Buffer capacity = %zu\n", buffer.capacity());
|
||||
|
||||
dsp::Buffer<int> *mbv[5];
|
||||
for (int c=0; c < 5; c++)
|
||||
{
|
||||
mbv[c] = new dsp::Buffer<int>(buffer[c], -c);
|
||||
}
|
||||
|
||||
for (int i=0; i < 10; i++)
|
||||
{
|
||||
for (int c=0; c < 5; c++)
|
||||
{
|
||||
buffer[c][0] = i+1;
|
||||
}
|
||||
buffer += 1;
|
||||
}
|
||||
|
||||
buffer.reset();
|
||||
for (int c=0; c < 5; c++)
|
||||
{
|
||||
for (int i=0; i < 10; i++)
|
||||
{
|
||||
print(*mbv[c], 10);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_buffer_multi_5()
|
||||
{
|
||||
std::cout << "----------------------------------------------" << std::endl;
|
||||
std::cout << "Start test_buffer_multi_5()" << std::endl;
|
||||
std::cout << "----------------------------------------------" << std::endl;
|
||||
|
||||
dsp::BufferMulti<int>buffer(5, 10);
|
||||
printf("Buffer capacity = %zu\n", buffer.capacity());
|
||||
|
||||
for (int i=0; i < 10; i++)
|
||||
{
|
||||
buffer = i+1;
|
||||
buffer += 1;
|
||||
}
|
||||
|
||||
buffer.reset();
|
||||
print(buffer.buffer(), buffer.buffer().capacity());
|
||||
|
||||
|
||||
for (int i=0; i < 10; i++)
|
||||
{
|
||||
print(buffer.quer(i), buffer.quer().capacity());
|
||||
// if (buffer.quer(0) == dsp::Buffer<int>(std::vector<int>{1,1,1,1,1}))
|
||||
// {
|
||||
// std::cout << "Okay" << std::endl;
|
||||
// }
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_buffer_multi()
|
||||
{
|
||||
test_buffer_multi_1();
|
||||
test_buffer_multi_2();
|
||||
test_buffer_multi_3();
|
||||
std::vector<int> v { 34,23 };
|
||||
const std::vector<int> v2 { 34,23 };
|
||||
// test_buffer_multi_1();
|
||||
// test_buffer_multi_2();
|
||||
// test_buffer_multi_3();
|
||||
test_buffer_multi_4();
|
||||
test_buffer_multi_5();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user