diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/midi_ringbuffer_test.cpp | 11 | ||||
-rw-r--r-- | tests/quantize_test.cpp | 13 | ||||
-rw-r--r-- | tests/smf_test.cpp | 8 | ||||
-rw-r--r-- | tests/time_test.cpp | 16 |
4 files changed, 28 insertions, 20 deletions
diff --git a/tests/midi_ringbuffer_test.cpp b/tests/midi_ringbuffer_test.cpp index 706aef1..2bf138c 100644 --- a/tests/midi_ringbuffer_test.cpp +++ b/tests/midi_ringbuffer_test.cpp @@ -1,21 +1,22 @@ +#include "raul/TimeStamp.hpp" +#include "raul/EventRingBuffer.hpp" #include <iostream> -#include "raul/StampedChunkRingBuffer.hpp" #include "raul/midi_names.h" using namespace std; using namespace Raul; void -read_write_test(StampedChunkRingBuffer& rb, unsigned offset) +read_write_test(EventRingBuffer& rb, unsigned offset) { - TickTime t; + TimeStamp t(TimeUnit(TimeUnit::FRAMES, 48000), 0, 0); size_t size; unsigned char buf[5]; snprintf((char*)buf, 5, "%d", offset); size = strlen((char*)buf); - size_t written = rb.write(offset, size, buf); + size_t written = rb.write(t, size, buf); assert(written == size); for (size_t i=0; i < 4; ++i) @@ -31,7 +32,7 @@ read_write_test(StampedChunkRingBuffer& rb, unsigned offset) int main() { - StampedChunkRingBuffer rb(32); + EventRingBuffer rb(32); for (size_t i=0; i < 9999; ++i) read_write_test(rb, i); diff --git a/tests/quantize_test.cpp b/tests/quantize_test.cpp index f79d279..b4c8725 100644 --- a/tests/quantize_test.cpp +++ b/tests/quantize_test.cpp @@ -1,5 +1,5 @@ -#include <iostream> #include <raul/Quantizer.hpp> +#include <iostream> using namespace std; using namespace Raul; @@ -8,16 +8,19 @@ using namespace Raul; int main() { - double q = 0; - double beats = 0; + double in = 0; cout << "Quantization: "; - cin >> q; + cin >> in; cout << endl; + + TimeStamp q(TimeUnit(TimeUnit::BEATS, 19200), in); while (true) { cout << "Beats: "; - cin >> beats; + cin >> in; + + TimeStamp beats(TimeUnit(TimeUnit::BEATS, 19200), in); cout << "Quantized: "; cout << Quantizer::quantize(q, beats) << endl << endl; diff --git a/tests/smf_test.cpp b/tests/smf_test.cpp index 75db43a..a123a61 100644 --- a/tests/smf_test.cpp +++ b/tests/smf_test.cpp @@ -14,10 +14,10 @@ main(int argc, char** argv) if (argc < 2) { filename = "./test.mid"; - SMFWriter writer(32768); - writer.start(string(filename)); + SMFWriter writer(TimeUnit(TimeUnit::BEATS, 19200)); + writer.start(string(filename), TimeStamp(writer.unit(), 0, 0)); writer.finish(); - cout << "Wrote " << filename << " with PPQN = " << writer.ppqn() << endl; + cout << "Wrote " << filename << " with PPQN = " << writer.unit().ppt() << endl; } else { filename = argv[1]; @@ -44,7 +44,7 @@ main(int argc, char** argv) unsigned char buf[4]; uint32_t ev_size; - uint32_t ev_delta_time; + TimeStamp ev_delta_time(reader.unit()); while (reader.read_event(4, buf, &ev_size, &ev_delta_time) >= 0) { cout << "Event, size = " << ev_size << ", time = " << ev_delta_time; diff --git a/tests/time_test.cpp b/tests/time_test.cpp index c5c89b7..2f87f87 100644 --- a/tests/time_test.cpp +++ b/tests/time_test.cpp @@ -1,5 +1,6 @@ -#include <iostream> +#include <raul/TimeStamp.hpp> #include <raul/TimeSlice.hpp> +#include <iostream> using namespace std; using namespace Raul; @@ -8,19 +9,22 @@ using namespace Raul; int main() { - TimeSlice ts(1/48000.0, 120); - - double in_double = 0; + TimeUnit unit(TimeUnit::BEATS, 19200); + TimeSlice ts(48000, 120); + double in_double; cout << "Beats: "; cin >> in_double; + + TimeStamp t(unit, (uint32_t)in_double, + (uint32_t)((in_double - (uint32_t)in_double) * unit.ppt())); cout << "\tSeconds: "; - cout << ts.beats_to_seconds(in_double); + cout << ts.beats_to_seconds(t); cout << endl; cout << "\tTicks: "; - cout << ts.beats_to_ticks(in_double); + cout << ts.beats_to_ticks(t); cout << endl; return 0; |