aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xaataaj.lua26
1 files 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
160 local m = c:match('.*pcm(%d+).*') 160 local m = c:match('.*pcm(%d+).*')
161 Cards[n]['captureDevs'][j] = m 161 Cards[n]['captureDevs'][j] = m
162 Cards[n]['devs'][m] = m 162 Cards[n]['devs'][m] = m
163 print('\tFound capture device: ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['captureDevs'][j] .. ' ' .. m) 163 print('\tFound capture device: ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['captureDevs'][j] .. ', sub device ' .. m)
164-- io.flush() 164-- io.flush()
165 end 165 end
166 Cards[n]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() 166 Cards[n]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do()
@@ -168,7 +168,7 @@ for i,l in ipairs(cards.lines) do
168 local m = p:match('.*pcm(%d+).*') 168 local m = p:match('.*pcm(%d+).*')
169 Cards[n]['playbackDevs'][j] = m 169 Cards[n]['playbackDevs'][j] = m
170 Cards[n]['devs'][m] = m 170 Cards[n]['devs'][m] = m
171 print('\tFound playback device ' .. Cards[n].card - 1 .. ' : ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['playbackDevs'][j] .. ' ' .. m) 171 print('\tFound playback device ' .. Cards[n].card - 1 .. ' : ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['playbackDevs'][j] .. ', sub device ' .. m)
172-- io.flush() 172-- io.flush()
173 if 'JACK' ~= arg[1] then 173 if 'JACK' ~= arg[1] then
174-- 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 .. '"') 174-- 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()
185 185
186 186
187local speak = function(card, subdevice, device, words, printIt, forkIt) 187local speak = function(card, subdevice, device, words, printIt, forkIt)
188 if printIt then print(words) end 188-- local file = os.tmpname()
189 if forkIt then 189-- D('Creating temporary script file at ' .. file)
190 __('#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -d ' .. card .. subdevice):noErr():noOut():fork() 190 local s = '#!/bin/bash\necho "' .. words .. '" | ALSA_CARD=' .. device .. ' ' .. speaker
191 else 191-- local s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -d ' .. device
192 __('#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -d ' .. card .. subdevice):noErr():noOut():Do() 192-- local s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -w ' .. file .. ' ; aplay -q --device=hw:CARD=' .. card .. ',DEV=' .. subdevice .. ' ' .. file
193 end 193 if printIt then print(words) end
194-- io.flush() 194 if forkIt then
195 __(s):noErr():noOut():fork()
196 else
197 __(s):noErr():noOut():Do()
198 end
199-- io.flush()
195end 200end
196 201
197if 'start' == arg[1] then 202if 'start' == arg[1] then
@@ -205,7 +210,7 @@ if 'start' == arg[1] then
205 __'sleep 6':Do() 210 __'sleep 6':Do()
206 for k,C in pairs(Cards) do 211 for k,C in pairs(Cards) do
207 for j,c in ipairs(C['playbackDevs']) do 212 for j,c in ipairs(C['playbackDevs']) do
208 speak(C.name, C['playbackDevs'][j], C.card - 1, 'Device number ' .. C.card - 1 .. ', ' .. C['playbackDevs'][j] .. ' : ' .. C.name, true, false) 213 speak(C.name, C['playbackDevs'][j], C.card - 1, 'Device number ' .. C.card - 1 .. ', sub device ' .. C['playbackDevs'][j] .. ' : ' .. C.name, true, false)
209 end 214 end
210 __'sleep 1':Do() 215 __'sleep 1':Do()
211 end 216 end
@@ -217,6 +222,7 @@ if 'start' == arg[1] then
217 speak(C.name, C['playbackDevs'][j], C.card - 1, 'Please type the device number you heard best - ', false, true) 222 speak(C.name, C['playbackDevs'][j], C.card - 1, 'Please type the device number you heard best - ', false, true)
218 end 223 end
219 end 224 end
225
220 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". 226 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".
221 local ourCard = '' 227 local ourCard = ''
222 228