# Listen universal setup (Windows). irm https://marcusx.fun/listen/setup/win | iex # 1) Performer: Python 3.12 + ffmpeg (winget, only if missing) -> %LOCALAPPDATA%\Listen -> pick mic -> sender runs hidden, # ARMED: connected and idle (mic closed, nothing sent) until the producer presses record; then it plays the # producer's cue (or a click on the song grid) and streams song-stamped mic audio until the producer stops. # 2) Producer : Windows has no prebuilt Listen plug-in; prints the browser listen page + the Mac/Logic route. # Safe to run again. No Scheduled Task, no Startup item. Only password: 333333. & { $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" $Url = $(if ($env:LISTEN_URL) { $env:LISTEN_URL.TrimEnd("/") } else { "https://marcusx.fun/listen" }) $Pw = $(if ($env:LISTEN_PW) { $env:LISTEN_PW } else { "333333" }) $Setup = "$Url/setup" $H = @{ "X-Listen-Password" = $Pw } $Dir = Join-Path $env:LOCALAPPDATA "Listen" function Say($m) { Write-Host "==> $m" -ForegroundColor Yellow } function Refresh-Path { $env:Path = [Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [Environment]::GetEnvironmentVariable("Path","User") + ";" + (Join-Path $env:LOCALAPPDATA "Microsoft\WinGet\Links") } function Find-Python { $c = @() $py = Get-Command py -ErrorAction SilentlyContinue if ($py) { foreach ($v in "-3.12","-3") { try { $e = & $py.Source $v -c "import sys;print(sys.executable)" 2>$null; if ($LASTEXITCODE -eq 0 -and $e) { $c += $e.Trim() } } catch {} } } $c += (Get-Command python -All -ErrorAction SilentlyContinue | Where-Object { $_.Source -notlike "*WindowsApps*" } | ForEach-Object { $_.Source }) $c += (Join-Path $env:LOCALAPPDATA "Programs\Python\Python312\python.exe") foreach ($p in $c) { if ($p -and (Test-Path $p) -and (Test-Path (Join-Path (Split-Path $p) "pythonw.exe"))) { return $p } } return $null } function Find-Ffmpeg { $f = Get-Command ffmpeg -ErrorAction SilentlyContinue if ($f) { return $f.Source } $g = Get-ChildItem (Join-Path $env:LOCALAPPDATA "Microsoft\WinGet\Packages") -Filter ffmpeg.exe -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.FullName -like "*Gyan.FFmpeg*" } | Select-Object -First 1 if ($g) { return $g.FullName } return $null } function Stop-Listen { # one sender per relay: an older copy would keep kicking the new one off $t = $null; try { $t = Get-ScheduledTask -TaskName "Listen sender" -ErrorAction SilentlyContinue } catch {} if ($t) { Say "removing the old 'Listen sender' Scheduled Task (it would fight this one)"; Stop-ScheduledTask -TaskName "Listen sender" -ErrorAction SilentlyContinue; Unregister-ScheduledTask -TaskName "Listen sender" -Confirm:$false -ErrorAction SilentlyContinue } $lnk = Join-Path ([Environment]::GetFolderPath("Startup")) "Listen sender.lnk" if (Test-Path $lnk) { Remove-Item $lnk -Force } $procs = Get-CimInstance Win32_Process -Filter "Name='pythonw.exe' OR Name='python.exe'" -ErrorAction SilentlyContinue | Where-Object { $_.CommandLine -and (($_.CommandLine -like "*sender.py*--url*") -or ($_.CommandLine -like "*\Listen\launch.py*")) } foreach ($p in $procs) { Get-CimInstance Win32_Process -Filter "ParentProcessId=$($p.ProcessId)" -ErrorAction SilentlyContinue | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue } Stop-Process -Id $p.ProcessId -Force -ErrorAction SilentlyContinue } if ($procs) { Start-Sleep -Seconds 1 } } $role = $env:LISTEN_ROLE if (-not $role) { Write-Host "" Write-Host " Listen setup (Windows) relay: $Url" Write-Host " 1) Performer (sit armed: the producer's record button starts and stops you)" Write-Host " 2) Producer (the performer lands on a track in your DAW)" $role = Read-Host " Pick 1 or 2" } switch -Regex ($role) { '^(1|p|perf|performer)$' { $role = "performer" } '^(2|prod|producer)$' { $role = "producer" } default { Write-Host "No role picked. Run the line again and type 1 or 2."; return } } if ($role -eq "producer") { Write-Host "" Say "Producer on Windows" Write-Host " There is no prebuilt Listen plug-in for Windows yet (the AU is for Logic on a Mac)." Write-Host " To hear the performer now: open $Url/ in Chrome, password $Pw." Write-Host " On the producer's Mac run: curl -fsSL $Setup/sh | bash and pick 2." return } # ---------------- performer ---------------- $python = Find-Python if (-not $python) { Say "installing Python 3.12 (winget, current user)" winget install -e --id Python.Python.3.12 --scope user --silent --accept-package-agreements --accept-source-agreements | Out-Host Refresh-Path; $python = Find-Python if (-not $python) { Write-Host "Python 3.12 did not install. Get it from python.org, then run this line again."; return } } $pythonw = Join-Path (Split-Path $python) "pythonw.exe" $ffmpeg = Find-Ffmpeg if (-not $ffmpeg) { Say "installing ffmpeg (winget Gyan.FFmpeg)" winget install -e --id Gyan.FFmpeg --silent --accept-package-agreements --accept-source-agreements | Out-Host Refresh-Path; $ffmpeg = Find-Ffmpeg if (-not $ffmpeg) { Write-Host "ffmpeg did not install. Run: winget install Gyan.FFmpeg then this line again."; return } } $ffdir = Split-Path $ffmpeg if (($env:Path -split ";") -notcontains $ffdir) { $env:Path = "$ffdir;$env:Path" } Say "Python: $python" Say "ffmpeg: $ffmpeg" New-Item -ItemType Directory -Force -Path $Dir | Out-Null Say "fetching sender into $Dir" foreach ($f in @(@("$Url/sender.py","sender.py"), @("$Url/proto.py","proto.py"), @("$Setup/launch.py","launch.py"), @("$Setup/listmics.py","listmics.py"))) { $tmp = Join-Path $Dir ($f[1] + ".tmp") Invoke-WebRequest -UseBasicParsing -Headers $H -Uri $f[0] -OutFile $tmp Move-Item -Force $tmp (Join-Path $Dir $f[1]) } $mic = $env:LISTEN_MIC if (-not $mic) { Push-Location $Dir $mics = @(& $python -B listmics.py 2>$null | Where-Object { $_ -and $_.Trim() } | Select-Object -Unique) Pop-Location if ($mics.Count -gt 0) { $def = 1 for ($i = 0; $i -lt $mics.Count; $i++) { if ($mics[$i] -like "*HyperX SoloCast 2*") { $def = $i + 1; break } } Write-Host " Microphones:" for ($i = 0; $i -lt $mics.Count; $i++) { Write-Host (" {0}) {1}" -f ($i + 1), $mics[$i]) } $pick = Read-Host " Pick a mic [1-$($mics.Count), Enter = $def]" $n = 0 if (-not ([int]::TryParse($pick, [ref]$n)) -or $n -lt 1 -or $n -gt $mics.Count) { $n = $def } $mic = $mics[$n - 1] } else { Write-Host " (no mic list from ffmpeg; using the system default mic)" } } # ffmpeg lists WASAPI names like "Microphone (HyperX SoloCast 2)"; the sender matches by substring. $micArg = "" if ($mic) { $micShort = $mic; if ($mic -match '\(([^()]+)\)\s*$') { $micShort = $Matches[1] }; $micArg = " --mic-name `"$micShort`"" } Stop-Listen $sargs = "-B `"$Dir\launch.py`" --url $Url --password $Pw --daemon --armed --mic --play-cue$micArg" Set-Content -Path (Join-Path $Dir "run.cmd") -Encoding ASCII -Value @" @echo off rem Listen performer sender (hidden). Re-run setup to change the mic. set PATH=$ffdir;%PATH% set LISTEN_URL=$Url set LISTEN_PWA_PASSWORD=$Pw cd /d "$Dir" start "" /b "$pythonw" $sargs "@ $env:LISTEN_URL = $Url; $env:LISTEN_PWA_PASSWORD = $Pw Say "starting the sender hidden and armed (mic: $(if ($mic) { $mic } else { 'default' }))" Start-Process -FilePath $pythonw -ArgumentList $sargs -WorkingDirectory $Dir -WindowStyle Hidden $ok = $false for ($i = 0; $i -lt 10; $i++) { Start-Sleep -Seconds 1 try { $h = Invoke-RestMethod -Headers $H -Uri "$Url/health"; if ($h.sender) { $ok = $true; break } } catch {} } if ($ok) { Say "relay sees your sender, armed. You never press anything: when the producer hits record you'll hear the beat (or a click) and you're recording." } else { Say "sender started; the relay has not confirmed it yet. Check $Url/health" } if (-not (Test-Path (Join-Path $ffdir "ffplay.exe"))) { Say "note: ffplay.exe isn't next to ffmpeg, so the cue/click can't play (the Gyan.FFmpeg winget package includes it)" } Write-Host " Stop: Get-CimInstance Win32_Process -Filter `"Name='pythonw.exe'`" | ? CommandLine -like '*\Listen\launch.py*' | % { Stop-Process -Id `$_.ProcessId }" Write-Host " Restart: run this setup line again (or double-click $Dir\run.cmd)." Write-Host " Nothing starts at login. Run this line again after a reboot." }