From d18c5aff575d781901459970e2853af5a73a51fc Mon Sep 17 00:00:00 2001 From: dvs1 Date: Thu, 31 Oct 2024 21:31:54 +1000 Subject: Various failed attempts to get ALSA stuff to talk to a particular sub device. --- aataaj.lua | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/aataaj.lua b/aataaj.lua index 5f043a7..ce691fa 100755 --- a/aataaj.lua +++ b/aataaj.lua @@ -160,7 +160,7 @@ for i,l in ipairs(cards.lines) do local m = c:match('.*pcm(%d+).*') Cards[n]['captureDevs'][j] = m Cards[n]['devs'][m] = m - print('\tFound capture device: ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['captureDevs'][j] .. ' ' .. m) + print('\tFound capture device: ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['captureDevs'][j] .. ', sub device ' .. m) -- io.flush() end Cards[n]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() @@ -168,7 +168,7 @@ for i,l in ipairs(cards.lines) do local m = p:match('.*pcm(%d+).*') Cards[n]['playbackDevs'][j] = m Cards[n]['devs'][m] = m - print('\tFound playback device ' .. Cards[n].card - 1 .. ' : ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['playbackDevs'][j] .. ' ' .. m) + print('\tFound playback device ' .. Cards[n].card - 1 .. ' : ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['playbackDevs'][j] .. ', sub device ' .. m) -- io.flush() if 'JACK' ~= arg[1] then -- print('\t\tALSA_CARD=' .. Cards[n].card - 1 .. ' ' .. speaker .. ' "Found playback device ' .. Cards[n].card - 1 .. ' : ' .. Cards[n]['name'] .. ' DEVICE: ' .. Cards[n]['playbackDevs'][j] .. ' ' .. m .. '"') @@ -185,13 +185,18 @@ io.flush() local speak = function(card, subdevice, device, words, printIt, forkIt) - if printIt then print(words) end - if forkIt then - __('#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -d ' .. card .. subdevice):noErr():noOut():fork() - else - __('#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -d ' .. card .. subdevice):noErr():noOut():Do() - end --- io.flush() +-- local file = os.tmpname() +-- D('Creating temporary script file at ' .. file) + local s = '#!/bin/bash\necho "' .. words .. '" | ALSA_CARD=' .. device .. ' ' .. speaker +-- local s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -d ' .. device +-- local s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -w ' .. file .. ' ; aplay -q --device=hw:CARD=' .. card .. ',DEV=' .. subdevice .. ' ' .. file + if printIt then print(words) end + if forkIt then + __(s):noErr():noOut():fork() + else + __(s):noErr():noOut():Do() + end +-- io.flush() end if 'start' == arg[1] then @@ -205,7 +210,7 @@ if 'start' == arg[1] then __'sleep 6':Do() for k,C in pairs(Cards) do for j,c in ipairs(C['playbackDevs']) do - speak(C.name, C['playbackDevs'][j], C.card - 1, 'Device number ' .. C.card - 1 .. ', ' .. C['playbackDevs'][j] .. ' : ' .. C.name, true, false) + speak(C.name, C['playbackDevs'][j], C.card - 1, 'Device number ' .. C.card - 1 .. ', sub device ' .. C['playbackDevs'][j] .. ' : ' .. C.name, true, false) end __'sleep 1':Do() end @@ -217,6 +222,7 @@ if 'start' == arg[1] then speak(C.name, C['playbackDevs'][j], C.card - 1, 'Please type the device number you heard best - ', false, true) end end + local choice = tonumber(io.read()) -- Lua has no way of just checking IF there is ANY input, so can't do "check if there was a keypress, continue if not". local ourCard = '' -- cgit v1.1