1.1 --- a/DJMFix.cpp Fri Dec 18 20:13:05 2020 +0100
1.2 +++ b/DJMFix.cpp Fri Dec 18 21:35:36 2020 +0100
1.3 @@ -14,3 +14,42 @@
1.4 * You should have received a copy of the GNU General Public License
1.5 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1.6 */
1.7 +#include <iostream>
1.8 +
1.9 +#include "DJMFix.h"
1.10 +
1.11 +namespace djmfix {
1.12 +
1.13 +class DJMFixImpl : public DJMFix {
1.14 +private:
1.15 + MidiSender midiSender;
1.16 +public:
1.17 +
1.18 + DJMFixImpl(MidiSender midiSender) : midiSender(midiSender) {
1.19 + std::cerr << "DJMFixImpl()" << std::endl; // TODO: do not mess STDIO
1.20 + }
1.21 +
1.22 + virtual ~DJMFixImpl() override {
1.23 + std::cerr << "~DJMFixImpl()" << std::endl; // TODO: do not mess STDIO
1.24 + }
1.25 +
1.26 + virtual void receive(MidiMessage midiMessage) override {
1.27 + std::cerr << "DJMFixImpl::receive()" << std::endl; // TODO: do not mess STDIO
1.28 +
1.29 + midiSender({0xf0, 0xf7});
1.30 + }
1.31 +
1.32 + void start() override {
1.33 + std::cerr << "DJMFixImpl::start()" << std::endl; // TODO: do not mess STDIO
1.34 + }
1.35 +
1.36 + void stop() override {
1.37 + std::cerr << "DJMFixImpl::stop()" << std::endl; // TODO: do not mess STDIO
1.38 + }
1.39 +};
1.40 +
1.41 +DJMFix* create(MidiSender midiSender) {
1.42 + return new DJMFixImpl(midiSender);
1.43 +}
1.44 +
1.45 +}
2.1 --- a/DJMFix.h Fri Dec 18 20:13:05 2020 +0100
2.2 +++ b/DJMFix.h Fri Dec 18 21:35:36 2020 +0100
2.3 @@ -14,3 +14,24 @@
2.4 * You should have received a copy of the GNU General Public License
2.5 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2.6 */
2.7 +#pragma once
2.8 +
2.9 +#include <vector>
2.10 +#include <functional>
2.11 +
2.12 +namespace djmfix {
2.13 +
2.14 +using MidiMessage = std::vector<uint8_t>;
2.15 +using MidiSender = std::function<void(MidiMessage) >;
2.16 +
2.17 +class DJMFix {
2.18 +public:
2.19 + virtual ~DJMFix() = default;
2.20 + virtual void receive(MidiMessage midiMessage) = 0;
2.21 + virtual void start() = 0;
2.22 + virtual void stop() = 0;
2.23 +};
2.24 +
2.25 +DJMFix* create(MidiSender midiSender);
2.26 +
2.27 +}
3.1 --- a/Makefile Fri Dec 18 20:13:05 2020 +0100
3.2 +++ b/Makefile Fri Dec 18 21:35:36 2020 +0100
3.3 @@ -18,7 +18,10 @@
3.4 clean:
3.5 rm -rf build
3.6
3.7 -.PHONY: all clean
3.8 +run: build/djm-fix
3.9 + build/djm-fix
3.10 +
3.11 +.PHONY: all clean run
3.12
3.13 build/djm-fix: DJMFix.cpp DJMFix.h djm-fix.cpp
3.14 mkdir -p build
4.1 --- a/djm-fix.cpp Fri Dec 18 20:13:05 2020 +0100
4.2 +++ b/djm-fix.cpp Fri Dec 18 21:35:36 2020 +0100
4.3 @@ -15,6 +15,21 @@
4.4 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4.5 */
4.6
4.7 +#include <memory>
4.8 +#include <iostream>
4.9 +
4.10 +#include "DJMFix.h"
4.11 +
4.12 int main(int argc, char**argv) {
4.13 +
4.14 + std::shared_ptr<djmfix::DJMFix> djmFix(djmfix::create([](djmfix::MidiMessage midiMessage) {
4.15 + std::cerr << "main: will send midiMessage" << std::endl; // TODO: do not mess STDIO
4.16 + }));
4.17 +
4.18 + djmFix->start();
4.19 + djmFix->receive({0xf0, 0xf7});
4.20 + djmFix->stop();
4.21 +
4.22 +
4.23 return 0;
4.24 }