Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/listening-lab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Early Listening Lab GUI

on:
push:
branches: [main]
paths:
- 'ui/listening_lab.py'
- 'tests/test_listening_lab.py'
- 'docs/LISTENING_LAB.md'
- '.github/workflows/listening-lab.yml'
pull_request:
paths:
- 'ui/listening_lab.py'
- 'tests/test_listening_lab.py'
- 'docs/LISTENING_LAB.md'
- '.github/workflows/listening-lab.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
controller-and-gui:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install Tk and virtual display
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends python3-tk xvfb
- name: Python syntax check
run: python3 -m py_compile ui/listening_lab.py tests/test_listening_lab.py
- name: Fake-player subprocess regressions
run: python3 -m unittest discover -s tests -p 'test_listening_lab.py' -v
- name: Native GUI construction under Xvfb
run: xvfb-run -a python3 ui/listening_lab.py --smoke-test
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ PSYCLE-LINUX exists to bring the workflow and behaviour of the original Psycle M

This project is not a ground-up DAW redesign.

## Early human-ear Listening Lab (experimental)

An opt-in, **candidate-only desktop listening GUI** is available at
[`ui/listening_lab.py`](ui/listening_lab.py). It opens local `.psy`
songs with the existing C++ `psycle-player`, supports ALSA/JACK output,
Stop, optional WAV output, and hash-bound JSON listening notes. See
[the Linux setup and listening procedure](docs/LISTENING_LAB.md).

This is a temporary human-observation harness requested on 9 November 2026,
**not** the finished Psycle tracker interface or an original-Psycle
compatibility verdict. The deferred engine/parity gates remain in force.

## Current priority — bounded original-Psycle investigation

The previous implementation roadmap is **deferred**, with its history and
Expand Down
121 changes: 121 additions & 0 deletions docs/LISTENING_LAB.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# PSYCLE-LINUX Listening Lab — early human-ear feedback

Status: **experimental GUI for the preserved C++ candidate player**, not the
full tracker UI or a certification of original Psycle 1.12.0 compatibility.

This small Python/Tk desktop application makes the already-maintained
historical psycle-player executable accessible to human listening tests.
It does **not** change the original engine, import any unlicensed songs,
claim a working Machine View, or modify the frozen evidence matrix.

The maintainer explicitly requested an early audible feedback tool on
9 November 2026, taking a narrowly scoped UI-test exception to the
deferred roadmap. The full Qt Widgets tracker UI remains deferred; this
temporary wrapper is not its architectural replacement.

## Launch on Ubuntu

Requires Python 3, Tk (Ubuntu package python3-tk), a desktop session,
and the previously maintained C++ psycle-player build.

~~~sh
sudo apt-get install python3-tk
# From PSYCLE-LINUX repository root:
python3 ui/listening_lab.py
~~~

No PyPI packages, virtual environments, containers, or Node/npm are needed.

If the player has not been built, reproduce the **Phase 6B historical-player**
build from .github/workflows/phase6b-player-build.yml (Ubuntu 24.04 reference).
The workflow pins the upstream support sources and historical plugin interface,
installs Qt/qmake and C++ library dependencies, and builds the C++ binary at:

~~~text
psycle-cpp-r12005-sanitized/psycle-player/++qmake/psycle-player
~~~

**Do not bypass the staging hashes or copy unknown SDK files to make the
build pass.** The GUI refuses to launch when that player is missing. A
different locally built candidate path may be supplied explicitly:

~~~sh
python3 ui/listening_lab.py \
--player /path/to/psycle-player \
--song /path/to/your-song.psy
~~~

The --player option is intentionally explicit so reports can identify the
actual executable bytes; selecting an executable does not assert that it is
the frozen Phase 6B build. The GUI hashes both song and player in its report.

## Listening procedure

1. **Lower system output volume** before starting. There is no in-app gain
limiter; headphones and speakers are driven by the selected audio backend.
2. Load a .psy song you own or are permitted to test. Use project-generated
synthetic fixtures where practical. The public repository deliberately
excludes historical demo songs with unresolved redistribution permissions.
3. Select alsa (typical desktop), jack (if available), or dummy (silent
diagnostic control). Optional device names are forwarded literally as
separate arguments, with no shell expansion. Driver availability depends on
the compiled player, and the historical player may fall back to
dummy after reporting an unavailable output driver: **audio silence is
not proof that the song has no sound**.
4. Click **Play song** and listen. The historical CLI loops until stopped;
the GUI sends Enter to its --wait stdin to stop and finalize.
A bounded terminate/kill fallback prevents a hung child from running
indefinitely. **Stop normally before closing or interrupting WAV export**
so the output file has a chance to finalize.
5. Optionally select a fresh, non-existing .wav output destination before
pressing Play. The GUI refuses to overwrite an existing WAV path.
6. Classify the listening result, describe the audible fault and reproduction
steps, and **Save listening report** as JSON. The report includes SHA-256
of song and player, runtime driver/device, the observed process exit code,
notes and a bounded tail of diagnostics. Reports may contain local file
paths and personal notes: review before publishing.

Configured third-party native/LADSPA plugin paths are **disabled by default**.
Enabling them is a deliberate local opt-in, not a safety certification.
The historical player is not plugin-sandboxed; do not load untrusted songs
or plugins as though they were isolated.

### First three suggested ear tests

