aboutsummaryrefslogtreecommitdiffstats
path: root/aataaj.lua
diff options
context:
space:
mode:
Diffstat (limited to 'aataaj.lua')
-rwxr-xr-xaataaj.lua92
1 files changed, 46 insertions, 46 deletions
diff --git a/aataaj.lua b/aataaj.lua
index 88eb346..5656427 100755
--- a/aataaj.lua
+++ b/aataaj.lua
@@ -116,8 +116,8 @@ local options =
116 _.killEmAll{'jmcore', 'qjackctl'} 116 _.killEmAll{'jmcore', 'qjackctl'}
117 -- Catia is python, and no easy way to kill it. 117 -- Catia is python, and no easy way to kill it.
118 -- Also it keeps jackdbus alive, no matter how hard you kill it. 118 -- Also it keeps jackdbus alive, no matter how hard you kill it.
119 __"pkill -TERM -u $USER -f catia":Do() 119 __'pkill -TERM -u $USER -f catia':Do()
120 __"sleep 2":Do() 120 __'sleep 2':Do()
121 _.killEmAll{'jackdbus', 'a2jmidid'} 121 _.killEmAll{'jackdbus', 'a2jmidid'}
122 os.exit(0) 122 os.exit(0)
123 end 123 end
@@ -145,24 +145,24 @@ local Cards = {}
145print('Scanning for audio devices.') 145print('Scanning for audio devices.')
146local cards = __'ls -d1 /proc/asound/card[0-9]*':noErr():Do() 146local cards = __'ls -d1 /proc/asound/card[0-9]*':noErr():Do()
147for i,l in ipairs(cards.lines) do 147for i,l in ipairs(cards.lines) do
148 local f, e = io.open(l .. '/id', "r") 148 local f, e = io.open(l .. '/id', 'r')
149 if nil == f then print("Could not open " .. l .. '/id') else 149 if nil == f then print('Could not open ' .. l .. '/id') else
150 Cards[l] = {path = l, name = f:read("*a"):sub(1, -2), devs = {}, captureDevs = {}, playbackDevs = {}, card=i} 150 Cards[l] = {path = l, name = f:read('*a'):sub(1, -2), devs = {}, captureDevs = {}, playbackDevs = {}, card=i}
151 if "Loopback" ~= Cards[l]['name'] then 151 if 'Loopback' ~= Cards[l]['name'] then
152 Cards[l]['capture'] = __('ls -d1 ' .. l .. '/pcm[0-9]*c*'):noErr():Do() 152 Cards[l]['capture'] = __('ls -d1 ' .. l .. '/pcm[0-9]*c*'):noErr():Do()
153 for j,c in ipairs(Cards[l]['capture'].lines) do 153 for j,c in ipairs(Cards[l]['capture'].lines) do
154 local n = c:match(".*pcm(%d+).*") 154 local n = c:match('.*pcm(%d+).*')
155 Cards[l]['captureDevs'][j] = n 155 Cards[l]['captureDevs'][j] = n
156 Cards[l]['devs'][n] = n 156 Cards[l]['devs'][n] = n
157 print("\tFound capture device: " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['captureDevs'][j] .. ' ' .. n) 157 print('\tFound capture device: ' .. Cards[l]['name'] .. '\tDEVICE: ' .. Cards[l]['captureDevs'][j] .. ' ' .. n)
158 io.flush() 158 io.flush()
159 end 159 end
160 Cards[l]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() 160 Cards[l]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do()
161 for j,p in ipairs(Cards[l]['playback'].lines) do 161 for j,p in ipairs(Cards[l]['playback'].lines) do
162 local n = p:match(".*pcm(%d+).*") 162 local n = p:match('.*pcm(%d+).*')
163 Cards[l]['playbackDevs'][j] = n 163 Cards[l]['playbackDevs'][j] = n
164 Cards[l]['devs'][n] = n 164 Cards[l]['devs'][n] = n
165 print("\tFound playback device " .. Cards[l].card - 1 .. " : " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['playbackDevs'][j] .. ' ' .. n) 165 print('\tFound playback device ' .. Cards[l].card - 1 .. ' : ' .. Cards[l]['name'] .. '\tDEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n)
166 io.flush() 166 io.flush()
167 if 'JACK' ~= arg[1] then 167 if 'JACK' ~= arg[1] then
168 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 .. '"') 168 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()
203 203
204if 'start' == arg[1] then 204if 'start' == arg[1] then
205 __('mkdir -p ' .. options.asoundrcPath.value):Do() 205 __('mkdir -p ' .. options.asoundrcPath.value):Do()
206 local a, e = io.open(options.asoundrcPath.value .. '/jack-plumbing', "w") 206 local a, e = io.open(options.asoundrcPath.value .. '/jack-plumbing', 'w')
207 if nil == a then print("Could not open " .. options.asoundrcPath.value .. '/jack-plumbing') else 207 if nil == a then print('Could not open ' .. options.asoundrcPath.value .. '/jack-plumbing') else
208 a:write([[ 208 a:write([[
209(connect "system:capture_1" "ploop:playback_1") 209(connect "system:capture_1" "ploop:playback_1")
210(connect "system:capture_2" "ploop:playback_2") 210(connect "system:capture_2" "ploop:playback_2")
@@ -218,20 +218,20 @@ if 'start' == arg[1] then
218 ]]) 218 ]])
219 a:close() 219 a:close()
220 end 220 end
221 local a, e = io.open(options.asoundrcPath.value .. '/' .. options.asoundrc.value, "w") 221 local a, e = io.open(options.asoundrcPath.value .. '/' .. options.asoundrc.value, 'w')
222 if nil == a then print("Could not open " .. options.asoundrcPath.value .. '/' .. options.asoundrc.value) else 222 if nil == a then print('Could not open ' .. options.asoundrcPath.value .. '/' .. options.asoundrc.value) else
223 for i,C in pairs(Cards) do 223 for i,C in pairs(Cards) do
224 for j,c in pairs(C['devs']) do 224 for j,c in pairs(C['devs']) do
225 a:write("pcm." .. C['name'] .. j .. " {\n") 225 a:write('pcm.' .. C['name'] .. j .. ' {\n')
226 a:write(" type hw\n") 226 a:write(' type hw\n')
227 a:write(" card " .. C['name'] .. "\n") 227 a:write(' card ' .. C['name'] .. '\n')
228 a:write(" device " .. C['devs'][j] .. "\n") 228 a:write(' device ' .. C['devs'][j] .. '\n')
229 a:write("}\n") 229 a:write('}\n')
230 a:write("ctl." .. C['name'] .. j .. " {\n") 230 a:write('ctl.' .. C['name'] .. j .. ' {\n')
231 a:write(" type hw\n") 231 a:write(' type hw\n')
232 a:write(" card " .. C['name'] .. "\n") 232 a:write(' card ' .. C['name'] .. '\n')
233 a:write(" device " .. C['devs'][j] .. "\n") 233 a:write(' device ' .. C['devs'][j] .. '\n')
234 a:write("}\n\n") 234 a:write('}\n\n')
235 end 235 end
236 end 236 end
237 a:write([[ 237 a:write([[
@@ -373,13 +373,13 @@ pcm.!default {
373 end 373 end
374elseif 'JACK' == arg[1] then 374elseif 'JACK' == arg[1] then
375 print('') 375 print('')
376 print("Start up JACK and friends.") 376 print('Start up JACK and friends.')
377 print("jack_control") 377 print('jack_control')
378 __[[jack_control start 378 __[[jack_control start
379 jack_control ds alsa]]:Do() 379 jack_control ds alsa]]:Do()
380 --jack_control dps device hw:RIG,0 380 --jack_control dps device hw:RIG,0
381 while 0 ~= __'jack_control status':Do().status do 381 while 0 ~= __'jack_control status':Do().status do
382 print("Waiting for JACK") 382 print('Waiting for JACK')
383 __'sleep 1':Do() 383 __'sleep 1':Do()
384 end 384 end
385 if nil ~= GUI then 385 if nil ~= GUI then
@@ -387,7 +387,7 @@ elseif 'JACK' == arg[1] then
387 __(GUI):forkOnce() 387 __(GUI):forkOnce()
388 end 388 end
389 if _.runnable'jack-plumbing' then 389 if _.runnable'jack-plumbing' then
390 print("jack-plumbing") 390 print('jack-plumbing')
391 __'jack-plumbing -o /var/lib/aataaj/jack-plumbing 2>/dev/null':fork() 391 __'jack-plumbing -o /var/lib/aataaj/jack-plumbing 2>/dev/null':fork()
392 end 392 end
393 if _.runnable'a2j_control' then 393 if _.runnable'a2j_control' then
@@ -396,72 +396,72 @@ elseif 'JACK' == arg[1] then
396 --a2j_control actually starts a2jmidid. 396 --a2j_control actually starts a2jmidid.
397 ----a2jmidid -e -u & 397 ----a2jmidid -e -u &
398 -- 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. 398 -- 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.
399 print("a2j_control") 399 print('a2j_control')
400 __'a2j_control --ehw && a2j_control --start':Do() 400 __'a2j_control --ehw && a2j_control --start':Do()
401-- print("sleep 2") 401-- print('sleep 2')
402-- __('sleep 2'):Do() 402-- __('sleep 2'):Do()
403 print("") 403 print("")
404 end 404 end
405 405
406 406
407 local AIN = "alsa_in" 407 local AIN = 'alsa_in'
408 if _.runnable'zita-a2j' then AIN = 'zita-a2j' end 408 if _.runnable'zita-a2j' then AIN = 'zita-a2j' end
409 local AOUT = "alsa_out" 409 local AOUT = 'alsa_out'
410 if _.runnable'zita-j2a' then AOUT = 'zita-j2a' end 410 if _.runnable'zita-j2a' then AOUT = 'zita-j2a' end
411 411
412 print("Basic ALSA sound devices converted to JACK.") 412 print('Basic ALSA sound devices converted to JACK.')
413 for i,C in pairs(options.aliases.value) do 413 for i,C in pairs(options.aliases.value) do
414 print('HW playback: ' .. C['name'] .. '\tDEVICE: ' .. C['dev']) 414 print('HW playback: ' .. C['name'] .. '\tDEVICE: ' .. C['dev'])
415 __(AOUT .. ' -j ' .. C['name'] .. ' -d ' .. C['dev']):fork() 415 __(AOUT .. ' -j ' .. C['name'] .. ' -d ' .. C['dev']):fork()
416 end 416 end
417 print("HW playback: cloop\tDEVICE: cloop") 417 print('HW playback: cloop\tDEVICE: cloop')
418 -- No idea why, cloop wont work with zita-a2j. 418 -- No idea why, cloop wont work with zita-a2j.
419 __'alsa_in -j cloop -d cloop':fork() 419 __'alsa_in -j cloop -d cloop':fork()
420 --__[[sleep 1 420 --__[[sleep 1
421 -- jack_connect cloop:capture_1 system:playback_1o() 421 -- jack_connect cloop:capture_1 system:playback_1o()
422 -- jack_connect cloop:capture_2 system:playback_2]]:Do() 422 -- jack_connect cloop:capture_2 system:playback_2]]:Do()
423 print("HW playback: ploop\tDEVICE: ploop") 423 print('HW playback: ploop\tDEVICE: ploop')
424 __'alsa_out -j ploop -d ploop':fork() 424 __'alsa_out -j ploop -d ploop':fork()
425 --__[[sleep 1 425 --__[[sleep 1
426 -- jack_connect system:capture_1 ploop:playback_1 426 -- jack_connect system:capture_1 ploop:playback_1
427 -- jack_connect system:capture_2 ploop:playback_2]]:Do() 427 -- jack_connect system:capture_2 ploop:playback_2]]:Do()
428 428
429 429
430 print("") 430 print('')
431 431
432 print("Rest of ALSA sound devices converted to JACK.") 432 print('Rest of ALSA sound devices converted to JACK.')
433 for i,C in pairs(Cards) do 433 for i,C in pairs(Cards) do
434 for j,c in ipairs(C['playbackDevs']) do 434 for j,c in ipairs(C['playbackDevs']) do
435 print("HW playback: " .. C['name'] .. "\tDEVICE: " .. C['playbackDevs'][j]) 435 print('HW playback: ' .. C['name'] .. '\tDEVICE: ' .. C['playbackDevs'][j])
436 __(AOUT .. ' -j ' .. C['name'] .. "_" .. C['playbackDevs'][j] .. '-in -d ' .. C['name'] .. C['playbackDevs'][j]):fork() 436 __(AOUT .. ' -j ' .. C['name'] .. '_' .. C['playbackDevs'][j] .. '-in -d ' .. C['name'] .. C['playbackDevs'][j]):fork()
437 -- __'sleep 1':Do() 437 -- __'sleep 1':Do()
438 -- __('jack_connect cloop:capture_1 ' .. C['name'] .. '_' .. C['playbackDevs'][j] .. '-in' .. ':playback_1'):Do() 438 -- __('jack_connect cloop:capture_1 ' .. C['name'] .. '_' .. C['playbackDevs'][j] .. '-in' .. ':playback_1'):Do()
439 -- __('jack_connect cloop:capture_2 ' .. C['name'] .. '_' .. C['playbackDevs'][j] .. '-in' .. ':playback_2'):Do() 439 -- __('jack_connect cloop:capture_2 ' .. C['name'] .. '_' .. C['playbackDevs'][j] .. '-in' .. ':playback_2'):Do()
440 end 440 end
441 for j,c in ipairs(C['captureDevs']) do 441 for j,c in ipairs(C['captureDevs']) do
442 print("HW capture: " .. C['name'] .. "\tDEVICE: " .. C['captureDevs'][j]) 442 print('HW capture: ' .. C['name'] .. '\tDEVICE: ' .. C['captureDevs'][j])
443 __(AIN .. ' -j ' .. C['name'] .. "_" .. C['captureDevs'][j] .. '-out -d ' .. C['name'] .. C['captureDevs'][j]):fork() 443 __(AIN .. ' -j ' .. C['name'] .. '_' .. C['captureDevs'][j] .. '-out -d ' .. C['name'] .. C['captureDevs'][j]):fork()
444 end 444 end
445 end 445 end
446 print("") 446 print('')
447 447
448 if _.runnable('aseqjoy') then 448 if _.runnable('aseqjoy') then
449 print("Scanning for joysticks.") 449 print('Scanning for joysticks.')
450 local sticks = __'ls -1 /dev/input/js[0-9]*':noErr():Do() 450 local sticks = __'ls -1 /dev/input/js[0-9]*':noErr():Do()
451 for i,l in ipairs(sticks.lines) do 451 for i,l in ipairs(sticks.lines) do
452 print("aseqjoy " .. l) 452 print('aseqjoy ' .. l)
453 -- Buttons switch to that numbered MIDI channel, defaults to 1. 453 -- Buttons switch to that numbered MIDI channel, defaults to 1.
454 -- Axis are mapped to MIDI controllers 10 - 15 454 -- Axis are mapped to MIDI controllers 10 - 15
455 -- -r means to use high resolution MIDI values. 455 -- -r means to use high resolution MIDI values.
456 __('aseqjoy -d ' .. l:sub(-1,-1) .. ' -r'):fork() 456 __('aseqjoy -d ' .. l:sub(-1,-1) .. ' -r'):fork()
457 end 457 end
458 print("") 458 print('')
459 end 459 end
460 460
461 if _.runnable('jack-plumbing') then 461 if _.runnable('jack-plumbing') then
462 print('Stop our jack-plumbing, eventually.') 462 print('Stop our jack-plumbing, eventually.')
463 __'sleep 4':Do() 463 __'sleep 4':Do()
464 _.killEmAll{"jack-plumbing"} 464 _.killEmAll{'jack-plumbing'}
465 end 465 end
466 466
467 if _.runnable('~/.aataaj_JACK.lua') then 467 if _.runnable('~/.aataaj_JACK.lua') then