From 411de7614e07690edf2593d6cc98b9271636ffbe Mon Sep 17 00:00:00 2001 From: dvs1 Date: Fri, 21 Nov 2025 16:21:42 +1000 Subject: Clean up. --- aataaj.lua | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'aataaj.lua') diff --git a/aataaj.lua b/aataaj.lua index 2c6058d..9542fa6 100755 --- a/aataaj.lua +++ b/aataaj.lua @@ -185,7 +185,6 @@ for i,l in ipairs(cards.lines) do Cards[n]['captureDevs'][j] = m Cards[n]['devs'][m] = m ---- print('Found capture DEVICE: ' .. Cards[n].card - 1 .. '\tSUB: ' .. m .. ' \t' .. Cards[n]['name']) --- io.flush() end Cards[n]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() for j,p in ipairs(Cards[n]['playback'].lines) do @@ -193,7 +192,6 @@ for i,l in ipairs(cards.lines) do Cards[n]['playbackDevs'][j] = m Cards[n]['devs'][m] = m print('Found playback DEVICE: ' .. Cards[n].card - 1 .. '\tSUB: ' .. m .. ' \t' .. Cards[n]['name']) --- io.flush() if 'JACK' ~= cmd 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 .. '"') -- io.flush() @@ -215,10 +213,11 @@ for i,l in ipairs(cards.lines) do end end end ---table.sort(Cards, function(a, b) return a.card < b.card end) print('') io.flush() + + local speak = function(card, subdevice, device, words, printIt, forkIt, ...) local files = {...} local s = '' @@ -226,11 +225,7 @@ local speak = function(card, subdevice, device, words, printIt, forkIt, ...) if 0 == #files then local file = os.tmpname() .. '.wav' D('Creating temporary script file at ' .. file) --- s = '#!/bin/bash\necho "' .. words .. '" | ALSA_CARD=' .. device .. ' ' .. speaker --- s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -d hw:' .. device .. subdevice s = '#!/bin/bash\n' .. speaker .. ' -d hw:' .. device .. subdevice .. ' "' .. words .. '"' --- s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -w ' .. file .. ' ; aplay --device=hw:' .. device .. subdevice .. ' ' .. file --- s = '#!/bin/bash\n' .. speaker .. ' -w ' .. file .. ' "' .. words .. '" ; aplay --device=hw:' .. device .. subdevice .. ' ' .. file else s = 'aplay -q --device=hw:' .. device .. subdevice for i, v in ipairs(files) do s = s .. ' /usr/local/share/doc/aataaj/' .. v .. '.wav' end @@ -241,15 +236,13 @@ local speak = function(card, subdevice, device, words, printIt, forkIt, ...) else __(s):Do() end --- io.flush() end -- TODO - Start with the device, then go through the sub devices. Coz at boot time subs don't seem to work. -- Likely that'll lock things up at "all speak at once" time. if 'start' == cmd then print('Your ' .. cnt .. ' audio devices are - ') - -print(' being turned on and volume maxed - ') + print(' being turned on and volume maxed - ') for k = 0, cnt do -- Turn on IEC958 for everything, they seem to default to off, so can't hear them. for l, m in ipairs(__("amixer -c " .. k .. " scontrols | grep 'IEC958' | cut -d ',' -f 2"):noErr():Do().lines) do @@ -261,20 +254,18 @@ print(' being turned on and volume maxed - ') end end -print(' being spoken through all at once - ') + print(' being spoken through all at once - ') for k,C in pairs(Cards) do for j,c in ipairs(C['playbackDevs']) do ----- speak(C.name, nil, C.card - 1, 'Your ' .. cnt .. ' audio devices are - ', false, true, 'your', numbers[cnt], 'devices') speak(C.name, C['playbackDevs'][j], C.card - 1, 'Your ' .. cnt .. ' audio devices are - ', false, true, 'your', numbers[cnt], 'devices') end 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(' being spoken through one at a time - ') + print(' being spoken through one at a time - ') for k,n in ipairs(Names) do C = Cards[n] for j,c in ipairs(C['playbackDevs']) do ----- speak(C.name, nil, C.card - 1, 'Device number ' .. C.card - 1 .. ', sub device ' .. C['playbackDevs'][j], false, false, 'device', numbers[C.card - 1], 'sub', numbers[tonumber(C['playbackDevs'][j])]) speak(C.name, C['playbackDevs'][j], C.card - 1, 'Device number ' .. C.card - 1 .. ', sub device ' .. C['playbackDevs'][j], true, false, 'device', numbers[C.card - 1], 'sub', numbers[tonumber(C['playbackDevs'][j])]) end __'sleep 1':Do() @@ -284,7 +275,6 @@ print(' being spoken through one at a time - ') print('Please type the device number you heard best - ') for k,C in pairs(Cards) do for j,c in ipairs(C['playbackDevs']) do ----- speak(C.name, nil, C.card - 1, 'Please type the device number you heard best - ', false, true, 'best') speak(C.name, C['playbackDevs'][j], C.card - 1, 'Please type the device number you heard best - ', false, true, 'best') end end @@ -301,9 +291,6 @@ print(' being spoken through one at a time - ') ---os.exit(true) - - __('mkdir -p ' .. options.asoundrcPath.value):Do() local a, e = io.open(options.asoundrcPath.value .. '/jack-plumbing', 'w') if nil == a then print('Could not open ' .. options.asoundrcPath.value .. '/jack-plumbing - ' .. e) else -- cgit v1.1