@@ -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
2323UMC1820_DEV ?= hw:UMC1820,0
2424UMC1820_PLUG_DEV ?= plughw:UMC1820,0
@@ -126,8 +126,41 @@ echo "Recording $$device for $$seconds seconds to $(ALSA_ARECORD_TEMPLATE)"; \
126126arecord -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
132165run-umc1820 :
133166 ALSA_CAPTURE_DEVICE=plughw:UMC1820,0 AUDIO_PLAYBACK_DEV=plughw:UMC1820,0 BPM=$(BPM ) $(MAKE ) run
0 commit comments