Skip to content

Commit add5b5b

Browse files
committed
trying to record
1 parent 19c19fe commit add5b5b

5 files changed

Lines changed: 375 additions & 60 deletions

File tree

Makefile

Lines changed: 14 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 run-oxi run-bind run-direct-test deps play-wavs umc1820-hw-params umc1820-record umc1820-record-stereo umc1820-mixer
21+
.PHONY: run build test check fmt clippy doc lint clean ci clean_log list-devices followlog run-oxi run-bind run-direct-test deps play-wavs sample-wav umc1820-hw-params umc1820-record umc1820-record-stereo umc1820-mixer
2222

2323
UMC1820_DEV ?= hw:UMC1820,0
2424
UMC1820_PLUG_DEV ?= plughw:UMC1820,0
@@ -28,6 +28,10 @@ UMC1820_CHANNELS ?= 18
2828
UMC1820_SECONDS ?= 30
2929
UMC1820_OUT ?= wav_files/umc1820_$(UMC1820_CHANNELS)ch_$(UMC1820_RATE)Hz.wav
3030

31+
# Audio monitor/capture devices used by the runtime (ALSA -D arguments)
32+
AUDIO_CAPTURE_DEV ?= default
33+
AUDIO_PLAYBACK_DEV ?= default
34+
3135
deps:
3236
@if command -v pkg-config >/dev/null 2>&1 && pkg-config --exists alsa; then \
3337
echo "ALSA development libraries already installed"; \
@@ -47,7 +51,7 @@ deps:
4751

4852
# Main targets
4953
run: deps clean_log build
50-
$(CARGO) run
54+
PHASOR_ALSA_CAPTURE_DEVICE="$(AUDIO_CAPTURE_DEV)" PHASOR_ALSA_PLAYBACK_DEVICE="$(AUDIO_PLAYBACK_DEV)" $(CARGO) run
5155

5256
run-oxi: deps clean_log build
5357
$(CARGO) run -- --bind-to-device "OXI ONE:OXI ONE MIDI 1 20:0"
@@ -116,10 +120,14 @@ play-wavs: deps
116120
fi; \
117121
for f in $$files; do \
118122
echo "Playing $$f"; \
119-
aplay "$$f"; \
123+
aplay -D "$(AUDIO_PLAYBACK_DEV)" "$$f"; \
120124
done
121125
$(call success)
122126

127+
sample-wav:
128+
@python3 -c 'import os, math, struct, wave; os.makedirs("wav_files", exist_ok=True); sr=44100; dur=1.0; freq=440.0; amp=0.2; n=int(sr*dur); frames=b"".join(struct.pack("<hh", int(amp*32767*math.sin(2*math.pi*freq*i/sr)), int(amp*32767*math.sin(2*math.pi*freq*i/sr))) for i in range(n)); w=wave.open("wav_files/sample.wav","wb"); w.setnchannels(2); w.setsampwidth(2); w.setframerate(sr); w.writeframes(frames); w.close()'
129+
$(call success)
130+
123131
test: clippy
124132
$(CARGO) test
125133
$(call success)
@@ -158,3 +166,6 @@ clean::
158166
clean_log:
159167
> app.log
160168
$(call success)
169+
170+
followlog:
171+
tail -n 200 -f app.log

0 commit comments

Comments
 (0)