From 78299bee93453b5b02fa0a833f93798c4f61066a Mon Sep 17 00:00:00 2001 From: dvs1 Date: Thu, 24 Oct 2024 12:37:14 +1000 Subject: Split up the audio output a little nicer. --- aataaj.lua | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'aataaj.lua') diff --git a/aataaj.lua b/aataaj.lua index 5357ac9..e7bb492 100755 --- a/aataaj.lua +++ b/aataaj.lua @@ -226,7 +226,7 @@ local cards = __'ls -d1 /proc/asound/card[0-9]*':noErr():Do() for i,l in ipairs(cards.lines) do local f, e = io.open(l .. '/id', "r") if nil == f then print("Could not open " .. l .. '/id') else - Cards[l] = {path = l, name = f:read("*a"):sub(1, -2), devs = {}, captureDevs = {}, playbackDevs = {}} + Cards[l] = {path = l, name = f:read("*a"):sub(1, -2), devs = {}, captureDevs = {}, playbackDevs = {}, card=i} if "Loopback" ~= Cards[l]['name'] then Cards[l]['capture'] = __('ls -d1 ' .. l .. '/pcm[0-9]*c*'):noErr():Do() for j,c in ipairs(Cards[l]['capture'].lines) do @@ -234,22 +234,51 @@ for i,l in ipairs(cards.lines) do Cards[l]['captureDevs'][j] = n Cards[l]['devs'][n] = n print("\tFound capture device: " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['captureDevs'][j] .. ' ' .. n) + io.flush() end Cards[l]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() for j,p in ipairs(Cards[l]['playback'].lines) do local n = p:match(".*pcm(%d+).*") Cards[l]['playbackDevs'][j] = n Cards[l]['devs'][n] = n - print("\tFound playback device " .. i - 1 .. " : " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['playbackDevs'][j] .. ' ' .. n) + print("\tFound playback device " .. Cards[l].card - 1 .. " : " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['playbackDevs'][j] .. ' ' .. n) + io.flush() if 'JACK' ~= args[1] then - print('\t\tALSA_CARD=' .. i - 1 .. ' ' .. speaker .. ' "Found playback device ' .. i - 1 .. ' : ' .. Cards[l]['name'] .. ' DEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n .. '"') - __('ALSA_CARD=' .. i - 1 .. ' ' .. speaker .. ' "Found playback device ' .. i - 1 .. ' : ' .. Cards[l]['name'] .. ' DEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n .. '"'):noErr():noOut():Do() - __'sleep 1':Do() + print('\t\tALSA_CARD=' .. Cards[l].card - 1 .. ' ' .. speaker .. ' "Found playback device ' .. Cards[l].card - 1 .. ' : ' .. Cards[l]['name'] .. ' DEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n .. '"') + io.flush() end end end end end +print('') +io.flush() + +-- TODO - No idea why the fuck #Cards kept telling me 0. +local cnt = 0 +for i,C in pairs(Cards) do + cnt = cnt + 1 +end + +print('Your ' .. cnt .. ' audio devices are ') +for i,C in pairs(Cards) do + print('' .. C.card - 1 .. ' : ' .. C.name) + __('ALSA_CARD=' .. C.card - 1 .. ' ' .. speaker .. ' "Your ' .. cnt .. ' audio devices are "'):log():noErr():noOut():fork() +end +-- TODO - should do a proper "wait for speakers to finish" here. Have fork(write a file), think that's what :wait(file) does. +__'sleep 6':Do() +print('') +io.flush() +for i,C in pairs(Cards) do + print('' .. C.card - 1 .. ' : ' .. C.name) + __('echo "' .. C.card - 1 .. ' : ' .. C.name .. '"') + __('ALSA_CARD=' .. C.card - 1 .. ' ' .. speaker .. ' "Device ' .. C.card - 1 .. ' ' .. C.name .. '"'):log():noErr():noOut():Do() + io.flush() + __'sleep 1':Do() +end +print('') +io.flush() + if 'start' == args[1] then __('mkdir -p ' .. asoundrcPath):Do() -- cgit v1.1