From 88c27e8b3aed4c5dbf0b17d34181f52034d7d706 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Fri, 17 Jan 2025 10:31:05 +0100 Subject: [PATCH] add opus output --- Makefile | 28 ++++++++++++++++++++-------- flake.nix | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 4265be2..d538380 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ BUILD_DIR=build SONG_DIR=${SRC_DIR}/songs BUILD_SONG_DIR=${BUILD_DIR}/songs BUILD_BOOK_DIR=${BUILD_DIR}/book +BUILD_OPUS_DIR=${BUILD_DIR}/opus BOOK_FULL=$(BUILD_BOOK_DIR)/full.pdf BOOKLET=$(BUILD_BOOK_DIR)/booklet.pdf @@ -14,11 +15,13 @@ TYP_FILES=$(wildcard ${SONG_DIR}/*.typ) LY_FILES=$(wildcard ${SONG_DIR}/*.ly) LY_PDFS=$(patsubst %.ly,${BUILD_SONG_DIR}/%.pdf,$(notdir ${LY_FILES})) LY_SVGS=$(patsubst %.ly,${BUILD_SONG_DIR}/%.svg,$(notdir ${LY_FILES})) +LY_OPUS=$(patsubst %.ly,${BUILD_OPUS_DIR}/%.opus,$(notdir ${LY_FILES})) -.PHONY: clean directories all +.PHONY: clean book opus all .DEFAULT_GOAL := all -directories: $(BUILD_DIR) $(BUILD_SONG_DIR) $(BUILD_BOOK_DIR) +book: $(BOOK_FULL) $(BOOKLET) $(LY_SVGS) $(GENERATED_SONGS) +opus: $(LY_OPUS) $(BUILD_DIR): mkdir -p $(BUILD_DIR) @@ -26,26 +29,35 @@ $(BUILD_DIR): $(BUILD_SONG_DIR): mkdir -p $(BUILD_SONG_DIR) +$(BUILD_OPUS_DIR): + mkdir -p $(BUILD_OPUS_DIR) + $(BUILD_BOOK_DIR): mkdir -p $(BUILD_BOOK_DIR) $(GENERATED_SONGS): $(LY_FILES) $(TYP_FILES) bin/generate -$(BUILD_SONG_DIR)/%.pdf: $(SONG_DIR)/%.ly $(SRC_DIR)/setup.ly - lilypond --pdf -o $(basename $@) $< +$(BUILD_SONG_DIR)/%.pdf: $(SONG_DIR)/%.ly $(SRC_DIR)/setup.ly | $(BUILD_SONG_DIR) + lilypond --pdf -o $(basename $@) $< pdfcrop $@ $@ -$(BUILD_SONG_DIR)/%.svg: $(BUILD_SONG_DIR)/%.pdf +$(BUILD_SONG_DIR)/%-1.midi: $(SONG_DIR)/%.ly $(SRC_DIR)/setup.ly | $(BUILD_SONG_DIR) + lilypond -o $(BUILD_SONG_DIR)/$* $< + +$(BUILD_SONG_DIR)/%.svg: $(BUILD_SONG_DIR)/%.pdf | $(BUILD_SONG_DIR) pdftocairo -svg $< $@ -$(BOOK_FULL): $(TYP_FILES) $(LY_SVGS) $(GENERATED_SONGS) $(SRC_DIR)/singalongs.typ $(SRC_DIR)/song.typ +${BUILD_OPUS_DIR}/%.opus: $(BUILD_SONG_DIR)/%-1.midi | $(BUILD_OPUS_DIR) + timidity $< -Ow -o - | opusenc - $@ + +$(BOOK_FULL): $(TYP_FILES) $(LY_SVGS) $(GENERATED_SONGS) $(SRC_DIR)/singalongs.typ $(SRC_DIR)/song.typ | $(BUILD_BOOK_DIR) typst compile --root $(WORKING_DIR) $(SRC_DIR)/singalongs.typ $@ $(BOOKLET): $(BOOK_FULL) - pdfbook2 --short-edge $< + pdfjam --booklet true --a4paper --outfile $@ $< -all: directories $(BOOK_FULL) $(BOOKLET) $(LY_SVGS) $(GENERATED_SONGS) +all: book opus clean: rm -rf $(BUILD_DIR) diff --git a/flake.nix b/flake.nix index 0e4fc53..b93a410 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,7 @@ with pkgs; mkShell { buildInputs = [ - texlivePackages.pdfbook2 + texlivePackages.pdfjam lilypond-with-fonts poppler_utils gnumake