diff options
| author | dvs1 | 2025-11-21 16:21:42 +1000 |
|---|---|---|
| committer | dvs1 | 2025-11-21 16:21:42 +1000 |
| commit | 411de7614e07690edf2593d6cc98b9271636ffbe (patch) | |
| tree | 751dea0cdc45e0d68543c99bf74f939a2b91a438 | |
| parent | Properly sort them. (diff) | |
| download | JackOnAllDevices-411de7614e07690edf2593d6cc98b9271636ffbe.zip JackOnAllDevices-411de7614e07690edf2593d6cc98b9271636ffbe.tar.gz JackOnAllDevices-411de7614e07690edf2593d6cc98b9271636ffbe.tar.bz2 JackOnAllDevices-411de7614e07690edf2593d6cc98b9271636ffbe.tar.xz | |
| -rwxr-xr-x | aataaj.lua | 23 |
1 files changed, 5 insertions, 18 deletions
| @@ -185,7 +185,6 @@ for i,l in ipairs(cards.lines) do | |||
| 185 | Cards[n]['captureDevs'][j] = m | 185 | Cards[n]['captureDevs'][j] = m |
| 186 | Cards[n]['devs'][m] = m | 186 | Cards[n]['devs'][m] = m |
| 187 | ---- print('Found capture DEVICE: ' .. Cards[n].card - 1 .. '\tSUB: ' .. m .. ' \t' .. Cards[n]['name']) | 187 | ---- print('Found capture DEVICE: ' .. Cards[n].card - 1 .. '\tSUB: ' .. m .. ' \t' .. Cards[n]['name']) |
| 188 | -- io.flush() | ||
| 189 | end | 188 | end |
| 190 | Cards[n]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() | 189 | Cards[n]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() |
| 191 | for j,p in ipairs(Cards[n]['playback'].lines) do | 190 | for j,p in ipairs(Cards[n]['playback'].lines) do |
| @@ -193,7 +192,6 @@ for i,l in ipairs(cards.lines) do | |||
| 193 | Cards[n]['playbackDevs'][j] = m | 192 | Cards[n]['playbackDevs'][j] = m |
| 194 | Cards[n]['devs'][m] = m | 193 | Cards[n]['devs'][m] = m |
| 195 | print('Found playback DEVICE: ' .. Cards[n].card - 1 .. '\tSUB: ' .. m .. ' \t' .. Cards[n]['name']) | 194 | print('Found playback DEVICE: ' .. Cards[n].card - 1 .. '\tSUB: ' .. m .. ' \t' .. Cards[n]['name']) |
| 196 | -- io.flush() | ||
| 197 | if 'JACK' ~= cmd then | 195 | if 'JACK' ~= cmd then |
| 198 | -- 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 .. '"') | 196 | -- 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 .. '"') |
| 199 | -- io.flush() | 197 | -- io.flush() |
| @@ -215,10 +213,11 @@ for i,l in ipairs(cards.lines) do | |||
| 215 | end | 213 | end |
| 216 | end | 214 | end |
| 217 | end | 215 | end |
| 218 | --table.sort(Cards, function(a, b) return a.card < b.card end) | ||
| 219 | print('') | 216 | print('') |
| 220 | io.flush() | 217 | io.flush() |
| 221 | 218 | ||
| 219 | |||
| 220 | |||
| 222 | local speak = function(card, subdevice, device, words, printIt, forkIt, ...) | 221 | local speak = function(card, subdevice, device, words, printIt, forkIt, ...) |
| 223 | local files = {...} | 222 | local files = {...} |
| 224 | local s = '' | 223 | local s = '' |
| @@ -226,11 +225,7 @@ local speak = function(card, subdevice, device, words, printIt, forkIt, ...) | |||
| 226 | if 0 == #files then | 225 | if 0 == #files then |
| 227 | local file = os.tmpname() .. '.wav' | 226 | local file = os.tmpname() .. '.wav' |
| 228 | D('Creating temporary script file at ' .. file) | 227 | D('Creating temporary script file at ' .. file) |
| 229 | -- s = '#!/bin/bash\necho "' .. words .. '" | ALSA_CARD=' .. device .. ' ' .. speaker | ||
| 230 | -- s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -d hw:' .. device .. subdevice | ||
| 231 | s = '#!/bin/bash\n' .. speaker .. ' -d hw:' .. device .. subdevice .. ' "' .. words .. '"' | 228 | s = '#!/bin/bash\n' .. speaker .. ' -d hw:' .. device .. subdevice .. ' "' .. words .. '"' |
| 232 | -- s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -w ' .. file .. ' ; aplay --device=hw:' .. device .. subdevice .. ' ' .. file | ||
| 233 | -- s = '#!/bin/bash\n' .. speaker .. ' -w ' .. file .. ' "' .. words .. '" ; aplay --device=hw:' .. device .. subdevice .. ' ' .. file | ||
| 234 | else | 229 | else |
| 235 | s = 'aplay -q --device=hw:' .. device .. subdevice | 230 | s = 'aplay -q --device=hw:' .. device .. subdevice |
| 236 | for i, v in ipairs(files) do s = s .. ' /usr/local/share/doc/aataaj/' .. v .. '.wav' end | 231 | 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, ...) | |||
| 241 | else | 236 | else |
| 242 | __(s):Do() | 237 | __(s):Do() |
| 243 | end | 238 | end |
| 244 | -- io.flush() | ||
| 245 | end | 239 | end |
| 246 | 240 | ||
| 247 | -- TODO - Start with the device, then go through the sub devices. Coz at boot time subs don't seem to work. | 241 | -- TODO - Start with the device, then go through the sub devices. Coz at boot time subs don't seem to work. |
| 248 | -- Likely that'll lock things up at "all speak at once" time. | 242 | -- Likely that'll lock things up at "all speak at once" time. |
| 249 | if 'start' == cmd then | 243 | if 'start' == cmd then |
| 250 | print('Your ' .. cnt .. ' audio devices are - ') | 244 | print('Your ' .. cnt .. ' audio devices are - ') |
| 251 | 245 | print(' being turned on and volume maxed - ') | |
| 252 | print(' being turned on and volume maxed - ') | ||
| 253 | for k = 0, cnt do | 246 | for k = 0, cnt do |
| 254 | -- Turn on IEC958 for everything, they seem to default to off, so can't hear them. | 247 | -- Turn on IEC958 for everything, they seem to default to off, so can't hear them. |
| 255 | for l, m in ipairs(__("amixer -c " .. k .. " scontrols | grep 'IEC958' | cut -d ',' -f 2"):noErr():Do().lines) do | 248 | 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 - ') | |||
| 261 | end | 254 | end |
| 262 | end | 255 | end |
| 263 | 256 | ||
| 264 | print(' being spoken through all at once - ') | 257 | print(' being spoken through all at once - ') |
| 265 | for k,C in pairs(Cards) do | 258 | for k,C in pairs(Cards) do |
| 266 | for j,c in ipairs(C['playbackDevs']) do | 259 | for j,c in ipairs(C['playbackDevs']) do |
| 267 | ---- speak(C.name, nil, C.card - 1, 'Your ' .. cnt .. ' audio devices are - ', false, true, 'your', numbers[cnt], 'devices') | ||
| 268 | speak(C.name, C['playbackDevs'][j], C.card - 1, 'Your ' .. cnt .. ' audio devices are - ', false, true, 'your', numbers[cnt], 'devices') | 260 | speak(C.name, C['playbackDevs'][j], C.card - 1, 'Your ' .. cnt .. ' audio devices are - ', false, true, 'your', numbers[cnt], 'devices') |
| 269 | end | 261 | end |
| 270 | end | 262 | end |
| 271 | -- TODO - should do a proper "wait for speakers to finish" here. Have fork(write a file), think that's what :wait(file) does. | 263 | -- TODO - should do a proper "wait for speakers to finish" here. Have fork(write a file), think that's what :wait(file) does. |
| 272 | __'sleep 6':Do() | 264 | __'sleep 6':Do() |
| 273 | print(' being spoken through one at a time - ') | 265 | print(' being spoken through one at a time - ') |
| 274 | for k,n in ipairs(Names) do | 266 | for k,n in ipairs(Names) do |
| 275 | C = Cards[n] | 267 | C = Cards[n] |
| 276 | for j,c in ipairs(C['playbackDevs']) do | 268 | for j,c in ipairs(C['playbackDevs']) do |
| 277 | ---- 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])]) | ||
| 278 | 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])]) | 269 | 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])]) |
| 279 | end | 270 | end |
| 280 | __'sleep 1':Do() | 271 | __'sleep 1':Do() |
| @@ -284,7 +275,6 @@ print(' being spoken through one at a time - ') | |||
| 284 | print('Please type the device number you heard best - ') | 275 | print('Please type the device number you heard best - ') |
| 285 | for k,C in pairs(Cards) do | 276 | for k,C in pairs(Cards) do |
| 286 | for j,c in ipairs(C['playbackDevs']) do | 277 | for j,c in ipairs(C['playbackDevs']) do |
| 287 | ---- speak(C.name, nil, C.card - 1, 'Please type the device number you heard best - ', false, true, 'best') | ||
| 288 | speak(C.name, C['playbackDevs'][j], C.card - 1, 'Please type the device number you heard best - ', false, true, 'best') | 278 | speak(C.name, C['playbackDevs'][j], C.card - 1, 'Please type the device number you heard best - ', false, true, 'best') |
| 289 | end | 279 | end |
| 290 | end | 280 | end |
| @@ -301,9 +291,6 @@ print(' being spoken through one at a time - ') | |||
| 301 | 291 | ||
| 302 | 292 | ||
| 303 | 293 | ||
| 304 | --os.exit(true) | ||
| 305 | |||
| 306 | |||
| 307 | __('mkdir -p ' .. options.asoundrcPath.value):Do() | 294 | __('mkdir -p ' .. options.asoundrcPath.value):Do() |
| 308 | local a, e = io.open(options.asoundrcPath.value .. '/jack-plumbing', 'w') | 295 | local a, e = io.open(options.asoundrcPath.value .. '/jack-plumbing', 'w') |
| 309 | if nil == a then print('Could not open ' .. options.asoundrcPath.value .. '/jack-plumbing - ' .. e) else | 296 | if nil == a then print('Could not open ' .. options.asoundrcPath.value .. '/jack-plumbing - ' .. e) else |
