2023-05-04 20:48:50 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "temporal/tempo.h"
|
|
|
|
|
|
|
|
#include "TempoMapCutBufferTest.h"
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(TempoMapCutBufferTest);
|
|
|
|
|
|
|
|
using namespace Temporal;
|
|
|
|
|
|
|
|
void
|
|
|
|
TempoMapCutBufferTest::createTest()
|
|
|
|
{
|
|
|
|
CPPUNIT_ASSERT (TempoMap::use() != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TempoMapCutBufferTest::cutTest()
|
|
|
|
{
|
|
|
|
TempoMap::WritableSharedPtr tmap (TempoMap::write_copy());
|
|
|
|
|
2023-06-05 18:34:52 -04:00
|
|
|
(void) tmap->set_tempo (Tempo (180, 4), BBT_Argument (6, 1, 0));
|
|
|
|
(void) tmap->set_meter (Meter (6, 8), BBT_Argument (3, 1, 0));
|
2023-05-04 20:48:50 -04:00
|
|
|
|
2023-06-05 18:34:52 -04:00
|
|
|
(void) tmap->set_tempo (Tempo (180, 4), BBT_Argument (15, 1, 0));
|
2023-06-07 14:29:19 -04:00
|
|
|
(void) tmap->set_meter (Meter (3, 4), BBT_Argument (15, 1, 0));
|
2023-05-04 20:48:50 -04:00
|
|
|
|
2023-06-05 18:34:52 -04:00
|
|
|
(void) tmap->set_tempo (Tempo (180, 4), BBT_Argument (31, 1, 0));
|
2023-06-07 14:29:19 -04:00
|
|
|
(void) tmap->set_meter (Meter (5, 4), BBT_Argument (32, 1, 0));
|
2023-05-04 20:48:50 -04:00
|
|
|
|
2023-06-07 14:29:19 -04:00
|
|
|
std::cerr << "\n\nBefore cut\n";
|
2023-06-05 18:34:52 -04:00
|
|
|
tmap->dump (std::cerr);
|
|
|
|
|
2023-06-07 15:39:22 -04:00
|
|
|
TempoMapCutBuffer* cb = tmap->cut (timepos_t::from_superclock (tmap->superclock_at (BBT_Argument (62, 1, 0))),
|
|
|
|
timepos_t::from_superclock (tmap->superclock_at (BBT_Argument (300, 1, 0))),
|
2023-06-05 18:34:52 -04:00
|
|
|
false);
|
|
|
|
|
2023-06-06 11:04:16 -04:00
|
|
|
std::cerr << "Cut Buffer:\n";
|
|
|
|
cb->dump (std::cerr);
|
|
|
|
|
2023-06-05 18:34:52 -04:00
|
|
|
std::cerr << "After cut\n";
|
|
|
|
tmap->dump (std::cerr);
|
2023-05-04 20:48:50 -04:00
|
|
|
|
|
|
|
tmap->abort_update ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TempoMapCutBufferTest::copyTest()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TempoMapCutBufferTest::pasteTest()
|
|
|
|
{
|
2023-06-07 15:39:22 -04:00
|
|
|
TempoMap::WritableSharedPtr tmap (TempoMap::write_copy());
|
|
|
|
|
|
|
|
(void) tmap->set_tempo (Tempo (180, 4), BBT_Argument (6, 1, 0));
|
|
|
|
(void) tmap->set_meter (Meter (6, 8), BBT_Argument (3, 1, 0));
|
|
|
|
|
|
|
|
(void) tmap->set_tempo (Tempo (180, 4), BBT_Argument (15, 1, 0));
|
|
|
|
(void) tmap->set_meter (Meter (3, 4), BBT_Argument (15, 1, 0));
|
|
|
|
|
|
|
|
(void) tmap->set_tempo (Tempo (180, 4), BBT_Argument (31, 1, 0));
|
|
|
|
(void) tmap->set_meter (Meter (5, 4), BBT_Argument (32, 1, 0));
|
|
|
|
|
2023-06-07 15:58:38 -04:00
|
|
|
TempoMapCutBuffer* cb = tmap->copy (timepos_t::from_superclock (tmap->superclock_at (BBT_Argument (8, 1, 0))),
|
|
|
|
timepos_t::from_superclock (tmap->superclock_at (BBT_Argument (31, 1, 0))));
|
2023-06-07 15:39:22 -04:00
|
|
|
|
|
|
|
TempoMap* new_map = new TempoMap (Tempo (120, 4), Meter (7, 8));
|
|
|
|
|
2023-06-07 15:58:38 -04:00
|
|
|
#if 0
|
2023-06-07 15:39:22 -04:00
|
|
|
std::cerr << "\n\nCut Buffer:\n";
|
|
|
|
cb->dump (std::cerr);
|
|
|
|
|
|
|
|
std::cerr << "Before paste\n";
|
|
|
|
new_map->dump (std::cerr);
|
2023-06-07 15:58:38 -04:00
|
|
|
#endif
|
2023-06-07 15:39:22 -04:00
|
|
|
|
|
|
|
new_map->paste (*cb, timepos_t::from_superclock (tmap->superclock_at (BBT_Argument (6, 1, 0))),
|
|
|
|
false);
|
|
|
|
|
2023-06-07 15:58:38 -04:00
|
|
|
#if 0
|
2023-06-07 15:39:22 -04:00
|
|
|
std::cerr << "After paste\n";
|
|
|
|
new_map->dump (std::cerr);
|
2023-06-07 15:58:38 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
Meter nmm (new_map->meter_at (BBT_Argument (21,7,34)));
|
|
|
|
Tempo nmt (new_map->tempo_at (BBT_Argument (21,7,34)));
|
|
|
|
Meter omm (tmap->meter_at (BBT_Argument (21,7,34)));
|
|
|
|
Tempo omt (tmap->tempo_at (BBT_Argument (21,7,34)));
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL (nmm, omm);
|
|
|
|
CPPUNIT_ASSERT_EQUAL (omt, nmt);
|
2023-06-07 15:39:22 -04:00
|
|
|
|
|
|
|
delete new_map;
|
2023-05-04 20:48:50 -04:00
|
|
|
}
|