Skip to content

Commit

Permalink
remove dtask submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
HackerFoo committed Oct 31, 2020
1 parent d569bd7 commit 7770923
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 58 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build/
/midipush
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "dtask"]
path = dtask
url = [email protected]:google/dtask.git
16 changes: 4 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
CXXFLAGS := -g3 -Og
LDFLAGS := -lrtmidi
LDFLAGS := -lasound

BUILD_DIR := build
DTASK_ROOT := dtask
DTASK_SRC := $(DTASK_ROOT)/src
DTASK_TOOLS := $(DTASK_ROOT)/tools

C_SRC := $(wildcard *.c)
CXX_SRC := $(wildcard *.cpp)
SRC := $(C_SRC) $(CXX_SRC)
SRC := $(wildcard *.c)
DTASK_TARGETS := midi_tasks
DTASK_GENERATED_HEADERS := $(patsubst %, $(BUILD_DIR)/%.h, $(DTASK_TARGETS))
HEADERS := $(wildcard *.h) $(DTASK_GENERATED_HEADERS)
OBJS := $(patsubst %.c, $(BUILD_DIR)/%.o, $(C_SRC)) $(patsubst %.cpp, $(BUILD_DIR)/%.o, $(CXX_SRC)) $(BUILD_DIR)/dtask.o
OBJS := $(patsubst %.c, $(BUILD_DIR)/%.o, $(SRC)) $(BUILD_DIR)/dtask.o
CFLAGS := -g -O3 -std=c99 -I $(DTASK_SRC) -I $(BUILD_DIR)
CXXFLAGS := -g -O3 -std=c++17 -I $(DTASK_SRC) -I $(BUILD_DIR)

.PHONY: all
all: midipush
Expand All @@ -23,7 +19,7 @@ print-%:
@echo $($*)

midipush: $(OBJS)
$(CXX) $^ -o $@ $(LDFLAGS)
$(CC) $^ -o $@ $(LDFLAGS)

$(DTASK_GENERATED_HEADERS): $(BUILD_DIR)/%.h : $(SRC)
@mkdir -p $(BUILD_DIR)
Expand All @@ -34,10 +30,6 @@ $(BUILD_DIR)/%.o: %.c $(HEADERS)
@mkdir -p $(BUILD_DIR)
$(CC) -c $< -o $@ $(CFLAGS) $(CFLAGS_EXT)

$(BUILD_DIR)/%.o: %.cpp $(HEADERS)
@mkdir -p $(BUILD_DIR)
$(CXX) -c $< -o $@ $(CXXFLAGS) $(CXXFLAGS_EXT)

$(BUILD_DIR)/dtask.o: $(DTASK_SRC)/dtask.c $(DTASK_SRC)/*.h
@mkdir -p $(BUILD_DIR)
$(CC) -c $< -o $@ $(CFLAGS) $(CFLAGS_EXT)
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ with pkgs;
stdenv.mkDerivation {
name = "midipush";
src = ./.;
buildInputs = [ rtmidi ];
buildInputs = [ python alsaLib ];
}
1 change: 0 additions & 1 deletion dtask
Submodule dtask deleted from 9e39f3
46 changes: 46 additions & 0 deletions midipush.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <alsa/asoundlib.h>
#include <stdio.h>
#include <stdint.h>

#include "dtask.h"

#ifndef DTASK_GEN
#include "midi_tasks.h"
#endif

static midi_tasks_state_t state = DTASK_STATE(midi_tasks, 0, 0);
static dtask_set_t initial = 0;


int main(int argc, char *argv[]) {
int status;
snd_rawmidi_t *midiin = NULL;
const char *portname = "hw:1,0,0";
if ((argc > 1) && (strncmp("hw:", argv[1], 3) == 0)) {
portname = argv[1];
}
if ((status = snd_rawmidi_open(&midiin, NULL, portname, SND_RAWMIDI_SYNC)) < 0) {
printf("Problem opening MIDI input: %s\n", snd_strerror(status));
exit(1);
}

char c;
while(true) {
if ((status = snd_rawmidi_read(midiin, &c, 1)) < 0) {
printf("Problem reading MIDI input: %s\n", snd_strerror(status));
}
if ((unsigned char)c >= 0x80) { // command byte: print in hex
printf("0x%x ", (unsigned char)buffer[0]);
} else {
printf("%d ", (unsigned char)buffer[0]);
}
fflush(stdout);
if (count % 20 == 0) { // print a newline to avoid line-wrapping
printf("\n");
}
}

snd_rawmidi_close(midiin);
midiin = NULL; // snd_rawmidi_close() does not clear invalid pointer,
return 0; // so might be a good idea to erase it after closing.
}
41 changes: 0 additions & 41 deletions midipush.cpp

This file was deleted.

0 comments on commit 7770923

Please sign in to comment.