ardour
midi_clock_slave_test.h
Go to the documentation of this file.
1 /*
2  * Copyright(C) 2000-2008 Paul Davis
3  * Author: Hans Baier
4  *
5  * Evoral is free software; you can redistribute it and/or modify it under the
6  * terms of the GNU General Public License as published by the Free Software
7  * Foundation; either version 2 of the License, or(at your option) any later
8  * version.
9  *
10  * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <cassert>
20 #include <stdint.h>
21 #include <cppunit/TestFixture.h>
22 #include <cppunit/extensions/HelperMacros.h>
23 
24 #include "ardour/tempo.h"
25 #include "ardour/slave.h"
26 
27 namespace ARDOUR {
28 
30  #define FRAME_RATE 44100
32 
37 
40 
41  public:
43  transport_speed (1.0),
44  _transport_frame (0),
45  _frame_time (1000000),
46  _tempo_map (0),
47  tempo (120),
48  meter (4.0, 4.0)
49  {
50  _tempo_map = new TempoMap (FRAME_RATE);
51  _tempo_map->add_tempo (tempo, Timecode::BBT_Time(1, 1, 0));
52  _tempo_map->add_meter (meter, Timecode::BBT_Time(1, 1, 0));
53  }
54 
55  // Controlling the mock object
56  void set_period_size (framecnt_t a_size) { _period_size = a_size; }
57  framecnt_t period_size () const { return _period_size; }
58  void next_period () {
59  _transport_frame += double(_period_size) * double(transport_speed);
60  _frame_time += _period_size;
61  }
62 
63  // Implementation
64  TempoMap& tempo_map () const { return *_tempo_map; }
65  framecnt_t frame_rate () const { return FRAME_RATE; }
68  pframes_t frames_since_cycle_start () const { return 0; }
69  framepos_t frame_time () const { return _frame_time; }
70 
71  void request_locate (framepos_t frame, bool with_roll = false) {
72  _transport_frame = frame;
73  }
74 
75  void request_transport_speed (const double speed) { transport_speed = speed; }
76 };
77 
78 class MIDIClock_SlaveTest : public CppUnit::TestFixture, ARDOUR::MIDIClock_Slave
79 {
83 
84  public:
86 
87  void setUp() {
88  }
89 
90  void tearDown() {
91  }
92 
93  void testStepResponse();
94 };
95 
96 } // namespace ARDOUR
void add_tempo(const Tempo &, Timecode::BBT_Time where)
Definition: tempo.cc:513
We need this wrapper for testability, it's just too hard to mock up a session class.
Definition: slave.h:183
uint32_t pframes_t
Definition: types.h:61
#define FRAME_RATE
void request_transport_speed(const double speed)
CPPUNIT_TEST_SUITE(MIDIClock_SlaveTest)
LIBARDOUR_API uint64_t TempoMap
Definition: debug.cc:60
void set_period_size(framecnt_t a_size)
void request_locate(framepos_t frame, bool with_roll=false)
int64_t framecnt_t
Definition: types.h:76
void add_meter(const Meter &, Timecode::BBT_Time where)
Definition: tempo.cc:590
Definition: amp.h:29
int64_t framepos_t
Definition: types.h:66
CPPUNIT_TEST(testStepResponse)
pframes_t frames_since_cycle_start() const