From 4edd85aa8156150f1fa7a3026a922b49366b642d Mon Sep 17 00:00:00 2001 From: dvs1 Date: Mon, 28 Oct 2024 10:30:16 +1000 Subject: Consistantly use single quotes for Lua strings, unless otherwise needed. Old habits die hard. lol --- aataaj.lua | 92 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'aataaj.lua') diff --git a/aataaj.lua b/aataaj.lua index 88eb346..5656427 100755 --- a/aataaj.lua +++ b/aataaj.lua @@ -116,8 +116,8 @@ local options = _.killEmAll{'jmcore', 'qjackctl'} -- Catia is python, and no easy way to kill it. -- Also it keeps jackdbus alive, no matter how hard you kill it. - __"pkill -TERM -u $USER -f catia":Do() - __"sleep 2":Do() + __'pkill -TERM -u $USER -f catia':Do() + __'sleep 2':Do() _.killEmAll{'jackdbus', 'a2jmidid'} os.exit(0) end @@ -145,24 +145,24 @@ local Cards = {} print('Scanning for audio devices.') 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 = {}, card=i} - if "Loopback" ~= Cards[l]['name'] then + 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 = {}, 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 - local n = c:match(".*pcm(%d+).*") + local n = c:match('.*pcm(%d+).*') Cards[l]['captureDevs'][j] = n Cards[l]['devs'][n] = n - print("\tFound capture device: " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['captureDevs'][j] .. ' ' .. 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+).*") + local n = p:match('.*pcm(%d+).*') Cards[l]['playbackDevs'][j] = n Cards[l]['devs'][n] = n - print("\tFound playback device " .. Cards[l].card - 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' ~= arg[1] then 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 .. '"') @@ -203,8 +203,8 @@ io.flush() if 'start' == arg[1] then __('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') else + local a, e = io.open(options.asoundrcPath.value .. '/jack-plumbing', 'w') + if nil == a then print('Could not open ' .. options.asoundrcPath.value .. '/jack-plumbing') else a:write([[ (connect "system:capture_1" "ploop:playback_1") (connect "system:capture_2" "ploop:playback_2") @@ -218,20 +218,20 @@ if 'start' == arg[1] then ]]) a:close() end - local a, e = io.open(options.asoundrcPath.value .. '/' .. options.asoundrc.value, "w") - if nil == a then print("Could not open " .. options.asoundrcPath.value .. '/' .. options.asoundrc.value) else + local a, e = io.open(options.asoundrcPath.value .. '/' .. options.asoundrc.value, 'w') + if nil == a then print('Could not open ' .. options.asoundrcPath.value .. '/' .. options.asoundrc.value) else for i,C in pairs(Cards) do for j,c in pairs(C['devs']) do - a:write("pcm." .. C['name'] .. j .. " {\n") - a:write(" type hw\n") - a:write(" card " .. C['name'] .. "\n") - a:write(" device " .. C['devs'][j] .. "\n") - a:write("}\n") - a:write("ctl." .. C['name'] .. j .. " {\n") - a:write(" type hw\n") - a:write(" card " .. C['name'] .. "\n") - a:write(" device " .. C['devs'][j] .. "\n") - a:write("}\n\n") + a:write('pcm.' .. C['name'] .. j .. ' {\n') + a:write(' type hw\n') + a:write(' card ' .. C['name'] .. '\n') + a:write(' device ' .. C['devs'][j] .. '\n') + a:write('}\n') + a:write('ctl.' .. C['name'] .. j .. ' {\n') + a:write(' type hw\n') + a:write(' card ' .. C['name'] .. '\n') + a:write(' device ' .. C['devs'][j] .. '\n') + a:write('}\n\n') end end a:write([[ @@ -373,13 +373,13 @@ pcm.!default { end elseif 'JACK' == arg[1] then print('') - print("Start up JACK and friends.") - print("jack_control") + print('Start up JACK and friends.') + print('jack_control') __[[jack_control start jack_control ds alsa]]:Do() --jack_control dps device hw:RIG,0 while 0 ~= __'jack_control status':Do().status do - print("Waiting for JACK") + print('Waiting for JACK') __'sleep 1':Do() end if nil ~= GUI then @@ -387,7 +387,7 @@ elseif 'JACK' == arg[1] then __(GUI):forkOnce() end if _.runnable'jack-plumbing' then - print("jack-plumbing") + print('jack-plumbing') __'jack-plumbing -o /var/lib/aataaj/jack-plumbing 2>/dev/null':fork() end if _.runnable'a2j_control' then @@ -396,72 +396,72 @@ elseif 'JACK' == arg[1] then --a2j_control actually starts a2jmidid. ----a2jmidid -e -u & -- I think the jack_control start and my current alsa config means a2jmidid gets started anyway. But seem to need this bit to get the joystick covered. - print("a2j_control") + print('a2j_control') __'a2j_control --ehw && a2j_control --start':Do() --- print("sleep 2") +-- print('sleep 2') -- __('sleep 2'):Do() print("") end - local AIN = "alsa_in" + local AIN = 'alsa_in' if _.runnable'zita-a2j' then AIN = 'zita-a2j' end - local AOUT = "alsa_out" + local AOUT = 'alsa_out' if _.runnable'zita-j2a' then AOUT = 'zita-j2a' end - print("Basic ALSA sound devices converted to JACK.") + print('Basic ALSA sound devices converted to JACK.') for i,C in pairs(options.aliases.value) do print('HW playback: ' .. C['name'] .. '\tDEVICE: ' .. C['dev']) __(AOUT .. ' -j ' .. C['name'] .. ' -d ' .. C['dev']):fork() end - print("HW playback: cloop\tDEVICE: cloop") + print('HW playback: cloop\tDEVICE: cloop') -- No idea why, cloop wont work with zita-a2j. __'alsa_in -j cloop -d cloop':fork() --__[[sleep 1 -- jack_connect cloop:capture_1 system:playback_1o() -- jack_connect cloop:capture_2 system:playback_2]]:Do() - print("HW playback: ploop\tDEVICE: ploop") + print('HW playback: ploop\tDEVICE: ploop') __'alsa_out -j ploop -d ploop':fork() --__[[sleep 1 -- jack_connect system:capture_1 ploop:playback_1 -- jack_connect system:capture_2 ploop:playback_2]]:Do() - print("") + print('') - print("Rest of ALSA sound devices converted to JACK.") + print('Rest of ALSA sound devices converted to JACK.') for i,C in pairs(Cards) do for j,c in ipairs(C['playbackDevs']) do - print("HW playback: " .. C['name'] .. "\tDEVICE: " .. C['playbackDevs'][j]) - __(AOUT .. ' -j ' .. C['name'] .. "_" .. C['playbackDevs'][j] .. '-in -d ' .. C['name'] .. C['playbackDevs'][j]):fork() + print('HW playback: ' .. C['name'] .. '\tDEVICE: ' .. C['playbackDevs'][j]) + __(AOUT .. ' -j ' .. C['name'] .. '_' .. C['playbackDevs'][j] .. '-in -d ' .. C['name'] .. C['playbackDevs'][j]):fork() -- __'sleep 1':Do() -- __('jack_connect cloop:capture_1 ' .. C['name'] .. '_' .. C['playbackDevs'][j] .. '-in' .. ':playback_1'):Do() -- __('jack_connect cloop:capture_2 ' .. C['name'] .. '_' .. C['playbackDevs'][j] .. '-in' .. ':playback_2'):Do() end for j,c in ipairs(C['captureDevs']) do - print("HW capture: " .. C['name'] .. "\tDEVICE: " .. C['captureDevs'][j]) - __(AIN .. ' -j ' .. C['name'] .. "_" .. C['captureDevs'][j] .. '-out -d ' .. C['name'] .. C['captureDevs'][j]):fork() + print('HW capture: ' .. C['name'] .. '\tDEVICE: ' .. C['captureDevs'][j]) + __(AIN .. ' -j ' .. C['name'] .. '_' .. C['captureDevs'][j] .. '-out -d ' .. C['name'] .. C['captureDevs'][j]):fork() end end - print("") + print('') if _.runnable('aseqjoy') then - print("Scanning for joysticks.") + print('Scanning for joysticks.') local sticks = __'ls -1 /dev/input/js[0-9]*':noErr():Do() for i,l in ipairs(sticks.lines) do - print("aseqjoy " .. l) + print('aseqjoy ' .. l) -- Buttons switch to that numbered MIDI channel, defaults to 1. -- Axis are mapped to MIDI controllers 10 - 15 -- -r means to use high resolution MIDI values. __('aseqjoy -d ' .. l:sub(-1,-1) .. ' -r'):fork() end - print("") + print('') end if _.runnable('jack-plumbing') then print('Stop our jack-plumbing, eventually.') __'sleep 4':Do() - _.killEmAll{"jack-plumbing"} + _.killEmAll{'jack-plumbing'} end if _.runnable('~/.aataaj_JACK.lua') then -- cgit v1.1