# HG changeset patch # User František Kučera # Date 1608323736 -3600 # Node ID 98274757fcf64e999d9643a8828e168559dd97ca # Parent 4ee5349be21dfc4fcf197a75e742bbb12f363b9a more bones diff -r 4ee5349be21d -r 98274757fcf6 DJMFix.cpp --- a/DJMFix.cpp Fri Dec 18 20:13:05 2020 +0100 +++ b/DJMFix.cpp Fri Dec 18 21:35:36 2020 +0100 @@ -14,3 +14,42 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +#include + +#include "DJMFix.h" + +namespace djmfix { + +class DJMFixImpl : public DJMFix { +private: + MidiSender midiSender; +public: + + DJMFixImpl(MidiSender midiSender) : midiSender(midiSender) { + std::cerr << "DJMFixImpl()" << std::endl; // TODO: do not mess STDIO + } + + virtual ~DJMFixImpl() override { + std::cerr << "~DJMFixImpl()" << std::endl; // TODO: do not mess STDIO + } + + virtual void receive(MidiMessage midiMessage) override { + std::cerr << "DJMFixImpl::receive()" << std::endl; // TODO: do not mess STDIO + + midiSender({0xf0, 0xf7}); + } + + void start() override { + std::cerr << "DJMFixImpl::start()" << std::endl; // TODO: do not mess STDIO + } + + void stop() override { + std::cerr << "DJMFixImpl::stop()" << std::endl; // TODO: do not mess STDIO + } +}; + +DJMFix* create(MidiSender midiSender) { + return new DJMFixImpl(midiSender); +} + +} diff -r 4ee5349be21d -r 98274757fcf6 DJMFix.h --- a/DJMFix.h Fri Dec 18 20:13:05 2020 +0100 +++ b/DJMFix.h Fri Dec 18 21:35:36 2020 +0100 @@ -14,3 +14,24 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +#pragma once + +#include +#include + +namespace djmfix { + +using MidiMessage = std::vector; +using MidiSender = std::function; + +class DJMFix { +public: + virtual ~DJMFix() = default; + virtual void receive(MidiMessage midiMessage) = 0; + virtual void start() = 0; + virtual void stop() = 0; +}; + +DJMFix* create(MidiSender midiSender); + +} diff -r 4ee5349be21d -r 98274757fcf6 Makefile --- a/Makefile Fri Dec 18 20:13:05 2020 +0100 +++ b/Makefile Fri Dec 18 21:35:36 2020 +0100 @@ -18,7 +18,10 @@ clean: rm -rf build -.PHONY: all clean +run: build/djm-fix + build/djm-fix + +.PHONY: all clean run build/djm-fix: DJMFix.cpp DJMFix.h djm-fix.cpp mkdir -p build diff -r 4ee5349be21d -r 98274757fcf6 djm-fix.cpp --- a/djm-fix.cpp Fri Dec 18 20:13:05 2020 +0100 +++ b/djm-fix.cpp Fri Dec 18 21:35:36 2020 +0100 @@ -15,6 +15,21 @@ * along with this program. If not, see . */ +#include +#include + +#include "DJMFix.h" + int main(int argc, char**argv) { + + std::shared_ptr djmFix(djmfix::create([](djmfix::MidiMessage midiMessage) { + std::cerr << "main: will send midiMessage" << std::endl; // TODO: do not mess STDIO + })); + + djmFix->start(); + djmFix->receive({0xf0, 0xf7}); + djmFix->stop(); + + return 0; }