From 6ba60f7329811a4bb3a07b1e6d81156d7f3a4ac3 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 12 Jan 2025 17:57:49 +0100 Subject: Added MIDIPlayer (WIP) --- MIDIPlayer.cpp | 27 +++++++++++++++++++++++++++ MIDIPlayer.h | 21 +++++++++++++++++++++ Makefile | 19 ++++++++++++++----- midiplay.cpp | 7 +++++-- 4 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 MIDIPlayer.cpp create mode 100644 MIDIPlayer.h diff --git a/MIDIPlayer.cpp b/MIDIPlayer.cpp new file mode 100644 index 0000000..41f852e --- /dev/null +++ b/MIDIPlayer.cpp @@ -0,0 +1,27 @@ +#include "MIDIPlayer.h" + +MIDIPlayer::MIDIPlayer() +{ +} + + +void MIDIPlayer::start() +{ + "aplaymidi -p24 locked_out_of_heaven.midi" +} + +void MIDIPlayer::stop() +{ +} + +bool MIDIPlayer::is_playing() +{ +} + +void MIDIPlayer::set_file(const std::string& filename) +{ +} + +std::vector MIDIPlayer::get_filelist() +{ +} diff --git a/MIDIPlayer.h b/MIDIPlayer.h new file mode 100644 index 0000000..e859bed --- /dev/null +++ b/MIDIPlayer.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include + +class MIDIPlayer +{ +public: + MIDIPlayer(); + + void start(); + + void stop(); + + bool is_playing(); + + void set_file(const std::string& filename); + + std::vector get_filelist(); +}; + diff --git a/Makefile b/Makefile index 5f24c4e..7ceb738 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,15 @@ TARGET=midiplay +SRCS=\ + midiplay.cpp \ + MIDIPlayer.cpp + +OBJS=$(SRCS:.cpp=.o) + +CXX=clang++ +CXXFLAGS=-Wall -g -O2 -fPIC -std=c++20 +CXXLIBS=-lfcgi -lreichwein -lfmt + all: $(TARGET) play: @@ -8,12 +18,11 @@ play: run-fcgi: spawn-fcgi -a 127.0.0.1 -p 9090 -n -- ./midiplay -midiplay.o: midiplay.cpp - g++ -Wall -g -O2 -fPIC -o $@ -c $^ - -$(TARGET): midiplay.o - g++ -Wall -g -O2 -fPIC -o $@ $^ -lfcgi -lreichwein -lfmt +%.o: %.cpp + $(CXX) $(CXXFLAGS) -o $@ -c $^ +$(TARGET): $(OBJS) + $(CXX) $(CXXFLAGS) -o $@ $^ $(CXXLIBS) clean: -rm -rf $(TARGET) diff --git a/midiplay.cpp b/midiplay.cpp index 75f33da..d5c0ef0 100644 --- a/midiplay.cpp +++ b/midiplay.cpp @@ -1,3 +1,5 @@ +#include "MIDIPlayer.h" + #include #include @@ -17,7 +19,7 @@ std::string getPostData(FCGX_Request& request) unsigned int status = FCGX_GetStr(result.data(), result.size(), request.in); if (status != result.size()) { - return fmt::format("Read error: {}/{}", status, result); + return fmt::format("Read error: {}/{}", status, result.size()); } return result; @@ -46,8 +48,9 @@ int main(int argc, char* argv[]) { FCGX_PutS("Content-Type: text/xml\r\n\r\n", request.out); std::string data = getPostData(request); - if (data == "3") + if (data == "3") { FCGX_PutS("4", request.out); + } } else { FCGX_PutS("Content-Type: text/text\r\n\r\n", request.out); FCGX_PutS("Bad request method: POST expected", request.out); -- cgit v1.2.3