| Test | Procedure | Tell us |
| --- | --- | --- |
| A — Is sound present? | Try alsa, then compare dummy | Audible/silent, device name, output log |
| B — Pitch | Listen to a known single-note or familiar sample passage | Correct, too high/low, unstable, octave error |
| C — Timing | Play a short repetitive pattern and stop after several loops | Steady, early/late note, drift, dropout, tick irregularity |

If there is a problem, include a timestamp or pattern position if possible,
the expected sound, the actual sound, and whether it reproduces twice.

## Evidence boundaries

This is **candidate-only auditory evidence**. Every report deliberately declares
original_psycle_observed=false and parity_status=UNKNOWN.
A human listening impression is invaluable for finding defects but does not
by itself justify changing the Phase 6C compatibility matrix.

Current known limitations:

- No full tracker editor, Machine View, sample keyboard, or instrument UI.
- No automatic song-end detection (the preserved CLI loops).
- No level meter, live waveform, speaker calibration, or automatic audio analysis.
- No isolation of arbitrary third-party plugins.
- No claim that the candidate matches original Psycle's pitch/timing semantics.
- The historical player must be built separately; GUI CI does not rebuild it.

## Run focused tests

~~~sh
python3 -m unittest discover -s tests -p 'test_listening_lab.py' -v
python3 -m py_compile ui/listening_lab.py
# In a Linux CI/Xvfb environment:
xvfb-run -a python3 ui/listening_lab.py --smoke-test
~~~

The headless subprocess test uses a clearly labeled **fake player**. It checks
command construction, spaces in paths, safe default plugin-path handling, and
graceful stdin shutdown. It does not pretend to render or audibly verify Psycle.
97 changes: 97 additions & 0 deletions tests/test_listening_lab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# SPDX-License-Identifier: Apache-2.0
"""Headless contract tests for the early Listening Lab controller."""
import os
from pathlib import Path
import stat
import sys
import tempfile
import time
import unittest
from unittest import mock

sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "ui"))
from listening_lab import PlaybackConfig, PlayerSession


class ListeningLabTests(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.root = Path(self.temp.name)
self.player = self.root / "fake player"
self.song = self.root / "song with spaces.psy"
self.song.write_bytes(b"PSY3SONG synthetic test input")
self.player.write_text(
"#!" + sys.executable + "\n"
"import os,sys\n"
"print('FAKE_PLAYER_READY', flush=True)\n"
"print('PSYCLE_PATH=' + repr(os.environ.get('PSYCLE_PATH')), flush=True)\n"
"print('ARGS=' + repr(sys.argv[1:]), flush=True)\n"
"sys.stdin.readline()\n"
"print('FAKE_PLAYER_STOPPED', flush=True)\n",
encoding="utf-8",
)
self.player.chmod(self.player.stat().st_mode | stat.S_IXUSR)

def config(self, **kwargs):
return PlaybackConfig(player=self.player, song=self.song, **kwargs)

def test_argv_preserves_spaces_and_waits_for_stop(self):
args = self.config(driver="alsa", device="plughw:0").command()
self.assertEqual(args[0], str(self.player.resolve()))
self.assertEqual(args[-2:], ["--input-file", str(self.song.resolve())])
self.assertEqual(args[args.index("--output-device") + 1], "plughw:0")
self.assertIn("--wait", args)

def test_rejects_invalid_driver_and_non_psy_file(self):
with self.assertRaisesRegex(ValueError, "Unsupported"):
self.config(driver="not-a-driver").command()
wav = self.root / "sample.wav"
wav.touch()
with self.assertRaisesRegex(ValueError, r"\.psy"):
PlaybackConfig(self.player, wav).command()

def test_refuses_overwriting_wav(self):
wav = self.root / "existing.wav"
wav.touch()
with self.assertRaisesRegex(ValueError, "overwrite"):
self.config(wav_output=wav).command()
new = self.root / "new.wav"
args = self.config(wav_output=new).command()
self.assertEqual(args[args.index("--output-file") + 1], str(new.resolve()))

def test_plugin_paths_opt_in_only(self):
with mock.patch.dict(os.environ, {"PSYCLE_PATH": "/tmp/plugins", "LADSPA_PATH": "/tmp/ladspa"}):
clean = self.config().environment()
self.assertNotIn("PSYCLE_PATH", clean)
self.assertNotIn("LADSPA_PATH", clean)
opted = self.config(allow_plugins=True).environment()
self.assertEqual(opted["PSYCLE_PATH"], "/tmp/plugins")
self.assertEqual(opted["LADSPA_PATH"], "/tmp/ladspa")

def test_fake_player_launch_and_graceful_shutdown(self):
with mock.patch.dict(os.environ, {"PSYCLE_PATH": "/tmp/ignore"}):
session = PlayerSession(self.config())
try:
session.start()
deadline = time.monotonic() + 3
output = ""
while "FAKE_PLAYER_READY" not in output and time.monotonic() < deadline:
output += session.output()
time.sleep(0.02)
self.assertIn("FAKE_PLAYER_READY", output)
self.assertIn("PSYCLE_PATH=None", output)
session.stop()
while session.poll() is None and time.monotonic() < deadline:
time.sleep(0.02)
self.assertEqual(session.poll(), 0)
output += session.output()
self.assertIn("FAKE_PLAYER_STOPPED", output)
self.assertTrue(session.started_utc)
self.assertTrue(session.ended_utc)
finally:
session.close()


if __name__ == "__main__":
unittest.main()
Loading
Loading