Skip to content

Commit 68703d3

Browse files
committed
record statically
1 parent 2dcdc87 commit 68703d3

2 files changed

Lines changed: 37 additions & 3 deletions

File tree

Makefile

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CARGO ?= cargo
1818

1919
# Targets
2020

21-
.PHONY: run build test check fmt clippy doc lint clean ci clean_log list-devices followlog user-shell run-oxi run-bind run-direct-test deps play-wavs sample-wav umc1820-hw-params umc1820-record umc1820-record-stereo umc1820-mixer arecord-app-capture arecord-umc1820 run-umc1820
21+
.PHONY: run build test check fmt clippy doc lint clean ci clean_log list-devices followlog user-shell run-oxi run-bind run-direct-test deps play-wavs sample-wav umc1820-hw-params umc1820-record umc1820-record-stereo umc1820-mixer arecord-app-capture arecord-umc1820 record run-umc1820
2222

2323
UMC1820_DEV ?= hw:UMC1820,0
2424
UMC1820_PLUG_DEV ?= plughw:UMC1820,0
@@ -126,8 +126,41 @@ echo "Recording $$device for $$seconds seconds to $(ALSA_ARECORD_TEMPLATE)"; \
126126
arecord -D "$$device" -f $(ALSA_ARECORD_FORMAT) -r $(ALSA_ARECORD_SAMPLE_RATE) -c $(ALSA_ARECORD_CHANNELS) -t wav -N --use-strftime -d "$$seconds" "$(ALSA_ARECORD_TEMPLATE)"
127127
$(call success)
128128

129-
arecord-umc1820:
130-
ALSA_CAPTURE_DEVICE=plughw:UMC1820,0 ALSA_CAPTURE_STEREO_PAIR=1 $(MAKE) arecord-app-capture
129+
arecord-umc1820: record
130+
131+
record: deps
132+
@mkdir -p wav_files
133+
@if [ ! -t 0 ]; then \
134+
echo "error: this target needs an interactive terminal (stdin)"; \
135+
exit 1; \
136+
fi
137+
@device="$(UMC1820_PLUG_DEV)"; \
138+
if [ -z "$$device" ]; then \
139+
echo "error: UMC1820_PLUG_DEV is empty"; \
140+
exit 1; \
141+
fi; \
142+
echo ""; \
143+
echo "Recording from $$device to $(ALSA_ARECORD_TEMPLATE)"; \
144+
echo "Press Enter to stop and finalize the WAV file."; \
145+
arecord -D "$$device" -f $(ALSA_ARECORD_FORMAT) -r $(ALSA_ARECORD_SAMPLE_RATE) -c $(ALSA_ARECORD_CHANNELS) -t wav -N --use-strftime "$(ALSA_ARECORD_TEMPLATE)" & \
146+
pid=$$!; \
147+
sleep 0.1; \
148+
if ! kill -0 $$pid 2>/dev/null; then \
149+
wait $$pid; \
150+
rc=$$?; \
151+
echo "arecord exited immediately with status $$rc"; \
152+
exit $$rc; \
153+
fi; \
154+
read -r _; \
155+
echo "Stopping..."; \
156+
if kill -0 $$pid 2>/dev/null; then kill -TERM $$pid; fi; \
157+
wait $$pid; \
158+
rc=$$?; \
159+
if [ $$rc -ne 0 ] && [ $$rc -ne 143 ]; then \
160+
echo "arecord exited with status $$rc"; \
161+
exit $$rc; \
162+
fi
163+
$(call success)
131164

132165
run-umc1820:
133166
ALSA_CAPTURE_DEVICE=plughw:UMC1820,0 AUDIO_PLAYBACK_DEV=plughw:UMC1820,0 BPM=$(BPM) $(MAKE) run

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ make run-bind MIDI_IN="UMC1820"
5353

5454
# UMC1820 helpers (recordings land in wav_files/, which is gitignored)
5555
make umc1820-hw-params
56+
make record # press Enter to stop
5657
make umc1820-record UMC1820_SECONDS=5
5758
make umc1820-record-stereo UMC1820_SECONDS=5
5859
```

0 commit comments

Comments
 (0)