Skip to content

armgit / Spun

Public Imported from GitHub
0

A CD-shaped music player for Linux, with local playback and Cider integration.

Add CD and cassette decks, TX-6 mixing, and smoother rendering

yappologistice4a5ecaf5e6b
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3c2d9c..86022e0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,15 +46,16 @@ qt_add_library(spun_core STATIC
src/listening.cpp src/listening.h src/tapesound.cpp src/tapesound.h src/vinylnoise.cpp src/vinylnoise.h
src/musicactions.cpp src/musicactions.h
src/library.cpp src/library.h src/lyrics.cpp src/lyrics.h src/artwork.cpp src/artwork.h
+ src/tx6.cpp src/tx6.h
src/player.cpp src/player.h src/disc.cpp src/disc.h src/recorder.cpp src/recorder.h src/playerbody.cpp src/playerbody.h src/mpris.cpp src/mpris.h
src/theme.cpp src/theme.h src/cider.cpp src/cider.h src/ciderevents.cpp src/ciderevents.h)
target_link_libraries(spun_core PUBLIC Qt6::Core Qt6::Gui Qt6::Quick Qt6::Qml Qt6::QuickControls2
Qt6::Svg Qt6::Multimedia Qt6::Concurrent Qt6::DBus Qt6::Network PkgConfig::TAGLIB)
if(TARGET Qt6::Quick3D AND SPUN_ENABLE_3D)
- target_sources(spun_core PRIVATE src/deckgeometry.cpp src/deckgeometry.h src/mediageometry.cpp src/mediageometry.h)
+ target_sources(spun_core PRIVATE src/deckgeometry.cpp src/deckgeometry.h src/cablegeometry.cpp src/cablegeometry.h src/mediageometry.cpp src/mediageometry.h)
target_link_libraries(spun_core PUBLIC Qt6::Quick3D)
target_compile_definitions(spun_core PUBLIC SPUN_WITH_3D=1)
- set(SPUN_3D_QML qml/Player3D.qml qml/Recorder3D.qml qml/Vinyl3D.qml)
+ set(SPUN_3D_QML qml/Player3D.qml qml/Recorder3D.qml qml/Tx6_3D.qml qml/Tx6Cable3D.qml qml/Vinyl3D.qml qml/Cassette3D.qml qml/Cd3D.qml)
endif()
target_compile_definitions(spun_core PUBLIC SPUN_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
target_compile_options(spun_core PRIVATE -Wall -Wextra -Wpedantic)
@@ -62,7 +63,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# Keep Release code compact without changing floating-point semantics or
# disabling exceptions. The animated geometry retains full speed optimization.
target_compile_options(spun_core PRIVATE "$<$<CONFIG:Release>:${SPUN_SIZE_OPTIMIZATION};-ffunction-sections;-fdata-sections>")
- set_source_files_properties(src/disc.cpp PROPERTIES COMPILE_OPTIONS "$<$<CONFIG:Release>:-O3>")
+ set_source_files_properties(src/disc.cpp src/mediageometry.cpp src/deckgeometry.cpp src/cablegeometry.cpp PROPERTIES COMPILE_OPTIONS "$<$<CONFIG:Release>:-O3>")
endif()
file(GLOB SPUN_SYMBOLS CONFIGURE_DEPENDS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/*.svg")
set_source_files_properties(qml/SpunStyle.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
@@ -77,7 +78,7 @@ function(spun_application target)
# Compile QML at build time, preserving existing resource URLs and the UI.
qt_add_qml_module(${target} URI SpunUi VERSION 1.0 NO_PLUGIN
NO_RESOURCE_TARGET_PATH RESOURCE_PREFIX "/" OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${target}-qml"
- QML_FILES ${SPUN_3D_QML} qml/Recorder.qml qml/RecorderDisplay.qml qml/SpunButton.qml qml/SpunSlider.qml qml/SeekSlider.qml qml/QuickJump.qml qml/NextTrackTip.qml qml/SavedQueuePicker.qml qml/Tonearm.qml qml/CassetteReels.qml qml/SpunText.qml qml/FontPicker.qml qml/SpunStateLayer.qml qml/SpunSpring.qml qml/SpunPopupEnter.qml qml/SpunStyle.qml qml/TrackContent.qml qml/SpunSearchField.qml qml/MenuEntry.qml qml/PreferenceSwitch.qml qml/TrackMenu.qml qml/Main.qml qml/LibraryPanel.qml qml/SpunToolTip.qml qml/IconButton.qml qml/Glyph.qml)
+ QML_FILES ${SPUN_3D_QML} qml/Recorder.qml qml/RecorderDisplay.qml qml/Tx6Controls.qml qml/Tx6Labels.qml qml/Tx6Display.qml qml/CassetteControls.qml qml/CdControls.qml qml/CdDisplay.qml qml/SpunButton.qml qml/SpunSlider.qml qml/SeekSlider.qml qml/QuickJump.qml qml/NextTrackTip.qml qml/SavedQueuePicker.qml qml/Tonearm.qml qml/CassetteReels.qml qml/SpunText.qml qml/FontPicker.qml qml/SpunStateLayer.qml qml/SpunSpring.qml qml/SpunPopupEnter.qml qml/SpunStyle.qml qml/TrackContent.qml qml/SpunSearchField.qml qml/MenuEntry.qml qml/PreferenceSwitch.qml qml/TrackMenu.qml qml/Main.qml qml/LibraryPanel.qml qml/SpunToolTip.qml qml/IconButton.qml qml/Glyph.qml)
# Preserve the exact SVGs and URLs; Qt's default threshold leaves many of
# these small resources uncompressed. Parsed symbols are already cached.
if(QT_FEATURE_zstd)
@@ -104,7 +105,8 @@ endif()
if(BUILD_TESTING)
find_package(Qt6 REQUIRED COMPONENTS Test)
spun_application(spun-diagnostics)
- target_sources(spun-diagnostics PRIVATE src/librarytest.cpp src/librarytest.h src/eventstest.cpp src/mediauitest.cpp src/threedtest.cpp src/artworktest.cpp src/recordertest.cpp src/turntabletest.cpp)
+ target_sources(spun-diagnostics PRIVATE src/librarytest.cpp src/librarytest.h src/eventstest.cpp src/mediauitest.cpp src/threedtest.cpp src/artworktest.cpp src/recordertest.cpp src/turntabletest.cpp src/cassettedecktest.cpp src/cddecktest.cpp src/tx6test.cpp)
+ target_sources(spun-diagnostics PRIVATE src/performancetest.cpp src/performancetest.h)
target_compile_definitions(spun-diagnostics PRIVATE SPUN_DIAGNOSTICS)
target_link_libraries(spun-diagnostics PRIVATE Qt6::Test)
if(TARGET Qt6::Quick3D AND SPUN_ENABLE_3D)
@@ -124,6 +126,8 @@ if(BUILD_TESTING)
target_link_libraries(spun-import-test PRIVATE spun_core Qt6::Test)
add_test(NAME spun-folder-import COMMAND spun-import-test)
set_tests_properties(spun-folder-import PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=offscreen;QT_QPA_PLATFORMTHEME=")
+ add_test(NAME spun-refresh-independent-motion COMMAND spun-diagnostics --test-performance)
+ set_tests_properties(spun-refresh-independent-motion PROPERTIES ENVIRONMENT "SPUN_PERF_TIMING_ONLY=1;QT_QPA_PLATFORM=offscreen;QT_QUICK_BACKEND=software;QSG_RENDER_LOOP=basic;QT_QPA_PLATFORMTHEME=")
add_test(NAME spun-playback-and-ui COMMAND spun --self-test)
set_tests_properties(spun-playback-and-ui PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=offscreen;QT_QUICK_BACKEND=software;QSG_RENDER_LOOP=basic;QT_QPA_PLATFORMTHEME=")
endif()
diff --git a/README.md b/README.md
index 3f84552..d73f17a 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
<h1 align="center">Spun</h1>
-<p align="center">A CD, vinyl and cassette music player for Linux.</p>
+<p align="center">A music player for Linux with CD, vinyl, cassette and recorder views.</p>
<p align="center">
<img src="assets/screenshots/spun-vinyl.png" alt="Spun in vinyl mode with a gold tonearm and the Cider queue alongside it" width="1000">
@@ -72,17 +72,28 @@ Spun connects to the local API on port 10767. Basic playback controls use Linux'
Choose a medium in **More → Preferences**. All four share playback controls, album details, lyrics and Mini mode.
-- **CD:** album artwork on the disc, with gentle rotation or an optional **500 RPM** setting. This changes the visual speed only.
+- **CD:** a DM15 R2R-inspired aluminum player with a glass lid, live display, transport buttons, shuffle and repeat selectors, and a volume knob. Stop pauses and returns to the start; the lid latch pauses before opening. In 3D, drag the housing to rotate it and double-click to reset. Gentle rotation and the optional **500 RPM** setting affect the visual speed only.
- **Vinyl:** a record with grooves and Relaxed, 33⅓ or 45 RPM rotation. Drag the needle to seek and play. The 3D turntable has a hinged dust cover, working speed buttons and a cue lever that lifts or lowers the needle to pause or play. Drag its housing to rotate it; double-click to reset the angle. Optional effects include crackle, hiss and groove skips.
-- **Cassette:** Clear, Smoke and Cream finishes, moving tape reels and optional transport sounds. Reels turn counterclockwise during forward playback and reverse while rewinding.
+- **Cassette:** Clear, Smoke and Cream tapes in a CP13-inspired portable player, with moving reels and optional transport sounds. The top buttons play or pause, seek backward or forward ten seconds, and stop playback. Press Stop again to open the door. Drag the side knob to adjust volume. In 3D, the clear panels reveal the transport, flywheel and belt; drag the housing to rotate it and double-click to reset. Reels turn counterclockwise during forward playback and reverse while rewinding.
- **TP-7:** a metal recorder with a draggable wheel, track display and working transport, rocker and volume controls. In 3D, drag the body to rotate it horizontally or tilt it vertically; double-click to reset the angle. The lower keys are Previous, Play/Pause and Next. The rocker seeks ten seconds, and the knob controls volume. The side keys open album details, the queue and the player menu. This is a playback appearance, without microphone recording.
- **Player bodies:** **Show player body** adds a turntable, portable cassette player or CD tray with a clear lid. Album changes exchange the medium with a brief sleeve or case animation. Tracks on the same album keep it in place, and playback starts immediately.
- **3D:** enable **3D player** for modeled discs, reels, cases and tonearm parts, with metallic surfaces and lighting tinted by Noctalia's current palette. Playback controls stay in their familiar positions. Mini mode remains compact, and reverse-side details stay flat for reading.
- **Seeking:** use the disc rim, vinyl needle or optional horizontal progress bar. Their previews stay in sync. Hold **Shift** for finer adjustments and **Esc** to cancel a drag.
- **Albums as records:** enable **Play albums as records** in Vinyl preferences to give each album track a groove band. A needle drop selects the song and position. Local mode uses loaded album tracks in track-number order; Cider starts the album and verifies the track before seeking. Missing durations or unavailable tracks fall back to single-song seeking. The circular and horizontal bars share the album timeline, so either can select a track and position.
-- **Reverse view:** press **F** for album details and tracks. The disc and cassette also support double-clicking to flip. Press **Y** for lyrics when available. Local lyrics can come from matching `.lrc` or `.txt` files or embedded metadata. **View artwork** opens the full cover.
+- **Reverse view:** press **F** for album details and tracks. In 2D, the disc and cassette also support double-clicking to flip. Press **Y** for lyrics when available. Local lyrics can come from matching `.lrc` or `.txt` files or embedded metadata. **View artwork** opens the full cover.
- **Mini mode:** a compact player with controls below the medium and an optional always-on-top setting. Hover or focus Next to preview the upcoming song when known.
+### TX-6 mixer
+
+In the TP-7 view, toggle **TX–6** beside the player. It works in 2D and 3D, with a modeled USB-C cable between the devices.
+
+- Channel 1 carries local TP-7 audio. Right-click channels 2–6 to load additional local files; all channels follow TP-7 playback and seeking.
+- The knob rows adjust high, mid and low EQ. Drag a fader or click its track to set the level. Press a channel key to mute; Shift-click to solo, or press the mixer's Shift button first.
+- The master knob controls player volume. FX I adds stereo delay; FX II enables compression. Hide or power off the mixer to bypass it.
+- The paired 3D view expands to make controls easier to reach. Buttons press inward and spring back on release.
+
+Mixing happens inside Spun. External USB hardware, recording, MIDI, synth mode and separate aux/cue outputs are not supported. With Cider, only master volume works because Cider plays its own audio. Additional tracks use private temporary audio caches, removed on unload or normal exit, with a 512 MiB limit per track (about 23 minutes).
+
### Browse through Cider
Use the top-left search button to browse songs, albums, playlists and artists without leaving Spun.
@@ -194,7 +205,7 @@ For focused player, artwork, lighting, geometry and media checks:
./scripts/test-3d.sh
```
-The default uses offscreen CPU rendering through Mesa and requires an available X display for its OpenGL context. It does not create visible windows. It checks recorder and turntable controls, physical rotation, seeking, rendered artwork and palette changes without exercising the full native window lifecycle.
+The default uses offscreen CPU rendering through Mesa and requires an available X display for its OpenGL context. It does not create visible windows. It checks CD, cassette, recorder, turntable and TX-6 controls, mixer audio processing, physical rotation, seeking, rendered artwork and palette changes without exercising the full native window lifecycle.
For the complete 3D interaction and Cider-fixture suites, run `SPUN_TEST_RENDERER=native ./scripts/test-3d.sh` in a separate Wayland or X11 test session. This includes projected seeking, tonearm gestures, lid transitions, scaling and mode combinations. Set `SPUN_TEST_SCREEN` to the dedicated output name and `SPUN_TEST_OUTPUT` to a local capture directory. Missing 3D rendering fails the checks instead of silently skipping them.
@@ -204,6 +215,14 @@ For large imports, run `QT_QPA_PLATFORM=offscreen QT_QPA_PLATFORMTHEME= ./build/
Run `python3 scripts/benchmark.py --output /tmp/spun-performance` for isolated performance comparisons. Offscreen results are not whole-desktop GPU measurements. `python3 scripts/make-demo.py` regenerates the original soundcheck after building and additionally requires FFmpeg.
+Use `python3 scripts/benchmark.py --three-d --media cd vinyl cassette tp7 tx6 --scenes idle playing --output /tmp/spun-3d-performance` to measure all five 3D assets. On supported Qt versions the report also includes draw calls, mesh and texture memory. Materials use small generated maps, a wallpaper-tinted studio probe and one 1024px shadow map; there are no downloaded texture packs. Render targets account for UI scaling and are capped at 1536px per side.
+
+`./build/spun --test-performance` measures mode-switch presentation latency and process memory with isolated, muted fixtures. Add `SPUN_PERF_PACING=1` in a native display session to measure animation updates and presented frames against that screen's refresh rate. `SPUN_PERF_MEDIA=cd,tx6` restricts the views, and `--capture-dir /tmp/spun-frames` saves the rendered results. Refresh-rate measurements require a visible, exposed window; offscreen frame counts do not measure display cadence.
+
+Motion uses Qt's frame clock and elapsed time. Hardware rendering on Wayland defaults to a threaded, vsync-driven render loop; `QSG_RENDER_LOOP` can override it. Actual frame rate depends on the scene and hardware. The CTest motion check verifies timing at simulated 60, 120, 165 and 240 Hz; it does not test physical displays at those rates.
+
+`SPUN_TEST_REVERSE_ONLY=1 ./build/spun --test-media-ui --capture-dir /tmp/spun-reverse` checks the rendered album reverse against both light and dark theme palettes, including text contrast and keyboard focus. It uses an isolated profile and does not change the desktop theme.
+
</details>
Before submitting substantial code contributions, open an issue to discuss scope and contributor licensing. A patch does not transfer its copyright; future commercial distribution needs appropriate rights to contributed code and compliance with third-party licenses.
diff --git a/qml/Cassette3D.qml b/qml/Cassette3D.qml
new file mode 100644
index 0000000..9f7c314
--- /dev/null
+++ b/qml/Cassette3D.qml
@@ -0,0 +1,264 @@
+import QtQuick
+import QtQuick3D
+import Spun 1.0
+
+Node {
+ id: deck
+ objectName: "cassettePlayer3D"
+ required property var app
+ required property Texture labelTexture
+ property alias lidNode: door
+ readonly property color glassColor: Qt.tint("#c5d2d8",Qt.alpha(app.accent,.08))
+ readonly property real doorAngle: app.cassetteControls ? app.cassetteControls.doorAngle : 0
+ function controlPoint(index) {
+ if(index<4)return mapPositionToScene(Qt.vector3d(-125+index*49,157.3,-12))
+ if(index===4)return mapPositionToScene(Qt.vector3d(214.5,75,-12))
+ return door.mapPositionToScene(Qt.vector3d(0,264,3))
+ }
+ Texture { id: brushed; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "brushed" } }
+ Texture { id: turned; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "turned" } }
+ Texture { id: beads; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "bead-normal" } }
+ Texture { id: fineMetal; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "metal-normal" } }
+ Texture { id: knurl; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "knurled-normal" } }
+ Texture { id: molded; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "molded" } }
+ PrincipledMaterial { id: aluminum; baseColor: "#cdd2d5"; metalness: .82; roughness: .38; roughnessMap: brushed; normalMap: beads; normalStrength: .14 }
+ PrincipledMaterial { id: metal; baseColor: "#a8b1b7"; metalness: .85; roughness: .4; roughnessMap: brushed; normalMap: fineMetal; normalStrength: .12 }
+ PrincipledMaterial { id: steel; baseColor: "#d6dadd"; metalness: 1; roughness: .24; roughnessMap: turned }
+ PrincipledMaterial { id: stamped; baseColor: "#b7bec2"; metalness: .88; roughness: .36; roughnessMap: brushed; normalMap: fineMetal; normalStrength: .1 }
+ PrincipledMaterial { id: rubber; baseColor: "#15191c"; roughness: .84; roughnessMap: molded }
+ PrincipledMaterial { id: tapePlastic; baseColor: "#dedbcc"; roughness: .54; roughnessMap: molded }
+ PrincipledMaterial { id: gold; baseColor: "#c89d57"; metalness: .95; roughness: .29; roughnessMap: turned; normalMap: fineMetal; normalStrength: .13 }
+ PrincipledMaterial { id: glass; baseColor: deck.glassColor; alphaMode: PrincipledMaterial.Blend; opacity: .06; roughness: .13; clearcoatAmount: .3; clearcoatRoughnessAmount: .16; depthDrawMode: Material.NeverDepthDraw }
+ PrincipledMaterial { id: glassEdge; baseColor: "#a5b9bf"; alphaMode: PrincipledMaterial.Blend; opacity: .4; roughness: .2; depthDrawMode: Material.NeverDepthDraw }
+ ReelGeometry { id: reelWeb }
+ CassetteGearGeometry { id: gearMesh }
+ component Solid: Model {
+ id: solid
+ property vector3d size: Qt.vector3d(20,20,4)
+ property real rounding: 2
+ property color tint: "#30363b"
+ property int cassetteControl: -1
+ property Material finish: PrincipledMaterial { baseColor: solid.tint; roughness: .55; roughnessMap: molded }
+ pickable: true
+ geometry: DeckGeometry { dimensions: solid.size; radius: solid.rounding }
+ materials: [finish]
+ }
+ component Ring: Model {
+ id: ring
+ property real radius: 10
+ property real hole: .2
+ property real depth: 2
+ property bool grooves: false
+ property int cassetteControl: -1
+ property Material finish: rubber
+ pickable: true
+ geometry: RecordGeometry { radius: ring.radius; hole: ring.hole; depth: ring.depth; grooves: ring.grooves }
+ materials: [finish]
+ }
+ component Screw: Node {
+ Ring { radius: 2.7; hole: .25; depth: 1.2; finish: steel }
+ Solid { size: Qt.vector3d(3.5,.7,.25); z: .7; rounding: .2; finish: rubber }
+ Solid { size: Qt.vector3d(.7,3.5,.25); z: .7; rounding: .2; finish: rubber }
+ }
+ component TapeSpan: Model {
+ property vector2d start
+ property vector2d end
+ source: "#Cube"
+ x: (start.x+end.x)/2; y: (start.y+end.y)/2; z: 14
+ eulerRotation.z: Math.atan2(end.y-start.y,end.x-start.x)*180/Math.PI
+ scale: Qt.vector3d(Math.hypot(end.x-start.x,end.y-start.y)/100,.012,.03)
+ materials: PrincipledMaterial { baseColor: "#352017"; roughness: .47 }
+ }
+ // An open frame keeps the front tape and rear transport in separate cavities.
+ Solid { objectName: "threeDEnclosure"; size: Qt.vector3d(400,282,5); z: -14; rounding: 7; finish: aluminum }
+ Repeater3D { model: 2; Solid { required property int index; x: index?198:-198; z: -12; size: Qt.vector3d(8,280,78); rounding: 3; finish: aluminum } }
+ Repeater3D { model: 2; Solid { required property int index; y: index?138:-138; z: -12; size: Qt.vector3d(394,8,78); rounding: 3; finish: aluminum } }
+ Repeater3D { model: 2; Solid { required property int index; x: index?192:-192; z: 25.8; size: Qt.vector3d(1.2,267,1.2); rounding: .5; finish: steel } }
+ Repeater3D { model: 2; Solid { required property int index; y: index?132:-132; z: 25.8; size: Qt.vector3d(385,1.2,1.2); rounding: .5; finish: steel } }
+ Solid { objectName: "threeDTopPlate"; size: Qt.vector3d(375,251,1.5); z: -10.5; rounding: 4; finish: metal }
+ Repeater3D { model: 4; Screw { required property int index; x: index%2?182:-182; y: index<2?122:-122; z: -8.8 } }
+ // Recesses and stamped brackets remain visible around a loaded cassette.
+ Repeater3D { model: 2; Node { required property int index; x: index?178:-178; z: -2; Solid { size: Qt.vector3d(9,187,12); rounding: 2; finish: rubber } Solid { size: Qt.vector3d(7,49,2); y: 48; z: 8; finish: steel } Screw { y: 58; z: 10 } } }
+ Repeater3D { model: 2; Node { required property int index; x: index?78.6:-78.6; y: 13; z: -4; Ring { radius: 15; depth: 7; finish: rubber } Ring { radius: 6; depth: 12; finish: steel } } }
+ Node {
+ objectName: "threeDMedium"
+ x: app.swapOffset*.86; opacity: app.incomingOpacity
+ Node {
+ visible: deck.app.deckPlayer.count>0
+ objectName: "threeDCassette"
+ Solid { objectName: "cassetteShell3D"; size: Qt.vector3d(346,214,12); y: 4; z: 4; rounding: 12; finish: PrincipledMaterial { baseColor: Qt.darker(deck.app.cassetteShell,1.4); alphaMode: PrincipledMaterial.Blend; opacity: player.cassetteFinish === "clear" ? .68 : 1; roughness: .32 } }
+ Solid { objectName: "threeDTapeWell"; size: Qt.vector3d(296,136,3); y: 13; z: 10.2; rounding: 25; finish: rubber }
+ Solid { objectName: "threeDLabelBacking"; size: Qt.vector3d(320,36,.8); y: 91; z: 13.1; rounding: 6; tint: "#aa9e88" }
+ Solid { size: Qt.vector3d(318,34,1.5); y: 91; z: 14; rounding: 6; finish: PrincipledMaterial { baseColorMap: deck.labelTexture; roughness: .88 } }
+ Solid { size: Qt.vector3d(326,34,9); y: -76; z: 12; rounding: 6; tint: deck.app.cassetteShell }
+ Repeater3D {
+ model: 2
+ Node {
+ id: reel
+ required property int index
+ objectName: "threeDReel"+index
+ x: index?78.6:-78.6; y: 13; z: 13
+ readonly property real fill: index?deck.app.cassetteVisualProgress:1-deck.app.cassetteVisualProgress
+ Ring { radius: 60; hole: .2; depth: .6; z: -2; finish: rubber }
+ Ring { radius: Math.sqrt(1936+3993*reel.fill)*.77; hole: 31; depth: 5; grooves: true; finish: PrincipledMaterial { baseColor: "#32231b"; roughness: .64 } }
+ Ring { objectName: "threeDReelBezel"+reel.index; radius: 62; hole: 60; depth: 1.5; z: 8; finish: rubber }
+ Node {
+ objectName: "threeDHub"+reel.index
+ eulerRotation.z: -(reel.index?deck.app.cassetteRightAngle:deck.app.cassetteLeftAngle)
+ Model { objectName: "threeDReelWeb"+reel.index; geometry: reelWeb; z: 2; materials: tapePlastic }
+ Ring { radius: 27.5; hole: 25.5; depth: .8; z: 5.2; finish: tapePlastic }
+ }
+ }
+ }
+ Solid { objectName: "threeDTapeRibbon"; size: Qt.vector3d(286,1.2,3); y: -58; z: 14; rounding: .3; tint: "#352017" }
+ Repeater3D {
+ model: 2
+ Node {
+ id: tapeGuide
+ required property int index
+ readonly property real side: index?1:-1
+ readonly property real packRadius: Math.sqrt(1936+3993*(index?deck.app.cassetteVisualProgress:1-deck.app.cassetteVisualProgress))*.77
+ readonly property real tangent: Math.sqrt(64.4*64.4+61*61-Math.pow(packRadius-10,2))/(64.4*64.4+61*61)
+ readonly property real radial: (packRadius-10)/(64.4*64.4+61*61)
+ readonly property vector2d normal: Qt.vector2d(side*(64.4*radial+61*tangent),-61*radial+64.4*tangent)
+ TapeSpan {
+ objectName: "threeDTapeFeed"+tapeGuide.index
+ start: Qt.vector2d(tapeGuide.side*78.6+tapeGuide.packRadius*tapeGuide.normal.x,13+tapeGuide.packRadius*tapeGuide.normal.y)
+ end: Qt.vector2d(tapeGuide.side*143+10*tapeGuide.normal.x,-48+10*tapeGuide.normal.y)
+ }
+ Ring { x: tapeGuide.side*143; y: -59; z: 14; radius: 4; hole: 1.2; depth: 5; finish: steel }
+ }
+ }
+ Repeater3D {
+ model: 2
+ Node {
+ required property int index
+ x: index?143:-143; y: -48; z: 13
+ Ring { radius: 10; hole: 3; depth: 7; finish: rubber }
+ Ring { radius: 3; hole: .5; depth: 8; finish: metal }
+ }
+ }
+ Solid { objectName: "threeDTapePressureSpring"; size: Qt.vector3d(44,3,1); y: -61; z: 12; rounding: .5; finish: gold }
+ Solid { size: Qt.vector3d(18,4,3); y: -60; z: 13; rounding: 1; tint: "#948372" }
+ Solid { size: Qt.vector3d(36,18,1); y: -83; z: 17; rounding: 3; finish: rubber }
+ Solid { objectName: "threeDTapeHead"; size: Qt.vector3d(26,13,5); y: -83; z: 19; rounding: 3; finish: steel }
+ Solid { size: Qt.vector3d(.7,11,.3); y: -83; z: 21.6; rounding: .2; tint: "#34383b" }
+ Repeater3D {
+ model: 8
+ Solid { required property int index; x: (index<4?-1:1)*(123+(index%4)*8); y: -73; z: 17; size: Qt.vector3d(2,20,1); rounding: .5; tint: Qt.darker(deck.app.cassetteShell,1.3) }
+ }
+ Solid { size: Qt.vector3d(5,111,4); y: 13; z: 21; rounding: 2; tint: deck.app.cassetteShell }
+ Solid { objectName: "threeDTapeWindow"; castsShadows: false; receivesShadows: false; size: Qt.vector3d(296,136,1); y: 13; z: 23; rounding: 25; finish: PrincipledMaterial { baseColor: deck.glassColor; metalness: 0; alphaMode: PrincipledMaterial.Blend; opacity: .065; roughness: .19; clearcoatAmount: .6; clearcoatRoughnessAmount: .15 } }
+ Repeater3D {
+ model: 4
+ Node {
+ required property int index
+ x: (index%2?1:-1)*159; y: (index<2?1:-1)*94; z: 13
+ Ring { radius: 3.8; hole: .4; depth: 2; finish: metal }
+ Solid { size: Qt.vector3d(5,1,1); z: 1.2; rounding: .2; tint: "#202428" }
+ }
+ }
+ }
+ }
+ // The real transport has a heavy flywheel and a belt. They are visible from the back.
+ Node {
+ objectName: "cassetteRearMechanism"; z: -20; eulerRotation.y: 180
+ Solid { size: Qt.vector3d(365,241,3); rounding: 5; finish: rubber }
+ Model { objectName: "cassetteStampedCarrier"; x: 20; y: 49; z: 4; geometry: CassettePlateGeometry {} materials: stamped }
+ // Turned-up flanges and bearing bosses give the carrier a physical edge.
+ Solid { x: 20; y: 104; z: 7; size: Qt.vector3d(250,2,9); rounding: .8; finish: stamped }
+ Solid { x: -108; y: 25; z: 7; size: Qt.vector3d(2,53,9); rounding: .8; finish: stamped }
+ Solid { x: 78; y: 37; z: 7; size: Qt.vector3d(2,37,8); rounding: .6; finish: stamped }
+ Repeater3D { model: 3; Node { required property int index; x: [-64,23,137][index]; y: [89,29,90][index]; z: 7; Ring { radius: 5.5; hole: 2; depth: 4; finish: stamped } Screw { z: 2.6 } } }
+ Solid { x: 55; y: -30; z: 4; size: Qt.vector3d(28,96,4); rounding: 2; finish: steel; eulerRotation.z: -24 }
+ Solid { x: -64; y: 28; z: 5; size: Qt.vector3d(15,110,3); rounding: 2; finish: metal; eulerRotation.z: 28 }
+ Node {
+ objectName: "cassetteFlywheel"; x: -114; y: -28; z: 13; eulerRotation.z: app.cassetteLeftAngle*1.8
+ Ring { radius: 48; depth: 12; finish: gold }
+ Ring { radius: 48.9; hole: 47.4; depth: 2.2; z: 8; finish: rubber }
+ Ring { radius: 46.8; hole: 45.8; depth: .7; z: 6.3; finish: steel }
+ Ring { radius: 7; depth: 1; z: 6.5; finish: steel }
+ Screw { z: 7.3 }
+ }
+ Node {
+ x: 87; y: 68; z: 12
+ Ring { radius: 24; depth: 18; finish: rubber }
+ Ring { radius: 19; depth: 1.8; z: 9.5; finish: stamped }
+ Ring { radius: 10; depth: 20; finish: gold }
+ Ring { radius: 10.8; hole: 9.5; depth: 2.2; z: 9; finish: rubber }
+ Ring { radius: 3; depth: 22; finish: steel }
+ Repeater3D { model: 2; Screw { required property int index; x: index?15:-15; z: 11 } }
+ }
+ // Tangent belt runs between the motor pulley and the flywheel.
+ Solid { x: -22.5; y: 47; z: 21; size: Qt.vector3d(227.6,1.8,2.2); eulerRotation.z: 15.8; rounding: .5; finish: rubber }
+ Solid { x: -1; y: -6; z: 21; size: Qt.vector3d(225.3,1.8,2.2); eulerRotation.z: 35.2; rounding: .5; finish: rubber }
+ Repeater3D {
+ model: [{x:-32,y:-64,s:1.35},{x:13,y:-50,s:1.05},{x:40,y:-67,s:.72},{x:79,y:-56,s:1.4}]
+ Node {
+ required property var modelData; required property int index
+ x: modelData.x; y: modelData.y; z: 9
+ Model { objectName: "cassetteGear"+index; geometry: gearMesh; scale: Qt.vector3d(modelData.s,modelData.s,1); eulerRotation.z: (index%2?1:-1)*app.cassetteRightAngle/modelData.s; materials: index===3?rubber:tapePlastic }
+ Ring { radius: 3; depth: 6; z: 1; finish: steel }
+ }
+ }
+ Repeater3D { model: 6; Screw { required property int index; x: [-172,169,-93,20,153,60][index]; y: [102,99,-102,91,-99,22][index]; z: 7 } }
+ // Tension spring between the selector rail and its return anchor.
+ Node {
+ x: -63; y: 63; z: 12; eulerRotation.z: -28
+ Solid { size: Qt.vector3d(1.1,45,1.1); rounding: .4; finish: steel }
+ Repeater3D { model: 10; Ring { required property int index; radius: 2.6; hole: 1.6; depth: .65; y: -12+index*2.7; eulerRotation.x: 90; finish: steel } }
+ }
+ Solid { x: 137; y: 70; z: 6; size: Qt.vector3d(19,58,2); rounding: 2; eulerRotation.z: -20; tint: "#a36a2d" }
+ Repeater3D { model: 5; Solid { required property int index; x: 132+index*2; y: 72; z: 7.3; size: Qt.vector3d(.7,45,.3); rounding: .2; eulerRotation.z: -20; finish: gold } }
+ Solid { objectName: "cassetteRearGlass"; size: Qt.vector3d(388,268,1.6); z: 33; rounding: 6; finish: glass; castsShadows: false; receivesShadows: false }
+ Repeater3D { model: 4; Screw { required property int index; x: index%2?184:-184; y: index<2?124:-124; z: 34.4 } }
+ }
+ Repeater3D {
+ model: 4
+ Node {
+ id: button; required property int index
+ readonly property real pressure: deck.app.cassetteControls ? deck.app.cassetteControls.keyItems[index].pressure : 0
+ x: -125+index*49; y: 142; z: -12; eulerRotation.x: -90
+ Ring { cassetteControl: button.index; radius: 18; depth: 1.4; finish: rubber }
+ Ring { objectName: "cassetteKey3D"+button.index; cassetteControl: button.index; radius: 16.2; depth: 14; z: 8-3.6*button.pressure; finish: aluminum }
+ Node {
+ z: 15.2-3.6*button.pressure
+ // Raised inlaid legends remain legible while viewing the top edge.
+ Model { source: "#Rectangle"; property int cassetteControl: button.index; pickable: true; scale: Qt.vector3d(.15,.15,1); materials: PrincipledMaterial { lighting: PrincipledMaterial.NoLighting; alphaMode: PrincipledMaterial.Blend; baseColorMap: Texture { sourceItem: Item { width: 48; height: 48; Glyph { anchors.fill: parent; visible: button.index<3; name: ["play","previous","next","play"][button.index]; ink: "#424b51" } Rectangle { anchors.centerIn: parent; width: 22; height: 22; color: "#424b51"; visible: button.index===3 } } } } }
+ }
+ }
+ }
+ Node {
+ x: 201; y: 75; z: -12; eulerRotation.y: 90
+ Ring { radius: 19; depth: 1.5; finish: rubber }
+ Ring { objectName: "cassetteVolume3D"; cassetteControl: 4; radius: 17; depth: 12; z: 7; finish: PrincipledMaterial { baseColor: "#c7cdd0"; metalness: .88; roughness: .37; normalMap: knurl; normalStrength: .26; roughnessMap: brushed } }
+ Ring { cassetteControl: 4; radius: 15.2; depth: .7; z: 13.4; finish: steel }
+ Solid { cassetteControl: 4; x: 10; z: 14; size: Qt.vector3d(5,1,.4); rounding: .3; finish: rubber }
+ }
+ Node {
+ x: 202.5; y: -23; z: -12; eulerRotation.y: 90
+ Solid { size: Qt.vector3d(38,139,1); rounding: 14; finish: metal }
+ Solid { y: 8; z: 1; size: Qt.vector3d(8,27,2); rounding: 3.8; finish: rubber }
+ Solid { y: 8; z: 2.1; size: Qt.vector3d(1.8,17,1); rounding: .6; finish: metal }
+ Ring { y: -42; z: 1.5; radius: 9; hole: 4.8; depth: 2; finish: rubber }
+ Ring { y: -42; z: 3; radius: 5.5; hole: 4.8; depth: .5; finish: steel }
+ Ring { y: 46; z: 1; radius: 1.3; depth: .8; finish: PrincipledMaterial { baseColor: deck.app.deckPlayer.playing?deck.app.accent:"#343b40"; lighting: PrincipledMaterial.NoLighting } }
+ }
+ Repeater3D { model: 2; Node { required property int index; x: index?142:-142; y: -133; z: 28; Ring { radius: 4.3; depth: 27; eulerRotation.y: 90; finish: metal } } }
+ Repeater3D { model: 2; Node { required property int index; x: index?159:-159; y: -133; z: 28; eulerRotation.y: 90; Ring { radius: 2; depth: 2; finish: steel } } }
+ Node {
+ id: door; objectName: "cassetteDoor3D"
+ y: -133; z: 30; eulerRotation.x: deck.doorAngle
+ Solid { objectName: "threeDLid"; pickable: false; y: 133; size: Qt.vector3d(382,264,1.8); rounding: 6; finish: glass; castsShadows: false; receivesShadows: false }
+ Repeater3D { model: 2; Solid { required property int index; x: index?190:-190; y: 133; size: Qt.vector3d(3,260,4.5); rounding: 1; finish: glassEdge; castsShadows: false } }
+ Repeater3D { model: 2; Solid { required property int index; y: index?263:3; size: Qt.vector3d(379,3,4.5); rounding: 1; finish: glassEdge; castsShadows: false } }
+ Solid { objectName: "cassetteDoorLatch3D"; cassetteControl: 5; y: 264; z: 3; size: Qt.vector3d(30,12,8); rounding: 2; finish: aluminum }
+ Repeater3D { model: 2; Solid { required property int index; x: index?183:-183; y: 152; z: -3; size: Qt.vector3d(7,33,8); rounding: 1.5; finish: glassEdge; castsShadows: false } }
+ }
+ Model {
+ objectName: "cassetteProgress3D"; y: -15.2; z: 31
+ visible: app.deckPlayer.count>0
+ geometry: WaveGeometry { progress: app.cassetteVisualProgress; phase: app.wavePhase; amplitude: app.deckPlayer.playing?2.4:0; linear: true }
+ materials: PrincipledMaterial { baseColor: app.accent; lighting: PrincipledMaterial.NoLighting; cullMode: Material.NoCulling }
+ }
+}
diff --git a/qml/CassetteControls.qml b/qml/CassetteControls.qml
new file mode 100644
index 0000000..7c5aa34
--- /dev/null
+++ b/qml/CassetteControls.qml
@@ -0,0 +1,88 @@
+import QtQuick
+
+Item {
+ id: controls
+ required property var app
+ objectName: "cassetteControls"
+ property int pressedControl: -1
+ property bool armed: false
+ property bool doorOpen: false
+ property real startY: 0
+ property real startVolume: 0
+ readonly property var keyItems: [play, rewind, forward, eject, volume, latch]
+ readonly property bool available: app.cassette && app.bodyVisible && !app.discFlipped && !app.menuOpen && !app.swapRunning
+ property real doorAngle: app.swapRunning ? app.lidOpen*55 : doorOpen ? 58 : 0
+ Behavior on doorAngle { enabled: controls.app.animate; NumberAnimation { duration: 300; easing.type: Easing.InOutCubic } }
+ function canUse(index) {
+ return available && (index>=3 || (app.deckPlayer.count>0 && (index===0 || !app.useCider || app.ciderService.canSeek)))
+ }
+ function cancel() { pressedControl=-1;armed=false }
+ function begin(index,y) { cancel();if(!canUse(index))return;pressedControl=index;armed=true;startY=y;startVolume=app.deckPlayer.volume }
+ function move(y,index) {
+ if(pressedControl===4)app.deckPlayer.volume=Math.max(0,Math.min(1,startVolume+(startY-y)/150))
+ else armed=index===pressedControl
+ }
+ function activate(index) {
+ if(!canUse(index))return
+ if(index===0) { doorOpen=false;app.deckPlayer.toggle() }
+ else if(index===1)app.deckPlayer.seek(Math.max(0,app.deckPlayer.position-10000))
+ else if(index===2)app.deckPlayer.seek(Math.min(app.deckPlayer.duration,app.deckPlayer.position+10000))
+ else if(index===3) {
+ if(app.deckPlayer.playing)app.deckPlayer.pause()
+ else doorOpen=!doorOpen
+ } else if(index===5) { if(!doorOpen)app.deckPlayer.pause();doorOpen=!doorOpen }
+ }
+ function end() { const index=pressedControl,run=armed;cancel();if(run && index!==4)activate(index) }
+ onAvailableChanged: if(!available)cancel()
+ Connections { target: controls.app.deckPlayer; function onPlayingChanged() { if(controls.app.deckPlayer.playing)controls.doorOpen=false } }
+ Connections { target: controls.app; function onCassetteTrackIdentityChanged(){controls.cancel()} }
+ component Key: Item {
+ id: key
+ required property int index
+ required property string caption
+ property string icon: ""
+ property bool knob: false
+ readonly property real pressure: Math.max(0,Math.min(1.04,travel.value))
+ SpunSpring { id: travel; targetValue: controls.pressedControl===key.index && controls.armed ? 1 : 0; epsilon: .005; animation.spring: 5.2; animation.damping: .38 }
+ enabled: controls.canUse(index)
+ activeFocusOnTab: true
+ Accessible.role: knob ? Accessible.Slider : Accessible.Button
+ Accessible.name: caption
+ Accessible.onPressAction: controls.activate(index)
+ Keys.onReturnPressed: controls.activate(index)
+ Keys.onSpacePressed: controls.activate(index)
+ Keys.onUpPressed: if(knob)controls.app.deckPlayer.volume=Math.min(1,controls.app.deckPlayer.volume+.05)
+ Keys.onDownPressed: if(knob)controls.app.deckPlayer.volume=Math.max(0,controls.app.deckPlayer.volume-.05)
+ Rectangle {
+ anchors.fill: parent; anchors.margins: 1
+ radius: key.knob ? 6 : 5
+ color: "#32383d"
+ }
+ Rectangle {
+ x: 1; y: 1+key.pressure*3; width: parent.width-2; height: parent.height-3
+ radius: key.knob ? 6 : 5
+ border.width: key.activeFocus ? 1.5 : .6; border.color: key.activeFocus ? controls.app.accent : "#8b989f"
+ gradient: Gradient { GradientStop { position: 0; color: "#e9edf0" } GradientStop { position: .18; color: "#c8cfd4" } GradientStop { position: .78; color: "#adb6bd" } GradientStop { position: 1; color: "#707d87" } }
+ Glyph { anchors.centerIn: parent; width: 13; height: 13; name: key.icon; ink: "#38434b"; visible: key.icon!=="" && key.icon!=="stop" }
+ Rectangle { anchors.centerIn: parent; width: 8; height: 8; color: "#38434b"; visible: key.icon==="stop" }
+ Repeater { model: key.knob ? 7 : 0; Rectangle { required property int index; x: 3; y: 4+index*3.5; width: parent.width-6; height: .65; color: "#6e7d85"; opacity: .55 } }
+ }
+ MouseArea {
+ anchors.fill: parent; preventStealing: true
+ cursorShape: key.knob ? Qt.SizeVerCursor : Qt.PointingHandCursor
+ onPressed: mouse => { key.forceActiveFocus();controls.begin(key.index,mapToItem(controls,mouse.x,mouse.y).y) }
+ onPositionChanged: mouse => controls.move(mapToItem(controls,mouse.x,mouse.y).y,containsMouse?key.index:-1)
+ onReleased: controls.end()
+ onCanceled: controls.cancel()
+ onWheel: wheel => { controls.app.deckPlayer.volume=Math.max(0,Math.min(1,controls.app.deckPlayer.volume+wheel.angleDelta.y/2400));wheel.accepted=true }
+ hoverEnabled: true
+ SpunToolTip { visible: parent.containsMouse && !parent.pressed && !controls.app.threeDActive; text: key.caption; timeout: 2500 }
+ }
+ }
+ Key { id: play; objectName: "cassettePlay"; index: 0; x: 123; y: 137; width: 34; height: 21; caption: controls.app.deckPlayer.playing?"Pause":"Play"; icon: controls.app.deckPlayer.playing?"pause":"play" }
+ Key { id: rewind; objectName: "cassetteRewind"; index: 1; x: 172; y: 137; width: 34; height: 21; caption: "Back 10 seconds"; icon: "previous" }
+ Key { id: forward; objectName: "cassetteForward"; index: 2; x: 221; y: 137; width: 34; height: 21; caption: "Forward 10 seconds"; icon: "next" }
+ Key { id: eject; objectName: "cassetteStop"; index: 3; x: 270; y: 137; width: 34; height: 21; caption: controls.app.deckPlayer.playing?"Stop":"Open or close cassette door"; icon: "stop" }
+ Key { id: volume; objectName: "cassetteVolume"; index: 4; x: 462; y: 203; width: 18; height: 34; caption: "Volume, drag up or down"; knob: true }
+ Key { id: latch; objectName: "cassetteLatch"; index: 5; x: 250; y: 160; width: 30; height: 9; caption: controls.doorOpen?"Close cassette door":"Open cassette door" }
+}
diff --git a/qml/Cd3D.qml b/qml/Cd3D.qml
new file mode 100644
index 0000000..7c04953
--- /dev/null
+++ b/qml/Cd3D.qml
@@ -0,0 +1,167 @@
+import QtQuick
+import QtQuick3D
+import Spun 1.0
+
+Node {
+ id: deck
+ objectName: "cdPlayer3D"
+ required property var app
+ required property Texture artworkTexture
+ required property Texture outgoingTexture
+ property alias lidNode: lid
+ readonly property real doorAngle: app.cdControls ? app.cdControls.doorAngle : 0
+ function controlPoint(index) {
+ if(index<6)return front.mapPositionToScene(Qt.vector3d(81+28*(index%3),index<3?10:-10,5))
+ if(index===6)return front.mapPositionToScene(Qt.vector3d(184,0,12))
+ if(index===7)return lid.mapPositionToScene(Qt.vector3d(0,-394,2))
+ return front.mapPositionToScene(Qt.vector3d(index===8?-126:-91,0,4))
+ }
+ Texture { id: brushed; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "brushed" } }
+ Texture { id: turned; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "turned" } }
+ Texture { id: micro; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "metal-normal" } }
+ Texture { id: molded; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "molded" } }
+ Texture { id: optical; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "disc" } }
+ Texture { id: knurl; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "knurled-normal" } }
+ PrincipledMaterial { id: aluminum; baseColor: "#cbd0d3"; metalness: .86; roughness: .34; roughnessMap: brushed; normalMap: micro; normalStrength: .11 }
+ PrincipledMaterial { id: polished; baseColor: "#d0d6d8"; metalness: 1; roughness: .22; roughnessMap: turned }
+ PrincipledMaterial { id: rubber; baseColor: "#12171b"; roughness: .85; roughnessMap: molded }
+ PrincipledMaterial { id: graphite; baseColor: "#343e44"; metalness: .72; roughness: .36; roughnessMap: brushed }
+ PrincipledMaterial { id: tray; baseColor: "#aab2b8"; metalness: .68; roughness: .43; roughnessMap: brushed }
+ PrincipledMaterial { id: glass; baseColor: Qt.tint("#dce6e9",Qt.alpha(app.accent,.07)); alphaMode: PrincipledMaterial.Blend; opacity: .065; roughness: .13; metalness: 0; clearcoatAmount: .65; clearcoatRoughnessAmount: .12; cullMode: Material.BackFaceCulling; depthDrawMode: Material.NeverDepthDraw }
+ PrincipledMaterial { id: glassEdge; baseColor: "#a9bec4"; alphaMode: PrincipledMaterial.Blend; opacity: .34; roughness: .16; metalness: .18; cullMode: Material.NoCulling }
+ PrincipledMaterial { id: discSilver; baseColorMap: optical; metalness: .86; roughness: .22; clearcoatAmount: .75; clearcoatRoughnessAmount: .13 }
+ component Solid: Model {
+ id: solid
+ property vector3d size: Qt.vector3d(20,20,10)
+ property real rounding: 2
+ property Material finish: aluminum
+ property int cdControl: -1
+ pickable: true
+ geometry: DeckGeometry { dimensions: solid.size; radius: solid.rounding }
+ materials: [finish]
+ }
+ component Ring: Model {
+ id: ring
+ property real radius: 10
+ property real hole: .2
+ property real depth: 2
+ property int cdControl: -1
+ property Material finish: rubber
+ pickable: true
+ geometry: RecordGeometry { radius: ring.radius; hole: ring.hole; depth: ring.depth }
+ materials: [finish]
+ }
+ component Screw: Node {
+ Ring { radius: 2.3; depth: 1; finish: polished }
+ Solid { size: Qt.vector3d(3,.65,.25); rounding: .2; z: .6; finish: rubber }
+ Solid { size: Qt.vector3d(.65,3,.25); rounding: .2; z: .6; finish: rubber }
+ }
+ // Separate extrusions leave a real recessed well below the disc and lid.
+ Solid { objectName: "threeDEnclosure"; size: Qt.vector3d(426,420,8); z: -51; rounding: 7 }
+ Repeater3D { model: 2; Solid { required property int index; x: index?209:-209; z: -23; size: Qt.vector3d(8,412,56); rounding: 3 } }
+ Repeater3D { model: 2; Solid { required property int index; y: index?206:-206; z: -23; size: Qt.vector3d(420,8,56); rounding: 3 } }
+ Solid { objectName: "threeDTopPlate"; size: Qt.vector3d(410,404,4); z: -10; rounding: 4; finish: tray }
+ Ring { radius: 188; hole: 181; depth: 11; z: -3; finish: graphite }
+ Ring { radius: 181; depth: 2; z: -6; finish: rubber }
+ Ring { radius: 187.8; hole: 186.7; depth: .5; z: 2.8; finish: polished }
+ // Finger scoops and suspension pads outside the CD recess.
+ Repeater3D { model: 2; Ring { required property int index; x: index?135:-135; y: -135; z: -6.7; radius: 19; depth: 1; finish: rubber } }
+ Repeater3D { model: 4; Screw { required property int index; x: index%2?197:-197; y: index<2?193:-193; z: -6.5 } }
+ Solid { objectName: "cdLaserSled"; x: 0; y: 83; z: -3; size: Qt.vector3d(26,104,4); rounding: 3; finish: graphite }
+ Repeater3D { model: 2; Solid { required property int index; x: index?9:-9; y: 82; z: -.5; size: Qt.vector3d(1.6,97,1.6); rounding: .7; finish: polished } }
+ Ring { y: 57; z: 1.5; radius: 5; depth: 1.8; finish: PrincipledMaterial { baseColor: "#466a85"; metalness: .6; roughness: .13; clearcoatAmount: 1 } }
+ Node {
+ objectName: "threeDMedium"; visible: app.deckPlayer.count>0
+ x: app.swapOffset*.86; z: app.lidOpen*24; opacity: app.incomingOpacity
+ eulerRotation.z: -app.spinAngle
+ Ring { objectName: "threeDRecord"; radius: 176; hole: 15; depth: 1.2; z: 5; finish: discSilver }
+ Ring { objectName: "threeDRecordLabel"; radius: 169; hole: 32; depth: .22; z: 5.76; finish: PrincipledMaterial { baseColorMap: deck.artworkTexture; roughness: .53; clearcoatAmount: .18; clearcoatRoughnessAmount: .3 } }
+ Ring { objectName: "threeDOpticalRim"; radius: 175.6; hole: 169.2; depth: .12; z: 5.66; finish: discSilver }
+ Ring { radius: 33; hole: 31.4; depth: .25; z: 5.85; finish: polished }
+ Ring { radius: 31.4; hole: 15; depth: .8; z: 5.4; finish: glassEdge; castsShadows: false }
+ Ring { radius: 26; hole: 25.4; depth: .25; z: 5.9; finish: polished }
+ }
+ Node {
+ objectName: "threeDOutgoingMedium"; visible: app.outgoingOpacity>0
+ x: app.outgoingOffset*.86; z: app.lidOpen*24; opacity: app.outgoingOpacity; eulerRotation.z: -app.outgoingAngle
+ Ring { radius: 176; hole: 15; depth: 1.2; z: 5; finish: discSilver }
+ Ring { radius: 169; hole: 32; depth: .22; z: 5.76; finish: PrincipledMaterial { baseColorMap: deck.outgoingTexture; roughness: .53 } }
+ }
+ Node {
+ objectName: "threeDCdSpindle"; z: 7; eulerRotation.z: -app.spinAngle
+ Ring { radius: 14.3; hole: 2; depth: 9; finish: graphite }
+ Ring { radius: 11.8; hole: 3.2; depth: .7; z: 4.9; finish: polished }
+ Ring { radius: 2.8; depth: 9.6; finish: polished }
+ Repeater3D { model: 3; Node { required property int index; eulerRotation.z: index*120; Model { objectName: "threeDSpindleClip"+index; source: "#Sphere"; x: 13; z: 1; scale: Qt.vector3d(.05,.05,.05); materials: polished } Screw { x: 7; z: 5.4 } } }
+ }
+ Repeater3D {
+ model: 2
+ Node {
+ required property int index; x: index?137:-137; y: 196; z: 11
+ Solid { size: Qt.vector3d(35,15,8); rounding: 2; finish: graphite }
+ Ring { radius: 5.5; depth: 31; eulerRotation.y: 90; finish: polished }
+ Repeater3D { model: 3; Ring { required property int index; radius: 5.65; hole: 4.7; depth: .6; x: -9+index*9; eulerRotation.y: 90; finish: graphite } }
+ }
+ }
+ Node {
+ id: lid; y: 197; z: 16; eulerRotation.x: -deck.doorAngle
+ Solid { objectName: "threeDLid"; size: Qt.vector3d(407,399,2.4); y: -197; rounding: 4; finish: glass; castsShadows: false; receivesShadows: false }
+ Repeater3D { model: 2; Solid { required property int index; x: index?203:-203; y: -197; size: Qt.vector3d(4,397,4.5); rounding: 1.2; finish: polished; castsShadows: false } }
+ Repeater3D { model: 2; Solid { required property int index; y: index?-395:1; size: Qt.vector3d(405,4,4.5); rounding: 1.2; finish: polished; castsShadows: false } }
+ Repeater3D { model: 2; Solid { required property int index; x: index?200:-200; y: -197; z: .1; size: Qt.vector3d(.9,391,2.8); rounding: .3; finish: glassEdge; castsShadows: false } }
+ Solid { objectName: "cdLidLatch3D"; cdControl: 7; y: -394; z: 1.4; size: Qt.vector3d(31,11,5); rounding: 2; finish: graphite }
+ Solid { cdControl: 7; y: -394; z: 4.1; size: Qt.vector3d(17,1.1,.5); rounding: .4; finish: polished }
+ }
+ Node {
+ id: front; y: -211; z: -24; eulerRotation.x: 90
+ Solid { objectName: "cdFrontGlass"; size: Qt.vector3d(411,48,2.3); rounding: 17; finish: PrincipledMaterial { baseColor: "#0c1419"; roughness: .18; metalness: .14; clearcoatAmount: .9; clearcoatRoughnessAmount: .1 } }
+ Repeater3D { model: 2; Node { required property int index; x: index?-154:-183; z: 2; Ring { radius: index?5.8:8; hole: index?3.8:5.5; depth: 2; finish: polished } Ring { radius: index?3.8:5.5; depth: .4; finish: rubber } } }
+ Model {
+ objectName: "cdDisplay3D"; source: "#Rectangle"; x: -7; z: 1.5; scale: Qt.vector3d(1.14,.36,1)
+ materials: PrincipledMaterial { lighting: PrincipledMaterial.NoLighting; baseColorMap: Texture { sourceItem: CdDisplay { app: deck.app } } }
+ }
+ Repeater3D {
+ model: 6
+ Node {
+ id: key; required property int index; x: 81+28*(index%3); y: index<3?10:-10
+ readonly property real pressure: deck.app.cdControls ? deck.app.cdControls.keyItems[index].pressure : 0
+ Ring { cdControl: key.index; radius: 8; depth: 1; z: 1.8; finish: rubber }
+ Ring { objectName: "cdKey3D"+key.index; cdControl: key.index; radius: 6.6; depth: 3.7; z: 3.5-1.6*key.pressure; finish: graphite }
+ Model {
+ property int cdControl: key.index; pickable: true; source: "#Rectangle"; z: 5.5-1.6*key.pressure; scale: Qt.vector3d(.065,.065,1)
+ materials: PrincipledMaterial { lighting: PrincipledMaterial.NoLighting; alphaMode: PrincipledMaterial.Blend; baseColorMap: Texture { sourceItem: Item { width: 32; height: 32; Glyph { anchors.fill: parent; visible: key.index!==1; name: [deck.app.deckPlayer.playing?"pause":"play","play","more","previous","next","volume"][key.index]; ink: "#c0cbcf" } Rectangle { anchors.centerIn: parent; width: 16; height: 16; visible: key.index===1; color: "#c0cbcf" } } } }
+ }
+ }
+ }
+ Node {
+ x: 184; eulerRotation.z: 135-270*deck.app.deckPlayer.volume
+ Ring { cdControl: 6; radius: 19; depth: 1.5; z: 1.8; finish: rubber }
+ Ring { objectName: "cdVolume3D"; cdControl: 6; radius: 17.6; depth: 8; z: 6; finish: PrincipledMaterial { baseColor: "#cad0d3"; metalness: .9; roughness: .33; roughnessMap: brushed; normalMap: knurl; normalStrength: .22 } }
+ Ring { cdControl: 6; radius: 16.6; depth: .8; z: 10.5; finish: polished }
+ Solid { cdControl: 6; y: 12; z: 11.1; size: Qt.vector3d(1.1,5,.4); rounding: .3; finish: graphite }
+ }
+ Repeater3D {
+ model: 2
+ Node {
+ required property int index; x: index?-91:-126
+ Solid { cdControl: index+8; size: Qt.vector3d(9,24,2); rounding: 2; z: 1.8; finish: rubber }
+ Solid { cdControl: index+8; size: Qt.vector3d(6.5,8,3); rounding: 1.4; z: 3.1; y: index ? (deck.app.deckPlayer.repeatMode-1)*6 : deck.app.deckPlayer.shuffle?6:-6; finish: polished }
+ Model { source: "#Rectangle"; x: 10; z: 1.6; scale: Qt.vector3d(.07,.07,1); materials: PrincipledMaterial { lighting: PrincipledMaterial.NoLighting; alphaMode: PrincipledMaterial.Blend; baseColorMap: Texture { sourceItem: Glyph { width: 32; height: 32; name: index?"repeat":"shuffle"; ink: "#aeb9bd" } } } }
+ }
+ }
+ }
+ Node {
+ y: 211; z: -24; eulerRotation.x: -90
+ Solid { size: Qt.vector3d(346,40,1.3); rounding: 4; finish: graphite }
+ Repeater3D { model: 2; Node { required property int index; x: index?139:100; z: 1.7; Ring { radius: index?7.5:6; hole: index?5:3.8; depth: 2; finish: polished } Ring { radius: index?5:3.8; depth: .3; finish: rubber } } }
+ Repeater3D { model: 2; Node { required property int index; x: index?0:-120; z: 1.8; Solid { size: Qt.vector3d(21,8,2); rounding: 3.8; finish: rubber } Solid { size: Qt.vector3d(14,2,1); rounding: .6; z: 1.4; finish: tray } } }
+ Repeater3D { model: 2; Solid { required property int index; x: index?52:-58; z: 1.6; size: Qt.vector3d(17,7,2); rounding: 1; finish: rubber } }
+ Repeater3D { model: 2; Screw { required property int index; x: index?163:-163; z: 2 } }
+ }
+ Repeater3D {
+ model: 4
+ Node { required property int index; x: index%2?167:-167; y: index<2?162:-162; z: -56; Ring { radius: 17; depth: 6; finish: graphite } Ring { radius: 15; depth: 4; z: -4; finish: rubber } Screw { z: -6.5; eulerRotation.x: 180 } }
+ }
+ // The transport perimeter uses the same progress preview as the horizontal bar.
+ Model { visible: app.deckPlayer.count>0; geometry: WaveGeometry { progress: app.recordVisualProgress; phase: app.wavePhase; amplitude: app.deckPlayer.playing?1.3:0 } materials: PrincipledMaterial { baseColor: app.accent; lighting: PrincipledMaterial.NoLighting; cullMode: Material.NoCulling } }
+}
diff --git a/qml/CdControls.qml b/qml/CdControls.qml
new file mode 100644
index 0000000..6cc941a
--- /dev/null
+++ b/qml/CdControls.qml
@@ -0,0 +1,94 @@
+import QtQuick
+
+Item {
+ id: controls
+ required property var app
+ objectName: "cdControls"
+ property int pressedControl: -1
+ property bool armed: false
+ property bool doorOpen: false
+ property real startY: 0
+ property real startVolume: 0
+ readonly property var keyItems: [play, stop, settings, previous, next, mute, volume, latch, shuffle, repeat]
+ readonly property bool available: app.cd && app.bodyVisible && !app.discFlipped && !app.menuOpen && !app.swapRunning
+ property real doorAngle: app.swapRunning ? Math.max(doorOpen ? 70 : 0, app.lidOpen*70) : doorOpen ? 70 : 0
+ Behavior on doorAngle { enabled: controls.app.animate && !controls.app.swapRunning; NumberAnimation { duration: 320; easing.type: Easing.InOutCubic } }
+ function canUse(index) {
+ const transport=index===0 || index===1 || index===3 || index===4 || index>=8
+ return available && index>=0 && index<keyItems.length
+ && (!transport || (app.deckPlayer.count>0 && (!app.useCider || !app.ciderService.controlBusy)))
+ }
+ function cancel() { pressedControl=-1;armed=false }
+ function begin(index,y) { cancel();if(!canUse(index))return;pressedControl=index;armed=true;startY=y;startVolume=app.deckPlayer.volume }
+ function move(y,index) { if(pressedControl===6)app.deckPlayer.volume=Math.max(0,Math.min(1,startVolume+(startY-y)/150));else armed=index===pressedControl }
+ function activate(index) {
+ if(!canUse(index))return
+ if(index===0){doorOpen=false;app.deckPlayer.toggle()}
+ else if(index===1){app.deckPlayer.pause();if(!app.useCider || app.ciderService.canSeek)app.deckPlayer.seek(0)}
+ else if(index===2)app.openSettings()
+ else if(index===3)app.deckPlayer.previous()
+ else if(index===4)app.deckPlayer.next()
+ else if(index===5)app.toggleMute()
+ else if(index===7){if(!doorOpen)app.deckPlayer.pause();doorOpen=!doorOpen}
+ else if(index===8)app.deckPlayer.shuffle=!app.deckPlayer.shuffle
+ else if(index===9)app.deckPlayer.repeatMode=(app.deckPlayer.repeatMode+1)%3
+ }
+ function end(){const index=pressedControl,run=armed;cancel();if(run&&index!==6)activate(index)}
+ onAvailableChanged: if(!available)cancel()
+ Connections { target: controls.app.deckPlayer; function onPlayingChanged(){if(controls.app.deckPlayer.playing)controls.doorOpen=false} function onTrackChanged(){controls.cancel()} }
+ Connections { target: controls.app; function onUseCiderChanged(){controls.cancel();controls.doorOpen=false} }
+ Rectangle { x: 54; y: 489; width: 422; height: 39; radius: 6; border.color: "#b9c0c4"; border.width: .8; gradient: Gradient { GradientStop { position: 0; color: "#dce0e3" } GradientStop { position: .2; color: "#c3c8cb" } GradientStop { position: 1; color: "#889298" } } }
+ Rectangle { x: 61; y: 492; width: 408; height: 31; radius: 14; color: "#101619"; border.color: "#69747a"; border.width: .7 }
+ Repeater { model: 2; Rectangle { required property int index; x: 72+index*24; y: 502; width: index?9:12; height: width; radius: width/2; color: "#05080a"; border.color: "#879298"; border.width: 1.2 } }
+ CdDisplay { app: controls.app; x: 196; y: 493; scale: .43; transformOrigin: Item.TopLeft }
+ Rectangle {
+ x: 250; y: 279; width: 30; height: 30; radius: 15; border.width: 2; border.color: "#455159"
+ gradient: Gradient { GradientStop { position: 0; color: "#cfd7dc" } GradientStop { position: .48; color: "#8e9ca5" } GradientStop { position: .52; color: "#39464e" } GradientStop { position: 1; color: "#aebbc2" } }
+ Rectangle { anchors.centerIn: parent; width: 5; height: 5; radius: 2.5; color: "#26343b" }
+ Repeater { model: 3; Rectangle { required property int index; x: 13.5+12*Math.sin(index*2*Math.PI/3); y: 13.5-12*Math.cos(index*2*Math.PI/3); width: 3; height: 3; radius: 1.5; color: "#e1e7eb"; border.width: .5; border.color: "#6b7b85" } }
+ }
+ component Key: Item {
+ id: key
+ required property int index
+ required property string caption
+ property string icon: ""
+ property bool knob: false
+ property bool selector: false
+ readonly property real pressure: Math.max(0,Math.min(1.03,travel.value))
+ SpunSpring { id: travel; targetValue: controls.pressedControl===key.index&&controls.armed?1:0; epsilon: .005; animation.spring: 5.2; animation.damping: .4 }
+ enabled: controls.canUse(index); activeFocusOnTab: true
+ Accessible.role: knob?Accessible.Slider:Accessible.Button; Accessible.name: caption
+ Accessible.onPressAction: controls.activate(index)
+ Keys.onReturnPressed: controls.activate(index)
+ Keys.onSpacePressed: controls.activate(index)
+ Keys.onUpPressed: if(knob)controls.app.deckPlayer.volume=Math.min(1,controls.app.deckPlayer.volume+.05)
+ Keys.onDownPressed: if(knob)controls.app.deckPlayer.volume=Math.max(0,controls.app.deckPlayer.volume-.05)
+ Rectangle { anchors.fill: parent; anchors.margins: 1; radius: key.selector?2:width/2; color: "#030607" }
+ Rectangle {
+ x: 2; y: 1+key.pressure*1.5; width: parent.width-4; height: parent.height-4
+ radius: key.selector?1:width/2; border.width: .6; border.color: key.activeFocus?controls.app.accent:"#8b979d"
+ gradient: Gradient { GradientStop { position: 0; color: key.knob?"#e4e7e9":"#68757c" } GradientStop { position: .5; color: key.knob?"#c4cbce":"#3b464d" } GradientStop { position: 1; color: key.knob?"#87959e":"#202c32" } }
+ Glyph { anchors.centerIn: parent; width: key.knob?10:7; height: width; name: key.icon; ink: "#bac4c8"; visible: key.icon!==""&&key.icon!=="stop" }
+ Rectangle { anchors.centerIn: parent; width: 3.5; height: 3.5; color: "#bac4c8"; visible: key.icon==="stop" }
+ Rectangle { visible: key.knob; x: parent.width/2-.6; y: 2; width: 1.2; height: 4; color: "#424c52"; transform: Rotation { origin.x: .6; origin.y: parent.height/2-2; angle: -135+270*controls.app.deckPlayer.volume } }
+ }
+ MouseArea {
+ anchors.fill: parent; preventStealing: true; hoverEnabled: true; cursorShape: key.knob?Qt.SizeVerCursor:Qt.PointingHandCursor
+ onPressed: mouse=>{key.forceActiveFocus();controls.begin(key.index,mapToItem(controls,mouse.x,mouse.y).y)}
+ onPositionChanged: mouse=>controls.move(mapToItem(controls,mouse.x,mouse.y).y,containsMouse?key.index:-1)
+ onReleased: controls.end(); onCanceled: controls.cancel()
+ onWheel: wheel=>{if(key.knob)controls.app.deckPlayer.volume=Math.max(0,Math.min(1,controls.app.deckPlayer.volume+wheel.angleDelta.y/2400));wheel.accepted=key.knob}
+ SpunToolTip { visible: parent.containsMouse&&!parent.pressed&&!controls.app.threeDActive; text: key.caption; timeout: 2500 }
+ }
+ }
+ Key { id: play; objectName: "cdPlay"; index: 0; caption: controls.app.deckPlayer.playing?"Pause":"Play"; icon: controls.app.deckPlayer.playing?"pause":"play"; x: 326; y: 494; width: 17; height: 16 }
+ Key { id: stop; objectName: "cdStop"; index: 1; caption: "Stop and return to start"; icon: "stop"; x: 354; y: 494; width: 17; height: 16 }
+ Key { id: settings; objectName: "cdSettings"; index: 2; caption: "Settings"; icon: "more"; x: 382; y: 494; width: 17; height: 16 }
+ Key { id: previous; objectName: "cdPrevious"; index: 3; caption: "Previous track"; icon: "previous"; x: 326; y: 510; width: 17; height: 16 }
+ Key { id: next; objectName: "cdNext"; index: 4; caption: "Next track"; icon: "next"; x: 354; y: 510; width: 17; height: 16 }
+ Key { id: mute; objectName: "cdMute"; index: 5; caption: "Mute or restore volume"; icon: "volume"; x: 382; y: 510; width: 17; height: 16 }
+ Key { id: volume; objectName: "cdVolume"; index: 6; caption: "Volume, drag up or down"; knob: true; x: 430; y: 493; width: 32; height: 32 }
+ Key { id: latch; objectName: "cdLatch"; index: 7; caption: controls.doorOpen?"Close CD lid":"Open CD lid"; x: 251; y: 482; width: 28; height: 8; selector: true }
+ Key { id: shuffle; objectName: "cdShuffle"; index: 8; caption: "Shuffle"; icon: "shuffle"; x: 122; y: 499; width: 23; height: 21; selector: true }
+ Key { id: repeat; objectName: "cdRepeat"; index: 9; caption: "Repeat mode"; icon: "repeat"; x: 157; y: 499; width: 23; height: 21; selector: true }
+}
diff --git a/qml/CdDisplay.qml b/qml/CdDisplay.qml
new file mode 100644
index 0000000..350eb21
--- /dev/null
+++ b/qml/CdDisplay.qml
@@ -0,0 +1,13 @@
+import QtQuick
+
+Rectangle {
+ required property var app
+ width: 240; height: 76
+ color: "#090e10"
+ readonly property color phosphor: Qt.tint("#ffb64f", Qt.alpha(app.accent,.35))
+ Text { x: 10; y: 6; text: parent.app.useCider ? "CIDER" : "LOCAL"; color: parent.phosphor; font.pixelSize: 12; font.letterSpacing: 1.3 }
+ Text { x: 10; y: 25; width: 218; elide: Text.ElideRight; text: parent.app.deckPlayer.count>0 ? parent.app.deckPlayer.title : "NO DISC"; color: parent.phosphor; font.pixelSize: 19 }
+ Text { x: 10; y: 53; text: parent.app.time(parent.app.deckPlayer.position); color: parent.phosphor; font.pixelSize: 13; font.family: "monospace" }
+ Text { x: 98; y: 53; text: parent.app.deckPlayer.playing ? "PLAY" : "PAUSE"; color: parent.phosphor; font.pixelSize: 11 }
+ Text { anchors.right: parent.right; anchors.rightMargin: 10; y: 53; text: Math.round(parent.app.deckPlayer.volume*100); color: parent.phosphor; font.pixelSize: 11 }
+}
diff --git a/qml/LibraryPanel.qml b/qml/LibraryPanel.qml
index ad6aae9..2d5de15 100644
--- a/qml/LibraryPanel.qml
+++ b/qml/LibraryPanel.qml
@@ -385,7 +385,7 @@ Rectangle {
}
onClicked: discographyMenu.open()
Menu {
- id: discographyMenu; objectName: "discographyMenu"; y: parent.height + 4; width: 204; padding: 8; spacing: 2; popupType: Popup.Item
+ id: discographyMenu; onOpened: panel.app.focusFirstMenuItem(discographyMenu); objectName: "discographyMenu"; y: parent.height + 4; width: 204; padding: 8; spacing: 2; popupType: Popup.Item
background: Rectangle { radius: SpunStyle.popupRadius; color: SpunStyle.popup }
enter: SpunPopupEnter {}
exit: Transition { NumberAnimation { property: "opacity"; to: 0; duration: SpunStyle.exit; easing.type: Easing.BezierSpline; easing.bezierCurve: SpunStyle.effectsCurve } }
diff --git a/qml/Main.qml b/qml/Main.qml
index 764b1d7..ff0ddde 100644
--- a/qml/Main.qml
+++ b/qml/Main.qml
@@ -8,10 +8,13 @@ ApplicationWindow {
objectName: "spunWindow"
title: "Spun"
visible: true
- readonly property real layoutWidth: miniMode ? 300 : sideOpen ? 860 : 530
+ readonly property bool wideMixer: tx6Visible && threeDRequested
+ readonly property real playerWidth: miniMode ? 300 : wideMixer ? 740 : 530
+ readonly property real mixerHeightExtra: wideMixer ? 64 : 0
+ readonly property real layoutWidth: playerWidth + (!miniMode && sideOpen ? 330 : 0)
readonly property real miniBaseHeight: showHorizontalSeek ? 382 : 354
readonly property real layoutHeight: miniMode ? miniBaseHeight + (actionNotice.visible ? 48 : 0)
- : Math.max(730, actionNotice.visible ? actionNotice.y + actionNotice.height + 8 : 730)
+ : Math.max(730 + mixerHeightExtra, actionNotice.visible ? actionNotice.y + actionNotice.height + 8 : 730)
onLayoutHeightChanged: Qt.callLater(updateMask)
readonly property real uiScale: testMode ? typography.uiScale : Math.min(typography.uiScale,
Math.max(.5, (Screen.desktopAvailableWidth - 40) / layoutWidth),
@@ -30,7 +33,7 @@ ApplicationWindow {
onThreeDActiveChanged: { cancel3DPointer(); cancelSeekPreview(); scrubber.cancelScrub(); stopSwap(); Qt.callLater(updateMask) }
readonly property var tonearm: armLoader.item
property var threeDPointer: null
- readonly property bool threeDHardwarePressed: !!(scene3D.item && scene3D.item.hardwareActive)
+ readonly property bool threeDHardwarePressed: !!(tx6Controls && tx6Controls.pressedControl>=0) || !!(scene3D.item && scene3D.item.hardwareActive) || !!(cassetteControls && cassetteControls.pressedControl>=0) || !!(cdControls && cdControls.pressedControl>=0)
function pointerEvent(control, point, modifiers) {
const p=control.mapFromItem(mediaSurface,point.x,point.y)
return {x:p.x,y:p.y,modifiers:modifiers,accepted:true}
@@ -55,14 +58,14 @@ ApplicationWindow {
}
function begin3DPointer(point, modifiers, hitControl) {
cancel3DPointer()
- const control=(recorder || vinyl) ? hitControl : hitControl || controlAt3DPoint(point)
+ const control=hitControl
if(control) { const event=pointerEvent(control,point,modifiers);control.beginPointer(event);if(event.accepted)threeDPointer=control }
}
function move3DPointer(point, modifiers) {
if(threeDPointer)threeDPointer.movePointer(pointerEvent(threeDPointer,point,modifiers))
}
function end3DPointer() { const control=threeDPointer;threeDPointer=null;if(control)control.endPointer() }
- function cancel3DPointer() { if(scene3D.item)scene3D.item.cancelHardware(); const control=threeDPointer;threeDPointer=null;if(control)control.cancelPointer() }
+ function cancel3DPointer() { if(tx6Controls)tx6Controls.cancel();if(cdControls)cdControls.cancel();if(cassetteControls)cassetteControls.cancel(); if(scene3D.item)scene3D.item.cancelHardware(); const control=threeDPointer;threeDPointer=null;if(control)control.cancelPointer() }
readonly property bool bodyVisible: (player.showPlayerBody || threeDRequested || recorder) && !miniMode
readonly property real mediumScale: bodyVisible && !discFlipped && !recorder ? .86 : 1
readonly property color cassetteShell: player.cassetteFinish === "cream" ? "#bab29c" : player.cassetteFinish === "clear" ? "#b06f8285" : root.surface
@@ -71,6 +74,14 @@ ApplicationWindow {
onBodyVisibleChanged: Qt.callLater(function() { stopSwap(); cancelSeekPreview(); updateMask() })
readonly property bool recorder: player.medium === "tp7"
readonly property var recorderView: recorderLoader.item
+ readonly property bool tx6Visible: recorder && tx6.visible && !miniMode && !discFlipped
+ readonly property var tx6Controls: tx6Loader.item
+ Binding { target: tx6; property: "available"; value: !root.useCider }
+ Connections { target: tx6; function onFeedback(message,error){root.notifyAction(message,error)} }
+ onTx6VisibleChanged: { cancel3DPointer(); Qt.callLater(updateMask) }
+ readonly property bool cd: player.medium === "cd"
+ readonly property var cdControls: cdControlsLoader.item
+ readonly property var cassetteControls: cassetteControlsLoader.item
readonly property bool cassette: player.medium === "cassette"
onCassetteChanged: Qt.callLater(function() { stopSwap(); scrubber.cancelScrub(); updateMask() })
readonly property bool vinyl: player.vinyl
@@ -135,7 +146,7 @@ ApplicationWindow {
}
function syncLibrary() { if (!visible || visibility === Window.Minimized) { songMenu.close(); musicBrowser.closeActions() }; library.active = libraryOpen && useCider && visible && visibility !== Window.Minimized }
function syncLyrics() { lyrics.remote = useCider; lyrics.active = discFlipped && lyricsView && visible && visibility !== Window.Minimized }
- onLyricsViewChanged: { syncLyrics(); if (!lyricsView && lyricList.activeFocus) contentItem.forceActiveFocus() }
+ onLyricsViewChanged: { syncLyrics(); if (discFlipped) Qt.callLater(focusDiscDetails) }
onVisibilityChanged: { syncLibrary(); syncLyrics(); if (root.visibility === Window.Minimized) { stopSwap(); cancelSeekPreview() } }
onVisibleChanged: { syncLibrary(); syncLyrics(); if (!root.visible) { stopSwap(); cancelSeekPreview() } }
onAnimateChanged: if (!animate) { stopSwap(); tapeWindSpeed = 0 }
@@ -199,6 +210,14 @@ ApplicationWindow {
cancelSeekPreview(); scrubber.cancelScrub()
stopSwap()
syncLyrics()
+ if (discFlipped) Qt.callLater(focusDiscDetails)
+ else contentItem.forceActiveFocus()
+ }
+ function focusDiscDetails() {
+ if (!discFlipped || menuOpen) return
+ if (!lyricsView) albumList.forceActiveFocus(Qt.TabFocusReason)
+ else if (lyricList.visible) lyricList.forceActiveFocus(Qt.TabFocusReason)
+ else lyricsViewButton.forceActiveFocus(Qt.TabFocusReason)
}
function receiveMediaDrop(drop) {
const urls = drop.hasUrls ? drop.urls : []
@@ -408,7 +427,7 @@ ApplicationWindow {
}
property bool queueOpen: false
property bool helpOpen: false
- readonly property bool menuOpen: artworkPopup.visible || helpOpen || recoveryPopup.visible || quickJump.visible || savedQueuePicker.visible || cleanupPopup.visible || qualityPopup.visible || savedQueueMenu.visible || saveQueuePopup.visible || deleteQueuePopup.visible || fontPicker.shown || fontPicker.opening || menu.visible || preferences.visible || crossfadeMenu.visible || queueMenu.visible || songMenu.visible || musicBrowser.actionsOpen
+ readonly property bool menuOpen: !!(tx6Controls && tx6Controls.popupOpen) || artworkPopup.visible || helpOpen || recoveryPopup.visible || quickJump.visible || savedQueuePicker.visible || cleanupPopup.visible || qualityPopup.visible || savedQueueMenu.visible || saveQueuePopup.visible || deleteQueuePopup.visible || fontPicker.shown || fontPicker.opening || menu.visible || preferences.visible || crossfadeMenu.visible || queueMenu.visible || songMenu.visible || musicBrowser.actionsOpen
property bool backgroundBlur: player.backgroundBlur && native.supportsBlur
onBackgroundBlurChanged: { native.effects(root, backgroundBlur); Qt.callLater(updateMask) }
property bool muted: false
@@ -510,8 +529,8 @@ ApplicationWindow {
Shortcut { sequence: "Left"; enabled: !(root.activeFocusItem instanceof Slider) && !root.editingText && !root.menuOpen; onActivated: root.deckPlayer.seek(root.deckPlayer.position - 5000) }
Shortcut { sequence: "Ctrl+Right"; enabled: !root.editingText && !root.menuOpen; onActivated: root.deckPlayer.next() }
Shortcut { sequence: "Ctrl+Left"; enabled: !root.editingText && !root.menuOpen; onActivated: root.deckPlayer.previous() }
- Shortcut { sequence: "Up"; enabled: !root.libraryOpen && !trackList.activeFocus && !root.menuOpen && !root.editingText && !(root.discFlipped && (albumList.activeFocus || lyricList.activeFocus)); onActivated: root.deckPlayer.volume = Math.min(1, root.deckPlayer.volume + .05) }
- Shortcut { sequence: "Down"; enabled: !root.libraryOpen && !trackList.activeFocus && !root.menuOpen && !root.editingText && !(root.discFlipped && (albumList.activeFocus || lyricList.activeFocus)); onActivated: root.deckPlayer.volume = Math.max(0, root.deckPlayer.volume - .05) }
+ Shortcut { sequence: "Up"; enabled: !(root.activeFocusItem instanceof Slider) && !root.libraryOpen && !trackList.activeFocus && !root.menuOpen && !root.editingText && !(root.discFlipped && (albumList.activeFocus || lyricList.activeFocus)); onActivated: root.deckPlayer.volume = Math.min(1, root.deckPlayer.volume + .05) }
+ Shortcut { sequence: "Down"; enabled: !(root.activeFocusItem instanceof Slider) && !root.libraryOpen && !trackList.activeFocus && !root.menuOpen && !root.editingText && !(root.discFlipped && (albumList.activeFocus || lyricList.activeFocus)); onActivated: root.deckPlayer.volume = Math.max(0, root.deckPlayer.volume - .05) }
Shortcut { sequence: "M"; enabled: !root.editingText && !root.menuOpen; onActivated: root.toggleMute() }
Shortcut { sequence: "Escape"; onActivated: { if(root.threeDPointer || root.threeDHardwarePressed) { root.cancel3DPointer();return }; if(artworkPopup.visible) { artworkPopup.close();return }; if(root.activeSeekControl) { root.cancelSeekPreview();return }; if(scrubber.scrubbing) { scrubber.cancelScrub();return }; if(root.libraryDragging) { root.endLibraryDrag(false);return }; if(quickJump.visible) { quickJump.close();return }; if(savedQueuePicker.visible) { savedQueuePicker.close();return }; if(cleanupPopup.visible) { cleanupPopup.close();return }; if(qualityPopup.visible) { qualityPopup.close();return }; if (saveQueuePopup.visible) { saveQueuePopup.close(); return }; if (deleteQueuePopup.visible) { deleteQueuePopup.close(); return }; if (savedQueueMenu.visible) { savedQueueMenu.close(); return }; if (fontPicker.shown || fontPicker.opening) { fontPicker.close(); return }; if (preferences.visible) { preferences.close(); return }; if (crossfadeMenu.visible) { crossfadeMenu.close(); return }; if (queueMenu.visible) { queueMenu.close(); return }; if (songMenu.visible) { songMenu.close(); return }; if (musicBrowser.actionsOpen) { musicBrowser.closeActions(); return }; if (menu.visible) { menu.close(); return }; if (root.queueSelectionCount > 0) { root.clearQueueSelection(); return }; if (root.queueSearchOpen) { root.closeQueueSearch(); return }; if (root.libraryOpen) { if (musicBrowser.item && musicBrowser.item.selectionCount > 0) musicBrowser.item.clearSelection(); else if (musicBrowser.detail && musicBrowser.browser.collectionQuery.length) musicBrowser.browser.collectionQuery = ""; else if (musicBrowser.detail) musicBrowser.browser.back(); else root.libraryOpen = false; return }; if (root.discFlipped) { root.discFlipped = false; return }; root.queueOpen = false; root.helpOpen = false; menu.close(); if (root.miniMode) player.miniMode = false } }
Shortcut { sequence: "Y"; enabled: !root.editingText && !root.menuOpen; onActivated: { if (root.deckPlayer.count) { root.discFlipped = true; root.lyricsView = !root.lyricsView } } }
@@ -529,29 +548,28 @@ ApplicationWindow {
FolderDialog { id: folder; title: "Add a music folder"; onAccepted: { root.useLocal(); player.addUrls([selectedFolder], player.count === 0) } }
FileDialog { id: cover; title: "Choose the disc artwork"; nameFilters: ["Artwork (*.jpg *.jpeg *.png *.webp)"]; onAccepted: player.setCover(selectedFile) }
- Timer {
- interval: 16; repeat: true
- running: root.animate && root.visible && root.visibility !== Window.Minimized && native.exposed && (root.deckPlayer.playing || root.spinSpeed > .02 || root.activeSeekControl || Math.abs(root.tapeWindSpeed) > .5)
- property double lastTime: 0
- onRunningChanged: lastTime = Date.now()
- onTriggered: {
- const now = Date.now()
- const dt = Math.min(.05, (now-lastTime)/1000)
- lastTime = now
- const target = root.deckPlayer.playing ? (root.vinyl ? root.vinylDegreesPerSecond : root.cassette ? 9 : root.recorder ? 36 : root.cdDegreesPerSecond) : 0
- root.spinSpeed += (target-root.spinSpeed)*Math.min(1,dt*2.2)
- if (!root.discFlipped) root.spinAngle = (root.spinAngle+root.spinSpeed*dt)%360
- const winding = root.cassette && root.activeSeekControl
- const windTarget = winding && now-root.activeSeekControl.lastMove < 120 ? root.activeSeekControl.windDirection * 850 : 0
- root.tapeWindSpeed += (windTarget-root.tapeWindSpeed)*Math.min(1,dt*18)
- if (root.cassette && !root.discFlipped && (root.deckPlayer.playing || winding || Math.abs(root.tapeWindSpeed) > .5)) {
- const position = Math.max(0, Math.min(1, root.cassetteVisualProgress))
- const speed = winding || Math.abs(root.tapeWindSpeed) > .5 ? root.tapeWindSpeed * 55 : 10000
- root.cassetteLeftAngle = (root.cassetteLeftAngle - dt * speed / Math.sqrt(1936 + 3993 * (1-position))) % 360
- root.cassetteRightAngle = (root.cassetteRightAngle - dt * speed / Math.sqrt(1936 + 3993 * position)) % 360
- }
- if (root.deckPlayer.playing) root.wavePhase=(root.wavePhase+dt*2.8)%(2*Math.PI)
+ function advanceMediaFrame(seconds, now) {
+ const dt = Math.min(.05, seconds)
+ const target = root.deckPlayer.playing ? (root.vinyl ? root.vinylDegreesPerSecond : root.cassette ? 9 : root.recorder ? 36 : root.cdDegreesPerSecond) : 0
+ root.spinSpeed += (target-root.spinSpeed)*Math.min(1,dt*2.2)
+ if (!root.discFlipped) root.spinAngle = (root.spinAngle+root.spinSpeed*dt)%360
+ const winding = root.cassette && root.activeSeekControl
+ const windTarget = winding && now-root.activeSeekControl.lastMove < 120 ? root.activeSeekControl.windDirection * 850 : 0
+ root.tapeWindSpeed += (windTarget-root.tapeWindSpeed)*Math.min(1,dt*18)
+ if (root.cassette && !root.discFlipped && (root.deckPlayer.playing || winding || Math.abs(root.tapeWindSpeed) > .5)) {
+ const position = Math.max(0, Math.min(1, root.cassetteVisualProgress))
+ const speed = winding || Math.abs(root.tapeWindSpeed) > .5 ? root.tapeWindSpeed * 55 : 10000
+ root.cassetteLeftAngle = (root.cassetteLeftAngle - dt * speed / Math.sqrt(1936 + 3993 * (1-position))) % 360
+ root.cassetteRightAngle = (root.cassetteRightAngle - dt * speed / Math.sqrt(1936 + 3993 * position)) % 360
}
+ if (root.deckPlayer.playing) root.wavePhase=(root.wavePhase+dt*2.8)%(2*Math.PI)
+ }
+ // Advance with Qt's animation frame clock, using seconds rather than a
+ // fixed 16 ms timer. Qt's render loop follows the active display's cadence.
+ FrameAnimation {
+ objectName: "mediaFrameAnimation"
+ running: root.animate && root.visible && root.visibility !== Window.Minimized && native.exposed && (root.deckPlayer.playing || root.spinSpeed > .02 || root.activeSeekControl || Math.abs(root.tapeWindSpeed) > .5)
+ onTriggered: root.advanceMediaFrame(frameTime, Date.now())
}
Connections {
target: root.deckPlayer
@@ -570,7 +588,7 @@ ApplicationWindow {
id: badge
objectName: "sourceBar"
visible: !root.miniMode
- x: 265 - width / 2; y: 13; width: native.hyprland ? 256 : 344; height: 48; radius: 24
+ x: (root.playerWidth - width) / 2; y: 13; width: native.hyprland ? 256 : 344; height: 48; radius: 24
color: root.surface
border.width: 0
MouseArea { anchors.fill: parent; onPressed: root.startSystemMove() }
@@ -645,6 +663,7 @@ ApplicationWindow {
Item {
id: mediaSurface
objectName: "mediaSurface"
+ x: root.wideMixer ? (root.playerWidth - 530) / 2 : 0
opacity: root.threeDActive ? 0 : 1
width: 530; height: 530
PlayerBody {
@@ -751,7 +770,7 @@ ApplicationWindow {
}
}
}
- Loader { id: recorderLoader; objectName: "recorderLoader"; anchors.fill: parent; active: root.recorder; sourceComponent: Recorder { app: root } }
+ Loader { id: recorderLoader; objectName: "recorderLoader"; anchors.fill: parent; transformOrigin: Item.TopLeft; scale: root.tx6Visible?.85:1; transform: Translate { x: root.tx6Visible?-65:0; y: root.tx6Visible?39:0 } active: root.recorder; sourceComponent: Recorder { app: root } }
Loader { objectName: "cassetteReelsLoader"; anchors.fill: parent; active: root.cassette; sourceComponent: CassetteReels { app: root } }
}
back: Item {
@@ -1031,6 +1050,7 @@ ApplicationWindow {
onClicked: { lyricList.following = true; lyricList.followLine() }
}
IconButton {
+ id: lyricsViewButton
objectName: "lyricsViewButton"
width: 36; height: 36; glyphName: root.lyricsView ? "queue" : "lyrics"
tip: root.lyricsView ? "Album tracks · Y" : "Lyrics · Y"
@@ -1217,8 +1237,45 @@ ApplicationWindow {
x: 45; y: 74; width: 440; height: 440
visible: root.bodyVisible && !root.recorder && !root.discFlipped && !root.threeDActive
medium: player.medium; surface: root.surface; part: 1
- opacity: 1 - .75*root.lidOpen
- transform: Scale { origin.x: 220; origin.y: root.cassette ? 112 : 26; yScale: 1 - .35*root.lidOpen }
+ opacity: 1 - .75*(root.cassette && root.cassetteControls ? root.cassetteControls.doorAngle/58 : root.cd && root.cdControls ? root.cdControls.doorAngle/70 : root.lidOpen)
+ transform: Scale { origin.x: 220; origin.y: root.cassette ? 358 : 26; yScale: 1 - .35*(root.cassette && root.cassetteControls ? root.cassetteControls.doorAngle/58 : root.cd && root.cdControls ? root.cdControls.doorAngle/70 : root.lidOpen) }
+ }
+ Canvas {
+ id: tx6CableFlat
+ visible: root.tx6Visible && !root.threeDActive
+ width: 530; height: 200
+ onVisibleChanged: requestPaint()
+ onPaint: {
+ const c=getContext("2d");c.reset();if(!visible)return;
+ // Same top-edge USB-C sockets as the 3D cable.
+ c.lineCap="round";c.strokeStyle="#85000000";c.lineWidth=5;
+ c.beginPath();c.moveTo(232,141);c.bezierCurveTo(186,23,495,23,471,138);c.stroke();
+ c.strokeStyle="#252e32";c.lineWidth=3.2;c.beginPath();c.moveTo(232,140);c.bezierCurveTo(186,22,495,22,471,137);c.stroke();
+ c.strokeStyle="#728086";c.lineWidth=.55;c.stroke();
+ c.fillStyle="#c4cace";c.fillRect(224,139,16,10);c.fillRect(463,138,16,10);
+ c.fillStyle="#e1e2df";c.fillRect(223,130,18,14);c.fillRect(462,128,18,14);
+ }
+ }
+ Loader {
+ id: tx6Loader
+ x: 295; y: 146; width: 244; height: 400; scale: .85; transformOrigin: Item.TopLeft
+ active: root.recorder && tx6.visible && !root.miniMode
+ visible: root.tx6Visible
+ opacity: root.threeDActive ? 0 : 1
+ enabled: !root.threeDActive
+ sourceComponent: Tx6Controls { app: root }
+ }
+ Loader {
+ id: cdControlsLoader
+ width: 530; height: 530
+ active: root.cd && root.bodyVisible && !root.discFlipped
+ sourceComponent: CdControls { app: root }
+ }
+ Loader {
+ id: cassetteControlsLoader
+ width: 530; height: 530
+ active: root.cassette && root.bodyVisible && !root.discFlipped
+ sourceComponent: CassetteControls { app: root }
}
Rectangle {
id: rimPreview
@@ -1236,14 +1293,35 @@ ApplicationWindow {
Loader {
id: scene3D
objectName: "scene3DLoader"
- x: 0; y: 60; width: 530; height: 470
+ x: 0; y: 60; width: root.playerWidth; height: 470 + root.mixerHeightExtra
active: root.threeDRequested
- onActiveChanged: if(active)setSource(player3DUrl, {app: root, surfaceItem: mediaSurface})
- Component.onCompleted: if(active)setSource(player3DUrl, {app: root, surfaceItem: mediaSurface})
+ onActiveChanged: if(active && !source.toString().length)setSource(player3DUrl, {app: root, surfaceItem: mediaSurface})
+ Component.onCompleted: if(active && !source.toString().length)setSource(player3DUrl, {app: root, surfaceItem: mediaSurface})
+ }
+ Button {
+ id: mixerToggle
+ objectName: "tx6Toggle"
+ // The visible pill keeps its position; the surrounding target is 48 px.
+ x: root.playerWidth - 102; y: 73; width: 74; height: 48
+ hoverEnabled: true; focusPolicy: Qt.StrongFocus
+ Accessible.name: "TX-6 mixer extension"
+ Accessible.description: checked ? "Hide the mixer" : "Show the mixer next to TP-7"
+ visible: root.recorder && !root.miniMode && !root.discFlipped
+ text: "TX–6"; checkable: true; checked: tx6.visible
+ onClicked: tx6.visible=checked
+ background: Rectangle {
+ y: 10; height: 28; radius: 14
+ color: mixerToggle.checked ? root.inset : Qt.alpha(root.surface,.85)
+ border.width: mixerToggle.visualFocus ? 2 : .6
+ border.color: mixerToggle.visualFocus ? root.accent : Qt.alpha(root.mutedInk,.25)
+ SpunStateLayer { anchors.fill: parent; radius: parent.radius; color: root.ink; hovered: mixerToggle.hovered; pressed: mixerToggle.down; focused: mixerToggle.visualFocus }
+ }
+ SpunToolTip { visible: mixerToggle.hovered; text: mixerToggle.checked ? "Hide TX-6 mixer" : "Show TX-6 mixer" }
+ contentItem: SpunText { text: parent.text; color: parent.checked?root.accent:root.mutedInk; font.pixelSize:12; horizontalAlignment:Text.AlignHCenter; verticalAlignment:Text.AlignVCenter }
}
DropArea {
objectName: "threeDMediaDrop"
- x: 0; y: 60; width: 530; height: 470
+ x: 0; y: 60; width: root.playerWidth; height: 470 + root.mixerHeightExtra
enabled: root.threeDActive
onEntered: drag => { if(!drag.hasUrls && !drag.hasText)drag.accepted=false }
onDropped: drop => root.receiveMediaDrop(drop)
@@ -1289,7 +1367,7 @@ ApplicationWindow {
id: deck
objectName: "playerDeck"
visible: !root.miniMode
- x: 62; y: 533; width: 406; height: 144 + (root.showHorizontalSeek ? 28 : 0); radius: SpunStyle.panelRadius
+ x: (root.playerWidth - width) / 2; y: 533 + root.mixerHeightExtra; width: 406; height: 144 + (root.showHorizontalSeek ? 28 : 0); radius: SpunStyle.panelRadius
color: root.surface; border.width: 0
MouseArea { anchors.fill: parent; onPressed: root.startSystemMove() }
SpunText {
@@ -1365,7 +1443,8 @@ ApplicationWindow {
}
SpunText {
- x: 65; y: 705; width: 400; horizontalAlignment: Text.AlignHCenter
+ objectName: "demoHint"
+ x: deck.x + 3; y: 705 + root.mixerHeightExtra; width: 400; horizontalAlignment: Text.AlignHCenter
visible: !root.miniMode
text: root.useCider || player.count ? "" : "Play demo"
color: root.mutedInk; font.pixelSize: SpunStyle.caption
@@ -1375,7 +1454,7 @@ ApplicationWindow {
Rectangle {
id: jewelCase
objectName: "queuePanel"
- x: 534; width: 310; anchors.top: badge.top; anchors.bottom: deck.bottom; radius: SpunStyle.panelRadius
+ x: root.playerWidth + 4; width: 310; anchors.top: badge.top; anchors.bottom: deck.bottom; radius: SpunStyle.panelRadius
visible: root.queueOpen; color: root.surface; border.width: 0
transform: Translate { id: queueEntrance; x: 0 }
onVisibleChanged: {
@@ -1749,7 +1828,7 @@ ApplicationWindow {
function renameQueue(queue, service) { saveQueuePopup.service = service; saveQueuePopup.renameTarget = queue; saveQueuePopup.open() }
function confirmDeleteQueue(id, service) { deleteQueuePopup.queueId = id; deleteQueuePopup.service = service; deleteQueuePopup.open() }
Menu {
- id: savedQueueMenu; parent: jewelCase; x: 30; y: 64; width: 264; padding: 8; popupType: Popup.Item
+ id: savedQueueMenu; onOpened: root.focusFirstMenuItem(savedQueueMenu); parent: jewelCase; x: 30; y: 64; width: 264; padding: 8; popupType: Popup.Item
background: Rectangle { color: SpunStyle.popup; radius: SpunStyle.popupRadius }
enter: SpunPopupEnter {}
exit: Transition { NumberAnimation { property: "opacity"; to: 0; duration: SpunStyle.exit; easing.type: Easing.BezierSpline; easing.bezierCurve: SpunStyle.effectsCurve } }
@@ -1801,7 +1880,7 @@ ApplicationWindow {
id: queueMenu
objectName: "queueEditMenu"
readonly property bool batch: root.queueSelectionCount > 0
- onOpened: { if (!batch && root.useCider && rowIndex >= 0 && rowIndex < root.ciderService.queue.length) library.prepareRadio(root.ciderService.queue[rowIndex]) }
+ onOpened: { root.focusFirstMenuItem(queueMenu); if (!batch && root.useCider && rowIndex >= 0 && rowIndex < root.ciderService.queue.length) library.prepareRadio(root.ciderService.queue[rowIndex]) }
property int rowIndex: -1
property int revision: -1
popupType: Popup.Item
@@ -1985,6 +2064,16 @@ ApplicationWindow {
}
IconButton { id: noticeDismiss; objectName: "dismissActionNotice"; visible: !actionNotice.importing; anchors.right: parent.right; anchors.rightMargin: 4; anchors.verticalCenter: parent.verticalCenter; glyphName: "close"; tip: "Dismiss"; ink: root.mutedInk; hoverFill: root.hoverFill; onClicked: actionNotice.dismiss() }
}
+ function focusFirstMenuItem(popup) {
+ for (let i = 0; i < popup.count; ++i) {
+ const entry = popup.itemAt(i)
+ if (entry && entry.visible && entry.enabled && entry.text !== undefined) {
+ popup.currentIndex = i
+ entry.forceActiveFocus(Qt.PopupFocusReason)
+ return
+ }
+ }
+ }
component SettingsAction: MenuEntry { app: root }
component SettingsGap: MenuSeparator {
padding: 0
@@ -2002,7 +2091,7 @@ ApplicationWindow {
background: Rectangle { color: SpunStyle.popup; radius: SpunStyle.popupRadius }
enter: SpunPopupEnter {}
exit: Transition { NumberAnimation { property: "opacity"; from: 1; to: 0; duration: SpunStyle.exit; easing.type: Easing.BezierSpline; easing.bezierCurve: SpunStyle.effectsCurve } }
- onOpened: { if (root.useCider) root.ciderService.refreshModes() }
+ onOpened: { root.focusFirstMenuItem(menu); if (root.useCider) root.ciderService.refreshModes() }
SettingsAction { text: "Add tracks"; glyphName: "plus"; hint: "Ctrl+O"; onTriggered: files.open() }
SettingsAction { text: "Add music folder"; glyphName: "folder"; hint: "Ctrl+Shift+O"; onTriggered: folder.open() }
@@ -2100,6 +2189,7 @@ ApplicationWindow {
onToggled: player.threeD = checked
onActiveFocusChanged: if(activeFocus)preferenceScroll.reveal(this)
}
+ PreferenceSwitch { objectName: "tx6Preference"; app: root; width: parent.width; visible: root.recorder; height: visible?implicitHeight:0; text: "TX-6 mixer extension"; glyphName: "volume"; checked: tx6.visible; onToggled:tx6.visible=checked; onActiveFocusChanged: if(activeFocus)preferenceScroll.reveal(this) }
PreferenceSwitch { objectName: "playerBodyToggle"; app: root; width: parent.width; visible: !root.recorder && (!supports3D || !player.threeD); height: visible ? implicitHeight : 0; text: "Show player body"; glyphName: "disc"; checked: player.showPlayerBody; onToggled: player.showPlayerBody = checked; onActiveFocusChanged: if(activeFocus)preferenceScroll.reveal(this) }
Row {
visible: root.cassette; height: visible ? 40 : 0; spacing: 6; width: parent.width
diff --git a/qml/Player3D.qml b/qml/Player3D.qml
index 36b9666..ee6efea 100644
--- a/qml/Player3D.qml
+++ b/qml/Player3D.qml
@@ -8,13 +8,21 @@ View3D {
required property Item surfaceItem
objectName: "player3DView"
clip: true
+ // Match device pixels for every enlarged deck, with the same bounded target.
+ readonly property real cdRenderScale: Math.min(Math.min(1.5, Math.max(1, app.uiScale)) * Screen.devicePixelRatio, 1536 / Math.max(1, width, height))
+ explicitTextureWidth: Math.ceil(width * cdRenderScale)
+ explicitTextureHeight: Math.ceil(height * cdRenderScale)
property real vinylYaw: 0
property real vinylPitch: 0
- readonly property bool inspectable: app.recorder || app.vinyl
+ readonly property bool inspectable: true
+ property real cdYaw: 0
+ property real cdPitch: 0
+ property real cassetteYaw: 0
+ property real cassettePitch: 0
property real recorderYaw: 0
property real recorderPitch: 0
- readonly property bool hardwareActive: !!(vinylScene.item && vinylScene.item.pressedControl>=0)
- function cancelHardware() { if(vinylScene.item)vinylScene.item.cancelHardware() }
+ readonly property bool hardwareActive: !!(vinylScene.item && vinylScene.item.pressedControl>=0) || !!(app.cassetteControls && app.cassetteControls.pressedControl>=0) || !!(app.cdControls && app.cdControls.pressedControl>=0)
+ function cancelHardware() { if(vinylScene.item)vinylScene.item.cancelHardware();if(app.cassetteControls)app.cassetteControls.cancel();if(app.cdControls)app.cdControls.cancel() }
property bool orbiting: false
property real pitchOffset: 0
property real yawOffset: 0
@@ -44,9 +52,13 @@ View3D {
antialiasingMode: SceneEnvironment.MSAA
antialiasingQuality: SceneEnvironment.Medium
specularAAEnabled: true
- lightProbe: Texture { textureData: StudioTexture { tint: view.app.accent } }
- probeExposure: .55
- aoEnabled: true; aoStrength: 18; aoDistance: 12; aoSoftness: 50; aoSampleRate: 2
+ tonemapMode: SceneEnvironment.TonemapModeAces
+ lightProbe: Texture { textureData: StudioTexture { tint: view.app.accent; ambientLift: view.app.cassette ? .16 : view.app.cd ? .09 : view.app.tx6Visible ? .1 : .035 } }
+ probeExposure: .7
+ // Tabletop and upright products need different softbox elevation.
+ probeOrientation: Qt.vector3d(view.app.vinyl || view.app.cd ? 270 : 0, 0, 0)
+ // Small contact shadows under caps and seams, without broad dirty halos.
+ aoEnabled: true; aoStrength: 22; aoDistance: 7; aoSoftness: 65; aoBias: .15; aoSampleRate: 2
}
readonly property vector3d vinylCamera: {
if(!app.vinyl)return Qt.vector3d(0,0,930)
@@ -66,26 +78,59 @@ View3D {
for(const p of points)distance=Math.max(distance,p.z+Math.abs(p.x-cx)*focal/(width/2-20),p.z+Math.abs(p.y-cy)*focal/(height/2-16))
return Qt.vector3d(cx,cy,distance)
}
- PerspectiveCamera { id: sceneCamera; x: app.vinyl ? view.vinylCamera.x : 0; y: app.vinyl ? view.vinylCamera.y : 0; z: app.vinyl ? view.vinylCamera.z : 710+(app.recorder?0:app.lidOpen*65); clipNear: 10; clipFar: 1500; fieldOfView: 38 }
- DirectionalLight { objectName: "threeDKeyLight"; color: view.keyTint; eulerRotation: Qt.vector3d(-30,-35,0); brightness: 1; ambientColor: view.ambientTint; castsShadow: true; shadowFactor: 35; shadowMapQuality: Light.ShadowMapQualityMedium; shadowMapFar: 1200 }
- DirectionalLight { objectName: "threeDFillLight"; color: view.fillTint; eulerRotation: Qt.vector3d(-10,45,0); brightness: .65 }
- property color caseTint: Qt.tint(app.surface,Qt.alpha(app.accent,.07))
- property color plateTint: Qt.tint(app.surface,Qt.alpha(app.ink,app.light?.12:.045))
- property color metalTint: Qt.tint("#b8bdc0",Qt.alpha(app.accent,.13))
- property color glassTint: Qt.tint("#dce8ed",Qt.alpha(app.accent,.18))
- Behavior on caseTint { enabled: app.animate; ColorAnimation { duration: 450 } }
- Behavior on plateTint { enabled: app.animate; ColorAnimation { duration: 450 } }
- Behavior on metalTint { enabled: app.animate; ColorAnimation { duration: 450 } }
- Behavior on glassTint { enabled: app.animate; ColorAnimation { duration: 450 } }
- Texture { id: brushedGrain; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "brushed" } }
- Texture { id: turnedGrain; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "turned" } }
- Texture { id: metalMicroSurface; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "metal-normal" } }
- Texture { id: moldedGrain; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "molded" } }
- Texture { id: vinylGrain; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "vinyl" } }
- Texture { id: opticalFilm; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "disc" } }
- Texture { id: paperGrain; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "paper" } }
- Texture { id: knurledGrain; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "knurled-normal" } }
- ReelGeometry { id: reelWeb }
+ readonly property vector3d cassetteCamera: {
+ if(!app.cassette)return Qt.vector3d(0,0,710)
+ const rotation=assembly.eulerRotation
+ let points=[]
+ for(const x of [-217,217])for(const y of [-143,164])for(const z of [-56,34])points.push(assembly.mapPositionToScene(Qt.vector3d(x,y,z)))
+ // Fit both hinge endpoints and the middle of the arc. Opening the door
+ // never changes the zoom, even after the user rotates the enclosure.
+ for(const degrees of [0,29,58]) {
+ const a=degrees*Math.PI/180
+ for(const x of [-193,193])for(const y of [0,269])for(const z of [-7,7])points.push(assembly.mapPositionToScene(Qt.vector3d(x,-133+y*Math.cos(a)-z*Math.sin(a),30+y*Math.sin(a)+z*Math.cos(a))))
+ }
+ const cx=(Math.min(...points.map(p=>p.x))+Math.max(...points.map(p=>p.x)))/2
+ const cy=(Math.min(...points.map(p=>p.y))+Math.max(...points.map(p=>p.y)))/2
+ const focal=height/(2*Math.tan(19*Math.PI/180))
+ let distance=710
+ for(const p of points)distance=Math.max(distance,p.z+Math.abs(p.x-cx)*focal/Math.max(1,width/2-20),p.z+Math.abs(p.y-cy)*focal/Math.max(1,height/2-18))
+ return Qt.vector3d(cx,cy,distance)
+ }
+ readonly property vector3d cdCamera: {
+ if(!app.cd)return Qt.vector3d(0,0,830)
+ const rotation=assembly.eulerRotation
+ let points=[]
+ for(const x of [-217,217])for(const y of [-225,214])for(const z of [-66,22])points.push(assembly.mapPositionToScene(Qt.vector3d(x,y,z)))
+ for(const degrees of [0,35,70]) {
+ const a=-degrees*Math.PI/180
+ for(const x of [-206,206])for(const y of [2,-400])points.push(assembly.mapPositionToScene(Qt.vector3d(x,197+y*Math.cos(a),16+y*Math.sin(a))))
+ }
+ const cx=(Math.min(...points.map(p=>p.x))+Math.max(...points.map(p=>p.x)))/2
+ const cy=(Math.min(...points.map(p=>p.y))+Math.max(...points.map(p=>p.y)))/2
+ const focal=height/(2*Math.tan(19*Math.PI/180))
+ let distance=730
+ for(const p of points)distance=Math.max(distance,p.z+Math.abs(p.x-cx)*focal/Math.max(1,width/2-18),p.z+Math.abs(p.y-cy)*focal/Math.max(1,height/2-16))
+ return Qt.vector3d(cx,cy,distance)
+ }
+ readonly property vector3d pairedCamera: {
+ if(!app.tx6Visible)return Qt.vector3d(0,0,710)
+ const rotation=assembly.eulerRotation
+ const points=[]
+ // Fit the two housings and the cable separately, without reserving a
+ // large empty box above the TP-7. Keep the controls large during orbit.
+ for(const box of [[-278,-19,-203,184,-30,34],[35,254,-199,158,-30,34],[-84,223,174,279,-24,-5]])
+ for(const x of [box[0],box[1]])for(const y of [box[2],box[3]])for(const z of [box[4],box[5]])
+ points.push(assembly.mapPositionToScene(Qt.vector3d(x,y,z)))
+ const cx=(Math.min(...points.map(p=>p.x))+Math.max(...points.map(p=>p.x)))/2
+ const cy=(Math.min(...points.map(p=>p.y))+Math.max(...points.map(p=>p.y)))/2
+ const focal=height/(2*Math.tan(19*Math.PI/180))
+ let distance=620
+ for(const p of points)distance=Math.max(distance,p.z+Math.abs(p.x-cx)*focal/(width/2-24),p.z+Math.abs(p.y-cy)*focal/(height/2-14))
+ return Qt.vector3d(cx,cy,distance)
+ }
+ PerspectiveCamera { id: sceneCamera; x: app.vinyl ? view.vinylCamera.x : app.cassette ? view.cassetteCamera.x : app.cd ? view.cdCamera.x : app.tx6Visible ? view.pairedCamera.x : 0; y: app.vinyl ? view.vinylCamera.y : app.cassette ? view.cassetteCamera.y : app.cd ? view.cdCamera.y : app.tx6Visible ? view.pairedCamera.y : 0; z: app.vinyl ? view.vinylCamera.z : app.cassette ? view.cassetteCamera.z : app.cd ? view.cdCamera.z : app.tx6Visible ? view.pairedCamera.z : 710; clipNear: 10; clipFar: 1500; fieldOfView: 38 }
+ DirectionalLight { objectName: "threeDKeyLight"; color: view.keyTint; eulerRotation: Qt.vector3d(-30,-35,0); brightness: .9; ambientColor: view.ambientTint; castsShadow: true; shadowFactor: 42; softShadowQuality: Light.PCF8; pcfFactor: 3; shadowBias: 1.5; shadowMapQuality: Light.ShadowMapQualityHigh; shadowMapFar: 1200 }
+ DirectionalLight { objectName: "threeDFillLight"; color: view.fillTint; eulerRotation: Qt.vector3d(-10,45,0); brightness: view.app.vinyl ? 1.3 : .55 }
Texture {
id: cover; generateMipmaps: true; mipFilter: Texture.Linear
property CoverTexture imageData: CoverTexture { objectName: "currentCoverTexture"; artwork: presentation.artwork }
@@ -101,330 +146,112 @@ View3D {
property CoverTexture imageData: CoverTexture { artwork: presentation.outgoing }
textureData: imageData.texture
}
- PrincipledMaterial { id: metal; baseColor: view.metalTint; metalness: .86; roughness: .36; roughnessMap: brushedGrain }
- PrincipledMaterial { id: rubber; baseColor: Qt.tint("#15191d",Qt.alpha(app.inset,.20)); roughness: .95; roughnessMap: moldedGrain }
- PrincipledMaterial { id: blackVinyl; baseColor: "#17191d"; metalness: 0; roughness: .48; roughnessMap: vinylGrain; clearcoatAmount: .14; clearcoatRoughnessAmount: .3 }
- PrincipledMaterial { id: smoothVinyl; baseColor: "#17191d"; metalness: 0; roughness: .32; roughnessMap: vinylGrain; clearcoatAmount: .14; clearcoatRoughnessAmount: .3 }
- PrincipledMaterial { id: gold; baseColor: Qt.tint("#d6ae58",Qt.alpha(app.accent,.045)); metalness: 1; roughness: .26; roughnessMap: brushedGrain; normalMap: metalMicroSurface; normalStrength: .12 }
- PrincipledMaterial { id: steel; baseColor: Qt.tint("#cbd0d4",Qt.alpha(app.accent,.025)); metalness: 1; roughness: .34; roughnessMap: turnedGrain; normalMap: metalMicroSurface; normalStrength: .24 }
- PrincipledMaterial { id: counterweightSteel; baseColor: Qt.tint("#c3c8cc",Qt.alpha(app.accent,.025)); metalness: 1; roughness: .31; roughnessMap: brushedGrain; normalMap: knurledGrain; normalStrength: .5 }
- PrincipledMaterial { id: platterMetal; baseColor: Qt.tint("#737b80",Qt.alpha(app.accent,.04)); metalness: 1; roughness: .5; roughnessMap: turnedGrain }
- PrincipledMaterial { id: label; baseColorMap: cover; roughness: app.vinyl?.92:.46; roughnessMap: paperGrain; clearcoatAmount: app.vinyl?0:.18; clearcoatRoughnessAmount: .3 }
- PrincipledMaterial { id: housingFinish; baseColor: view.caseTint; metalness: 0; roughness: .4; roughnessMap: moldedGrain; clearcoatAmount: .22; clearcoatRoughnessAmount: .4 }
- PrincipledMaterial { id: plateFinish; baseColor: view.plateTint; metalness: 0; roughness: .48; roughnessMap: moldedGrain }
- PrincipledMaterial { id: lidEdge; baseColor: view.glassTint; metalness: 0; roughness: .14; alphaMode: PrincipledMaterial.Blend; opacity: .32; clearcoatAmount: .7; clearcoatRoughnessAmount: .12 }
- PrincipledMaterial { id: tapePlastic; baseColor: "#d0cab9"; metalness: 0; roughness: .48; roughnessMap: moldedGrain }
- component Solid: Model {
- id: solidNode
- property vector3d size: Qt.vector3d(20,20,10)
- property real rounding: 2
- property color tint: "#30363b"
- geometry: DeckGeometry { dimensions: solidNode.size; radius: solidNode.rounding }
- property Material finish: PrincipledMaterial { baseColor: solidNode.tint; metalness: 0; roughness: .55; roughnessMap: moldedGrain }
- materials: [finish]
- }
- component Ring: Model {
- id: ringNode
- property real radius: 10
- property real hole: 3
- property real depth: 2
- property bool grooves: false
- geometry: RecordGeometry { radius: ringNode.radius; hole: ringNode.hole; depth: ringNode.depth; grooves: ringNode.grooves }
- property Material finish: rubber
- materials: [finish]
- }
- component TapeSpan: Model {
- property vector2d start
- property vector2d end
- source: "#Cube"
- x: (start.x+end.x)/2; y: (start.y+end.y)/2; z: 14
- eulerRotation.z: Math.atan2(end.y-start.y,end.x-start.x)*180/Math.PI
- scale: Qt.vector3d(Math.hypot(end.x-start.x,end.y-start.y)/100,.012,.03)
- materials: PrincipledMaterial { baseColor: "#352017"; roughness: .47 }
- }
Node {
id: assembly
y: app.vinyl ? -45 : 0
- eulerRotation: Qt.vector3d(app.vinyl?-42+view.vinylPitch:app.recorder?-12+view.recorderPitch:-24+view.pitchOffset,app.vinyl?-12+view.vinylYaw:app.recorder?-12+view.recorderYaw:-7+view.yawOffset,0)
- Loader3D { id: recorderScene; active: app.recorder; sourceComponent: Recorder3D { app: view.app; artworkTexture: cover } }
+ eulerRotation: Qt.vector3d(app.vinyl?-42+view.vinylPitch:app.recorder?-12+view.recorderPitch:app.cassette?18+view.cassettePitch:-44+view.cdPitch,app.vinyl?-12+view.vinylYaw:app.recorder?-12+view.recorderYaw:app.cassette?-24+view.cassetteYaw:-16+view.cdYaw,0)
+ Loader3D { id: recorderScene; active: app.recorder; sourceComponent: Recorder3D { app: view.app; artworkTexture: cover; x: view.app.tx6Visible?-142:0; scale: view.app.tx6Visible?Qt.vector3d(.85,.85,.85):Qt.vector3d(1,1,1) } }
+ Loader3D { id: tx6Scene; active: app.tx6Visible; sourceComponent: Tx6_3D { app:view.app;x:145;scale:Qt.vector3d(.85,.85,.85) } }
+ Loader3D { active:app.tx6Visible;sourceComponent:Tx6Cable3D {} }
+ Loader3D { id: cassetteScene; active: app.cassette; sourceComponent: Cassette3D { app: view.app; labelTexture: tapeLabel } }
Loader3D { id: vinylScene; active: app.vinyl; sourceComponent: Vinyl3D { app: view.app; artworkTexture: cover; outgoingTexture: oldCover } }
- Loader3D { id: legacyMedium; active: !app.recorder && !app.vinyl; sourceComponent: Node {
- property alias lidNode: lidPivot
- Solid {
- objectName: "threeDEnclosure"
- y: app.cassette?-4.5:0; z: -15
- size: app.cassette?Qt.vector3d(402,283,28):Qt.vector3d(428,428,28)
- rounding: app.cassette?23:app.vinyl?22:214; tint: view.caseTint
- finish: housingFinish
- }
- Solid {
- objectName: "threeDEnclosureSeam"
- y: app.cassette?-4.5:0; z: -24
- size: app.cassette?Qt.vector3d(402.3,283.3,1.1):Qt.vector3d(428.3,428.3,1.1)
- rounding: app.cassette?23:app.vinyl?22:214; finish: rubber
- }
- Solid {
- objectName: "threeDTopPlate"
- y: app.cassette?-4.5:0; z: .1
- size: app.cassette?Qt.vector3d(388,269,2):Qt.vector3d(414,414,2)
- rounding: app.cassette?19:app.vinyl?17:207; tint: view.plateTint
- finish: plateFinish
- }
- Repeater3D {
- model: app.vinyl?4:0
- Node {
- required property int index
- x: index%2?193:-193; y: index<2?193:-193; z: 2
- Ring { radius: 3.2; hole: .25; depth: 1.2; finish: metal }
- Solid { size: Qt.vector3d(4,.7,.3); z: .8; rounding: .2; tint: "#202228" }
- }
- }
- Repeater3D {
- model: 4
- Model {
- required property int index
- source: "#Cylinder"; x: (index%2?1:-1)*(app.cassette?157:app.vinyl?160:120)
- y: (index<2?1:-1)*(app.cassette?107:app.vinyl?162:120); z: -33
- eulerRotation.x: 90; scale: Qt.vector3d(.24,.1,.24); materials: rubber
- }
- }
- Ring { visible: !app.cassette; radius: 182; hole: 3; depth: 7; z: -1; finish: rubber }
- Ring { visible: !app.cassette; radius: 180; hole: 176.5; depth: 1.1; z: 2.1; finish: app.vinyl?platterMetal:metal }
- Ring { visible: !app.cassette; radius: 183; hole: 179; depth: 3; z: 0; finish: app.vinyl?platterMetal:metal }
- Ring { objectName: "threeDPlatterLip"; visible: app.vinyl; radius: 181.4; hole: 180.3; depth: .7; z: 2.8; finish: steel }
- Node {
- id: medium
- objectName: "threeDMedium"
- x: app.swapOffset*.86
- opacity: app.incomingOpacity
- Node {
- visible: !app.cassette
- eulerRotation.z: -app.spinAngle
- Ring { objectName: "threeDRecord"; radius: 176; hole: app.vinyl?3.5:15; depth: app.vinyl?2.8:1.2; grooves: app.vinyl; z: 4; finish: app.vinyl?blackVinyl:metal }
- Ring { objectName: "threeDRunout"; visible: app.vinyl; radius: 78; hole: 62.6; depth: .07; z: 5.47; finish: smoothVinyl }
- Ring { visible: app.vinyl; radius: 175.7; hole: 174; depth: .06; z: 5.46; finish: smoothVinyl }
- Repeater3D {
- objectName: "threeDTrackBands"
- model: app.recordMap ? app.recordMap.rows.length-1 : 0
- Ring {
- required property int index
- readonly property real boundaryAngle: app.recordMap ? (6+20*app.recordMap.rows[index+1].start/app.recordMap.total)*Math.PI/180 : 0
- radius: Math.hypot(173-197*Math.sin(boundaryAngle),-105+197*Math.cos(boundaryAngle))*.86
- hole: radius-.8; depth: .08; z: 5.48
- finish: PrincipledMaterial { baseColor: "#43484a"; metalness: .2; roughness: .38 }
- }
- }
- Ring { objectName: "threeDRecordLabel"; radius: app.vinyl?62:169; hole: app.vinyl?3.5:32; depth: .25; z: app.vinyl?5.6:4.8; finish: label }
- Ring { visible: app.vinyl; radius: 62.6; hole: 61.8; depth: .3; z: 5.55; finish: blackVinyl }
- Ring { objectName: "threeDOpticalRim"; visible: !app.vinyl; radius: 175.5; hole: 169.2; depth: .18; z: 4.72; finish: PrincipledMaterial { baseColorMap: opticalFilm; metalness: .8; roughness: .19; clearcoatAmount: .65; clearcoatRoughnessAmount: .12 } }
- Ring { visible: !app.vinyl; radius: 33; hole: 31.5; depth: .2; z: 5; finish: metal }
- Ring { castsShadows: false; visible: !app.vinyl; radius: 32; hole: 15; depth: .4; z: 4.9; finish: PrincipledMaterial { baseColor: view.glassTint; metalness: .3; roughness: .15; alphaMode: PrincipledMaterial.Blend; opacity: .6 } }
- Ring { objectName: "threeDHubPressing"; visible: !app.vinyl; radius: 27.5; hole: 26.7; depth: .25; z: 5.15; finish: steel }
- Ring { visible: !app.vinyl; radius: 16.2; hole: 15; depth: .5; z: 5; finish: lidEdge; castsShadows: false }
- }
- Node {
- visible: app.cassette
- objectName: "threeDCassette"
- Solid { size: Qt.vector3d(346,214,12); y: 4; z: 4; rounding: 12; finish: PrincipledMaterial { baseColor: Qt.darker(app.cassetteShell,1.4); alphaMode: PrincipledMaterial.Blend; opacity: player.cassetteFinish === "clear" ? .68 : 1; roughness: .32 } }
- Solid { objectName: "threeDTapeWell"; size: Qt.vector3d(296,136,3); y: 13; z: 10.2; rounding: 25; finish: rubber }
- Solid { objectName: "threeDLabelBacking"; size: Qt.vector3d(320,36,.8); y: 91; z: 13.1; rounding: 6; tint: "#aa9e88" }
- Solid { size: Qt.vector3d(318,34,1.5); y: 91; z: 14; rounding: 6; finish: PrincipledMaterial { baseColorMap: tapeLabel; roughness: .88 } }
- Solid { size: Qt.vector3d(326,34,9); y: -76; z: 12; rounding: 6; tint: app.cassetteShell }
- Repeater3D {
- model: 2
- Node {
- id: reel
- required property int index
- objectName: "threeDReel"+index
- x: index?78.6:-78.6; y: 13; z: 13
- readonly property real fill: index?view.progress:1-view.progress
- Ring { radius: 60; hole: .2; depth: .6; z: -2; finish: rubber }
- Ring { radius: Math.sqrt(1936+3993*reel.fill)*.77; hole: 31; depth: 5; grooves: true; finish: PrincipledMaterial { baseColor: "#32231b"; roughness: .64 } }
- Ring { objectName: "threeDReelBezel"+reel.index; radius: 62; hole: 60; depth: 1.5; z: 8; finish: rubber }
- Node {
- objectName: "threeDHub"+reel.index
- eulerRotation.z: -(reel.index?app.cassetteRightAngle:app.cassetteLeftAngle)
- Model { objectName: "threeDReelWeb"+reel.index; geometry: reelWeb; z: 2; materials: tapePlastic }
- Ring { radius: 27.5; hole: 25.5; depth: .8; z: 5.2; finish: tapePlastic }
- }
- }
- }
- Solid { objectName: "threeDTapeRibbon"; size: Qt.vector3d(286,1.2,3); y: -58; z: 14; rounding: .3; tint: "#352017" }
- Repeater3D {
- model: 2
- Node {
- id: tapeGuide
- required property int index
- readonly property real side: index?1:-1
- readonly property real packRadius: Math.sqrt(1936+3993*(index?view.progress:1-view.progress))*.77
- readonly property real tangent: Math.sqrt(64.4*64.4+61*61-Math.pow(packRadius-10,2))/(64.4*64.4+61*61)
- readonly property real radial: (packRadius-10)/(64.4*64.4+61*61)
- readonly property vector2d normal: Qt.vector2d(side*(64.4*radial+61*tangent),-61*radial+64.4*tangent)
- TapeSpan {
- objectName: "threeDTapeFeed"+tapeGuide.index
- start: Qt.vector2d(tapeGuide.side*78.6+tapeGuide.packRadius*tapeGuide.normal.x,13+tapeGuide.packRadius*tapeGuide.normal.y)
- end: Qt.vector2d(tapeGuide.side*143+10*tapeGuide.normal.x,-48+10*tapeGuide.normal.y)
- }
- Ring { x: tapeGuide.side*143; y: -59; z: 14; radius: 4; hole: 1.2; depth: 5; finish: steel }
- }
- }
- Repeater3D {
- model: 2
- Node {
- required property int index
- x: index?143:-143; y: -48; z: 13
- Ring { radius: 10; hole: 3; depth: 7; finish: rubber }
- Ring { radius: 3; hole: .5; depth: 8; finish: metal }
- }
- }
- Solid { objectName: "threeDTapePressureSpring"; size: Qt.vector3d(44,3,1); y: -61; z: 12; rounding: .5; finish: gold }
- Solid { size: Qt.vector3d(18,4,3); y: -60; z: 13; rounding: 1; tint: "#948372" }
- Solid { size: Qt.vector3d(36,18,1); y: -83; z: 17; rounding: 3; finish: rubber }
- Solid { objectName: "threeDTapeHead"; size: Qt.vector3d(26,13,5); y: -83; z: 19; rounding: 3; finish: steel }
- Solid { size: Qt.vector3d(.7,11,.3); y: -83; z: 21.6; rounding: .2; tint: "#34383b" }
- Repeater3D {
- model: 8
- Solid { required property int index; x: (index<4?-1:1)*(123+(index%4)*8); y: -73; z: 17; size: Qt.vector3d(2,20,1); rounding: .5; tint: Qt.darker(app.cassetteShell,1.3) }
- }
- Solid { size: Qt.vector3d(5,111,4); y: 13; z: 21; rounding: 2; tint: app.cassetteShell }
- Solid { objectName: "threeDTapeWindow"; castsShadows: false; receivesShadows: false; size: Qt.vector3d(296,136,1); y: 13; z: 23; rounding: 25; finish: PrincipledMaterial { baseColor: view.glassTint; metalness: 0; alphaMode: PrincipledMaterial.Blend; opacity: .065; roughness: .19; clearcoatAmount: .6; clearcoatRoughnessAmount: .15 } }
- Repeater3D {
- model: 4
- Node {
- required property int index
- x: (index%2?1:-1)*159; y: (index<2?1:-1)*94; z: 13
- Ring { radius: 3.8; hole: .4; depth: 2; finish: metal }
- Solid { size: Qt.vector3d(5,1,1); z: 1.2; rounding: .2; tint: "#202428" }
- }
- }
- }
- }
- Node {
- objectName: "threeDOutgoingMedium"
- visible: app.outgoingOpacity>0
- x: app.outgoingOffset*.86; opacity: app.outgoingOpacity
- Ring { visible: !app.cassette; radius: 176; hole: app.vinyl?3.5:15; depth: 2.8; grooves: app.vinyl; z: 4; finish: app.vinyl?blackVinyl:metal }
- Ring { visible: !app.cassette; radius: app.vinyl?62:169; hole: app.vinyl?3.5:32; depth: .25; z: 5.6; eulerRotation.z: -app.outgoingAngle; finish: PrincipledMaterial { baseColorMap: oldCover; roughness: .85 } }
- Solid { visible: app.cassette; size: Qt.vector3d(346,214,15); rounding: 12; z: 6; tint: app.cassetteShell }
- }
- Node {
- id: lidPivot
- visible: !app.vinyl
- y: app.cassette?108:194; z: 18
- eulerRotation.x: -app.lidOpen*40
- Solid {
- objectName: "threeDLid"
- castsShadows: false; receivesShadows: false
- y: app.cassette?-112.5:-194
- size: app.cassette?Qt.vector3d(356,225,2):Qt.vector3d(388,388,2)
- rounding: app.cassette?12:194
- finish: PrincipledMaterial { baseColor: view.glassTint; alphaMode: PrincipledMaterial.Blend; opacity: .065; metalness: .1; roughness: .16; cullMode: Material.NoCulling }
- }
- Ring { objectName: "threeDLidRim"; visible: !app.cassette; y: -194; radius: 193.5; hole: 190; depth: 3.5; finish: lidEdge; castsShadows: false; receivesShadows: false }
- Solid { objectName: "threeDLidLatch"; y: app.cassette?-224:-383; z: 1.5; size: Qt.vector3d(28,6,4); rounding: 2; finish: lidEdge; castsShadows: false }
- }
- Repeater3D {
- model: 2
- Model { required property int index; source: "#Cylinder"; x: (index?1:-1)*(app.cassette?124:app.vinyl?140:48); y: app.cassette?109:app.vinyl?207:191; z: 14; eulerRotation.z: 90; scale: Qt.vector3d(.065,.24,.065); materials: metal }
- }
- Model { visible: app.vinyl; source: "#Cylinder"; z: 9; eulerRotation.x: 90; scale: Qt.vector3d(.07,.16,.07); materials: steel }
- Model { visible: app.vinyl; source: "#Sphere"; z: 16; scale: Qt.vector3d(.07,.07,.07); materials: steel }
- Ring { visible: app.vinyl; radius: 4.7; hole: 3.5; depth: .6; z: 7; finish: steel }
- Node {
- objectName: "threeDCdSpindle"
- visible: !app.cassette && !app.vinyl
- z: 8
- Ring { radius: 13.8; hole: 3; depth: 6; finish: rubber }
- Ring { radius: 11.8; hole: 9.5; depth: .55; z: 3.2; finish: steel }
- Model { source: "#Cylinder"; eulerRotation.x: 90; scale: Qt.vector3d(.045,.073,.045); materials: steel }
- Repeater3D {
- model: 3
- Node {
- required property int index
- eulerRotation.z: index*120
- Solid { objectName: "threeDSpindleClip"+index; x: 12.5; z: 2; size: Qt.vector3d(7.5,4,2.2); rounding: 1.5; finish: steel }
- }
- }
- }
- Node {
- visible: app.vinyl && !!app.tonearm
- objectName: "threeDTonearm"
- x: 135.88; y: 103.2; z: 11
- Model { source: "#Cylinder"; eulerRotation.x: 90; scale: Qt.vector3d(.25,.12,.25); materials: rubber }
- Ring { objectName: "threeDBearingCollar"; radius: 16.5; hole: 10; depth: 3; z: 1.5; finish: steel }
- Ring { objectName: "threeDBearingHousing"; radius: 15; hole: 9; depth: 10; z: 8; eulerRotation.x: 90; finish: steel }
- Repeater3D {
- model: 2
- Node {
- required property int index
- x: index?15:-15; z: 8; eulerRotation.y: 90
- Ring { radius: 4; hole: .6; depth: 2; finish: steel }
- Solid { size: Qt.vector3d(5,.6,.3); z: 1.1; rounding: .2; finish: rubber }
- }
- }
- Model { source: "#Cylinder"; z: 8; eulerRotation.x: 90; scale: Qt.vector3d(.16,.09,.16); materials: gold }
- Node {
- id: armPivot
- eulerRotation.z: app.tonearm?-app.tonearm.armAngle:4
- eulerRotation.x: app.tonearm?-6*(1-app.tonearm.lowered):0
- z: 12
- Model { objectName: "threeDArmTube"; source: "#Cylinder"; y: -79; scale: Qt.vector3d(.045,1.58,.045); materials: gold }
- Model { objectName: "threeDCounterweight"; source: "#Cylinder"; y: 23; scale: Qt.vector3d(.23,.24,.23); materials: counterweightSteel }
- Repeater3D {
- model: 2
- Ring { required property int index; radius: 11.6; hole: 10.6; depth: .8; y: 12+index*22; eulerRotation.x: 90; finish: steel }
- }
- Model { source: "#Cylinder"; y: 10; scale: Qt.vector3d(.10,.06,.10); materials: rubber }
- Model { source: "#Cylinder"; y: 34; scale: Qt.vector3d(.24,.03,.24); materials: rubber }
- Solid { objectName: "threeDFingerLift"; x: 9; y: -158; z: 6; size: Qt.vector3d(14,3,2); rounding: 1; eulerRotation.y: -18; finish: steel }
- Solid { objectName: "threeDHeadshell"; y: -159; z: 3; size: Qt.vector3d(15,27,2); rounding: 3; finish: platterMetal }
- Repeater3D {
- model: 2
- Model { required property int index; source: "#Cylinder"; x: index?3:-3; y: -160; z: 5; eulerRotation.x: 90; scale: Qt.vector3d(.022,.025,.022); materials: metal }
- }
- Solid { objectName: "threeDCartridge"; y: -165; z: -2; size: Qt.vector3d(12,21,11); rounding: 3; tint: Qt.tint(app.surface,Qt.alpha("#c6a25a",.15)) }
- Solid { y: -167; z: 4; size: Qt.vector3d(6,10,1); rounding: 1; finish: gold }
- Solid { y: -169.42; z: -7; size: Qt.vector3d(3,6,5); rounding: .5; tint: "#171b1d" }
- Model { objectName: "threeDStylus"; source: "#Cone"; y: -169.42; z: -13; eulerRotation.x: -90; scale: Qt.vector3d(.015,.09,.015); materials: metal }
- }
- }
- Node {
- visible: app.packageOpacity>0; opacity: app.packageOpacity
- x: 126; y: -107; z: 28; eulerRotation.z: -12
- Solid { objectName: "threeDAlbumCase"; size: Qt.vector3d(130,130,5); rounding: 3; finish: metal }
- Solid { size: Qt.vector3d(120,122,.5); x: 3; z: 3; rounding: 1; finish: label }
- }
- Model {
- visible: app.deckPlayer.count>0
- geometry: WaveGeometry { progress: view.progress; phase: app.wavePhase; amplitude: app.deckPlayer.playing?2.4:0; linear: app.cassette }
- materials: PrincipledMaterial { baseColor: app.accent; lighting: PrincipledMaterial.NoLighting; cullMode: Material.NoCulling }
- }
+ Loader3D { id: cdScene; active: app.cd; sourceComponent: Cd3D { app: view.app; artworkTexture: cover; outgoingTexture: oldCover } }
}
- } }
// Pointer math intersects the same plane as the physical controls. It never
// installs a Qt Quick 3D transform on the shared 2D control tree.
- function projectSurface(x,y) { return projectSurfaceDepth(x,y,app.recorder?16:.5) }
+ function projectSurface(x,y) { return projectSurfaceDepth(x,y,app.recorder?16:app.cassette?36:app.cd?5:.5) }
function projectSurfaceDepth(x,y,depth) {
- const space=app.vinyl && vinylScene.item ? vinylScene.item.recordSpace : assembly
- const p=mapFrom3DScene(space.mapPositionToScene(Qt.vector3d(x-265,294-y,depth)))
+ const space=app.vinyl && vinylScene.item ? vinylScene.item.recordSpace : app.recorder && recorderScene.item ? recorderScene.item : assembly
+ const rp=app.recorder && app.recorderView ? app.recorderView.mapFromItem(surfaceItem,x,y) : Qt.point(x-60,y-89)
+ const p=mapFrom3DScene(space.mapPositionToScene(Qt.vector3d(app.recorder?rp.x-205:x-265,app.recorder?205-rp.y:294-y,depth)))
return Qt.point(p.x,p.y)
}
- function unprojectSurface(x,y) { return unprojectPlane(x,y,app.recorder?16:.5) }
+ function unprojectSurface(x,y) { return unprojectPlane(x,y,app.recorder?16:app.cassette?36:app.cd?5:.5) }
function unprojectPlane(x,y,depth) {
- const space=app.vinyl && vinylScene.item ? vinylScene.item.recordSpace : assembly
+ const space=app.vinyl && vinylScene.item ? vinylScene.item.recordSpace : app.recorder && recorderScene.item ? recorderScene.item : assembly
const a=space.mapPositionFromScene(mapTo3DScene(Qt.vector3d(x,y,0)))
const b=space.mapPositionFromScene(mapTo3DScene(Qt.vector3d(x,y,1000)))
const t=(depth-a.z)/(b.z-a.z)
+ if(app.recorder && app.recorderView)return app.recorderView.mapToItem(surfaceItem,a.x+(b.x-a.x)*t+205,205-a.y-(b.y-a.y)*t)
return Qt.point(a.x+(b.x-a.x)*t+265,294-a.y-(b.y-a.y)*t)
}
function projectRecorderControl(index) { const p=mapFrom3DScene(recorderScene.item.controlScenePoint(index));return Qt.point(p.x,p.y) }
+ function projectTx6Control(index) {const p=mapFrom3DScene(tx6Scene.item.controlPoint(index));return Qt.point(p.x,p.y)}
+ function projectTx6Face(x,y) {
+ const p=mapFrom3DScene(tx6Scene.item.mapPositionToScene(tx6Scene.item.surface(x,y,14)))
+ return Qt.point(p.x,p.y)
+ }
+ function tx6FacePoint(x,y) {
+ const space=tx6Scene.item
+ const a=space.mapPositionFromScene(mapTo3DScene(Qt.vector3d(x,y,0)))
+ const b=space.mapPositionFromScene(mapTo3DScene(Qt.vector3d(x,y,1000)))
+ const t=(14-a.z)/(b.z-a.z)
+ return Qt.point(a.x+(b.x-a.x)*t+122,176-a.y-(b.y-a.y)*t)
+ }
+ function assistedTx6Hit(x,y,object) {
+ if(!app.tx6Visible || !tx6Scene.item || !app.tx6Controls || app.menuOpen)return null
+ // Assistance belongs only to the visible mixer face. Never reach
+ // through its back, a cable, or the other device to find a control.
+ if(tx6Scene.item.mapDirectionToScene(Qt.vector3d(0,0,1)).z<.3)return null
+ let parent=object
+ while(parent && parent!==tx6Scene.item)parent=parent.parent
+ if(!parent)return null
+ const local=tx6FacePoint(x,y)
+ if(local.x<0 || local.x>244 || local.y<0 || local.y>352)return null
+ let nearest=-1,score=Infinity
+ for(let i=0;i<34;i++) {
+ if(!app.tx6Controls.canUse(i))continue
+ const center=projectTx6Control(i)
+ const distance=Math.hypot(x-center.x,y-center.y)
+ // Nearest-center resolution keeps neighboring knobs distinct even
+ // when their invisible hit areas overlap at an oblique angle.
+ const radius=i<24 ? 14 : 18
+ if(distance<=radius && distance<score){nearest=i;score=distance}
+ }
+ if(nearest>=0)return {control:null,body:true,depth:16,hardware:-1,tx6:nearest}
+ if(local.y>=201 && local.y<=290) {
+ const channel=Math.round((local.x-22)/29.3)
+ if(channel>=0 && channel<6 && Math.abs(local.x-(22+channel*29.3))<=12 && app.tx6Controls.canUse(18+channel))
+ return {control:null,body:true,depth:16,hardware:-1,tx6:18+channel,faderLevel:Math.max(0,Math.min(1,(285-local.y)/77))}
+ }
+ return null
+ }
function recorderHit(x,y) {
const hit=pick(x,y)
if(!hit.objectHit)return {control:null,body:false,depth:16}
+ if(hit.objectHit.tx6Info)return {control:null,body:true,depth:16,hardware:-1,info:hit.objectHit.tx6Info}
+ const txIndex=hit.objectHit.tx6Control
+ if(txIndex>=0)return {control:null,body:true,depth:16,hardware:-1,tx6:txIndex}
+ const assisted=assistedTx6Hit(x,y,hit.objectHit)
+ if(assisted)return assisted
const index=hit.objectHit.recorderControl
const controls=app.recorderView
const control=controls && index>=0 && index<controls.controls.length ? controls.controls[index].pointerInput : controls && index===20 ? controls.wheelInput : null
- return {control:control && control.enabled ? control : null,body:true,depth:assembly.mapPositionFromScene(hit.scenePosition).z}
+ return {control:control && control.enabled ? control : null,body:true,depth:recorderScene.item.mapPositionFromScene(hit.scenePosition).z}
+ }
+ function resetCdOrientation() { cdYaw=0;cdPitch=0 }
+ function projectCdControl(index) { const p=mapFrom3DScene(cdScene.item.controlPoint(index));return Qt.point(p.x,p.y) }
+ function cdHit(x,y) {
+ const miss={control:null,body:false,depth:5,hardware:-1}
+ if(app.menuOpen || app.swapRunning)return miss
+ const hit=pick(x,y)
+ const index=hit.objectHit ? hit.objectHit.cdControl : -1
+ if(index>=0 && app.cdControls && app.cdControls.canUse(index))return {control:null,body:true,depth:5,hardware:index}
+ const front=assembly.mapDirectionToScene(Qt.vector3d(0,0,1)).z>.18
+ const control=front ? app.controlAt3DPoint(unprojectSurface(x,y)) : null
+ return {control:control,body:!!hit.objectHit,depth:5,hardware:-1}
+ }
+ function resetCassetteOrientation() { cassetteYaw=0;cassettePitch=0 }
+ function projectCassetteControl(index) { const p=mapFrom3DScene(cassetteScene.item.controlPoint(index));return Qt.point(p.x,p.y) }
+ function cassetteHit(x,y) {
+ const miss={control:null,body:false,depth:36,hardware:-1}
+ if(app.menuOpen || app.swapRunning)return miss
+ const hit=pick(x,y)
+ const index=hit.objectHit ? hit.objectHit.cassetteControl : -1
+ if(index>=0 && app.cassetteControls && app.cassetteControls.canUse(index))return {control:null,body:true,depth:36,hardware:index}
+ const front=assembly.mapDirectionToScene(Qt.vector3d(0,0,1)).z>.18
+ const control=front ? app.controlAt3DPoint(unprojectSurface(x,y)) : null
+ return {control:control,body:!!hit.objectHit,depth:36,hardware:-1}
}
function resetRecorderOrientation() { recorderYaw=0;recorderPitch=0 }
function resetVinylOrientation() { vinylYaw=0;vinylPitch=0 }
@@ -445,11 +272,19 @@ View3D {
return {control:control,body:true,depth:.5,hardware:-1}
}
function lidBounds() {
- if(!legacyMedium.item)return Qt.rect(0,0,0,0)
- let left=width,top=height,right=0,bottom=0
- for(let i=0;i<32;++i){const a=i*Math.PI/16;const point=app.cassette?Qt.vector3d(i%2?178:-178,i<16?0:-225,0):Qt.vector3d(194*Math.cos(a),-194+194*Math.sin(a),0);const p=mapFrom3DScene(legacyMedium.item.lidNode.mapPositionToScene(point));left=Math.min(left,p.x);right=Math.max(right,p.x);top=Math.min(top,p.y);bottom=Math.max(bottom,p.y)}
- return Qt.rect(left,top,right-left,bottom-top)
+ if(app.cassette && cassetteScene.item) {
+ const points=[]
+ for(const x of [-191,191])for(const y of [0,266])points.push(mapFrom3DScene(cassetteScene.item.lidNode.mapPositionToScene(Qt.vector3d(x,y,0))))
+ const left=Math.min(...points.map(p=>p.x)),top=Math.min(...points.map(p=>p.y))
+ return Qt.rect(left,top,Math.max(...points.map(p=>p.x))-left,Math.max(...points.map(p=>p.y))-top)
+ }
+ if(!cdScene.item)return Qt.rect(0,0,0,0)
+ const points=[]
+ for(const x of [-206,206])for(const y of [2,-400])points.push(mapFrom3DScene(cdScene.item.lidNode.mapPositionToScene(Qt.vector3d(x,y,0))))
+ const left=Math.min(...points.map(p=>p.x)),top=Math.min(...points.map(p=>p.y))
+ return Qt.rect(left,top,Math.max(...points.map(p=>p.x))-left,Math.max(...points.map(p=>p.y))-top)
}
+
MouseArea {
id: pointer
objectName: "threeDPointer"
@@ -458,18 +293,25 @@ View3D {
property point pressPoint
property bool windowDragAllowed: false
property bool hoveredBody: false
+ property int hoveredHardware: -1
+ property int hoveredTx6: -1
+ property bool channelMenuPress: false
property real startYaw: 0
property real startPitch: 0
property real grabDepth: 16
property string hint: ""
function updateHint(x,y) {
+ hoveredTx6=-1
const point=view.unprojectSurface(x,y)
- const hit=view.app.vinyl ? view.vinylHit(x,y) : view.app.recorder ? view.recorderHit(x,y) : null
+ const hit=view.app.vinyl ? view.vinylHit(x,y) : view.app.recorder ? view.recorderHit(x,y) : view.app.cassette ? view.cassetteHit(x,y) : view.cdHit(x,y)
+ if(hit && hit.info){hoveredBody=true;hoveredControl=null;hint=hit.info;return}
+ if(hit && hit.tx6>=0) {hoveredTx6=hit.tx6;hoveredBody=true;hoveredControl=null;hoveredHardware=-1;hint=view.app.tx6Controls.caption(hit.tx6);return}
const target=hit ? hit.control : view.app.controlAt3DPoint(point)
hoveredBody=!!hit && hit.body
+ hoveredHardware=hit && hit.hardware!==undefined ? hit.hardware : -1
if(hit && hit.hardware>=0) {
hoveredControl=null;hoveredBody=true
- hint=["33⅓ RPM", "45 RPM", view.app.deckPlayer.playing?"Lift needle and pause":"Lower needle and play", vinylScene.item.coverOpen?"Close dust cover":"Open dust cover"][hit.hardware]
+ hint=view.app.cd ? view.app.cdControls.keyItems[hit.hardware].caption : view.app.cassette ? view.app.cassetteControls.keyItems[hit.hardware].caption : ["33⅓ RPM", "45 RPM", view.app.deckPlayer.playing?"Lift needle and pause":"Lower needle and play", vinylScene.item.coverOpen?"Close dust cover":"Open dust cover"][hit.hardware]
return
}
if(target!==hoveredControl)hintDismissed=false
@@ -489,17 +331,29 @@ View3D {
}
anchors.fill: parent; hoverEnabled: true; preventStealing: true; acceptedButtons: Qt.AllButtons
onPressed: mouse => {
- hintDismissed=true;pressPoint=Qt.point(mouse.x,mouse.y)
- const hit=view.app.vinyl ? view.vinylHit(mouse.x,mouse.y) : view.app.recorder ? view.recorderHit(mouse.x,mouse.y) : null
+ hintDismissed=true;pressPoint=Qt.point(mouse.x,mouse.y);channelMenuPress=false
+ const hit=view.app.vinyl ? view.vinylHit(mouse.x,mouse.y) : view.app.recorder ? view.recorderHit(mouse.x,mouse.y) : view.app.cassette ? view.cassetteHit(mouse.x,mouse.y) : view.cdHit(mouse.x,mouse.y)
grabDepth=hit ? hit.depth : .5
- if(mouse.button===Qt.LeftButton && hit && hit.hardware>=0) { vinylScene.item.beginHardware(hit.hardware);windowDragAllowed=false;return }
+ if(hit && hit.tx6>=0) {
+ if(mouse.button===Qt.RightButton && hit.tx6<30){const i=hit.tx6;channelMenuPress=true;view.app.tx6Controls.openChannel(i<18?i%6:i<24?i-18:i-24);windowDragAllowed=false;return}
+ if(mouse.button===Qt.LeftButton){
+ const p=view.tx6FacePoint(mouse.x,mouse.y)
+ if(hit.faderLevel!==undefined)view.app.tx6Controls.setValue(hit.tx6,hit.faderLevel)
+ const center=view.app.tx6Controls.position(hit.tx6)
+ view.app.tx6Controls.begin(hit.tx6,p.y,(p.x-center.x)/18);windowDragAllowed=false;return
+ }
+ }
+ if(mouse.button===Qt.LeftButton && hit && hit.hardware>=0) { if(view.app.cd)view.app.cdControls.begin(hit.hardware,mouse.y);else if(view.app.cassette)view.app.cassetteControls.begin(hit.hardware,mouse.y);else vinylScene.item.beginHardware(hit.hardware);windowDragAllowed=false;return }
if(mouse.button===Qt.LeftButton)view.app.begin3DPointer(view.unprojectPlane(mouse.x,mouse.y,grabDepth),mouse.modifiers,hit ? hit.control : null)
view.orbiting=mouse.button===Qt.LeftButton && !!hit && hit.body && !view.app.threeDPointer && !view.app.menuOpen
- startYaw=view.app.vinyl?view.vinylYaw:view.recorderYaw;startPitch=view.app.vinyl?view.vinylPitch:view.recorderPitch
+ startYaw=view.app.vinyl?view.vinylYaw:view.app.cassette?view.cassetteYaw:view.app.cd?view.cdYaw:view.recorderYaw;startPitch=view.app.vinyl?view.vinylPitch:view.app.cassette?view.cassettePitch:view.app.cd?view.cdPitch:view.recorderPitch
windowDragAllowed=mouse.button===Qt.LeftButton && !view.app.threeDPointer && !view.orbiting
}
onPositionChanged: mouse => {
if(pressed) {
+ if(view.app.tx6Controls && view.app.tx6Controls.pressedControl>=0){view.app.tx6Controls.move(view.tx6FacePoint(mouse.x,mouse.y).y,view.recorderHit(mouse.x,mouse.y).tx6,mouse.modifiers&Qt.ShiftModifier);return}
+ if(view.app.cd && view.app.cdControls && view.app.cdControls.pressedControl>=0) { view.app.cdControls.move(mouse.y,view.cdHit(mouse.x,mouse.y).hardware);return }
+ if(view.app.cassette && view.app.cassetteControls && view.app.cassetteControls.pressedControl>=0) { view.app.cassetteControls.move(mouse.y,view.cassetteHit(mouse.x,mouse.y).hardware);return }
if(view.app.vinyl && vinylScene.item && vinylScene.item.pressedControl>=0) {
vinylScene.item.armed=view.vinylHit(mouse.x,mouse.y).hardware===vinylScene.item.pressedControl
return
@@ -509,6 +363,12 @@ View3D {
if(view.app.vinyl) {
view.vinylYaw=(startYaw+(mouse.x-pressPoint.x)*.55)%360
view.vinylPitch=Math.max(-35,Math.min(65,startPitch+(mouse.y-pressPoint.y)*.4))
+ } else if(view.app.cassette) {
+ view.cassetteYaw=(startYaw+(mouse.x-pressPoint.x)*.65)%360
+ view.cassettePitch=Math.max(-60,Math.min(70,startPitch+(mouse.y-pressPoint.y)*.5))
+ } else if(view.app.cd) {
+ view.cdYaw=(startYaw+(mouse.x-pressPoint.x)*.6)%360
+ view.cdPitch=Math.max(-50,Math.min(75,startPitch+(mouse.y-pressPoint.y)*.45))
} else {
view.recorderYaw=(startYaw+(mouse.x-pressPoint.x)*.65)%360
view.recorderPitch=Math.max(-65,Math.min(75,startPitch+(mouse.y-pressPoint.y)*.5))
@@ -517,13 +377,13 @@ View3D {
if(windowDragAllowed && !view.app.threeDPointer && (pressedButtons & Qt.LeftButton) && Math.hypot(mouse.x-pressPoint.x,mouse.y-pressPoint.y)>12)view.app.startSystemMove()
} else { updateHint(mouse.x,mouse.y);if(!hoveredControl)view.tilt(Qt.point(mouse.x,mouse.y)) }
}
- onReleased: { if(vinylScene.item)vinylScene.item.endHardware();view.app.end3DPointer();view.orbiting=false }
+ onReleased: mouse=> { if(view.app.tx6Controls)view.app.tx6Controls.end(mouse.modifiers);if(view.app.cdControls)view.app.cdControls.end();if(view.app.cassetteControls)view.app.cassetteControls.end();if(vinylScene.item)vinylScene.item.endHardware();view.app.end3DPointer();view.orbiting=false }
onCanceled: { if(vinylScene.item)vinylScene.item.cancelHardware();view.app.cancel3DPointer();view.orbiting=false }
- onClicked: mouse => { if(mouse.button===Qt.RightButton)view.app.openSettings() }
- onDoubleClicked: mouse => { if(mouse.button===Qt.LeftButton) { if(view.inspectable) { view.app.cancel3DPointer();view.orbiting=false;if(view.app.vinyl)view.resetVinylOrientation();else view.resetRecorderOrientation() } else if(!view.app.controlAt3DPoint(view.unprojectSurface(mouse.x,mouse.y)))view.app.flipDisc() } }
- onExited: { hoveredControl=null;hoveredBody=false;hint="";hintDismissed=false;if(!pressed){view.pitchOffset=0;view.yawOffset=0} }
- onWheel: wheel => { if(!view.app.menuOpen)view.app.deckPlayer.volume=Math.max(0,Math.min(1,view.app.deckPlayer.volume+wheel.angleDelta.y/2400));wheel.accepted=true }
- cursorShape: view.orbiting||view.app.threeDGesture?Qt.ClosedHandCursor:hoveredControl?Qt.PointingHandCursor:hoveredBody?Qt.OpenHandCursor:Qt.ArrowCursor
+ onClicked: mouse => { if(mouse.button===Qt.RightButton && !channelMenuPress)view.app.openSettings() }
+ onDoubleClicked: mouse => { if(mouse.button===Qt.LeftButton) { if(view.app.tx6Visible){const hit=view.recorderHit(mouse.x,mouse.y);if(hit.tx6>=0){view.app.tx6Controls.cancel();view.app.tx6Controls.resetControl(hit.tx6);return}}if(view.inspectable) { view.app.cancel3DPointer();view.orbiting=false;if(view.app.vinyl)view.resetVinylOrientation();else if(view.app.cassette)view.resetCassetteOrientation();else if(view.app.cd)view.resetCdOrientation();else view.resetRecorderOrientation() } else if(!view.app.controlAt3DPoint(view.unprojectSurface(mouse.x,mouse.y)))view.app.flipDisc() } }
+ onExited: { hoveredControl=null;hoveredBody=false;hoveredHardware=-1;hoveredTx6=-1;hint="";hintDismissed=false;if(!pressed){view.pitchOffset=0;view.yawOffset=0} }
+ onWheel: wheel => { if(view.app.tx6Visible){const hit=view.recorderHit(wheel.x,wheel.y);if(hit.tx6>=0){view.app.tx6Controls.scroll(hit.tx6,wheel.angleDelta.y/120);wheel.accepted=true;return}}if(!view.app.menuOpen)view.app.deckPlayer.volume=Math.max(0,Math.min(1,view.app.deckPlayer.volume+wheel.angleDelta.y/2400));wheel.accepted=true }
+ cursorShape: view.orbiting||view.app.threeDGesture?Qt.ClosedHandCursor:hoveredTx6>=0?(view.app.tx6Controls.canUse(hoveredTx6)?Qt.PointingHandCursor:Qt.ForbiddenCursor):(hoveredControl||hoveredHardware>=0)?Qt.PointingHandCursor:hoveredBody?Qt.OpenHandCursor:Qt.ArrowCursor
}
SpunToolTip {
objectName: "threeDToolTip"
diff --git a/qml/PreferenceSwitch.qml b/qml/PreferenceSwitch.qml
index 0f9306a..7ad3b8d 100644
--- a/qml/PreferenceSwitch.qml
+++ b/qml/PreferenceSwitch.qml
@@ -9,6 +9,8 @@ Switch {
padding: 0; spacing: 0
font.family: SpunStyle.family; font.pixelSize: SpunStyle.body
Accessible.name: text
+ Keys.onReturnPressed: event => { if(!event.isAutoRepeat) { toggle(); toggled() } }
+ Keys.onEnterPressed: event => { if(!event.isAutoRepeat) { toggle(); toggled() } }
background: Rectangle {
radius: SpunStyle.rowRadius
color: "transparent"
diff --git a/qml/Recorder3D.qml b/qml/Recorder3D.qml
index 20b15a5..7575417 100644
--- a/qml/Recorder3D.qml
+++ b/qml/Recorder3D.qml
@@ -9,10 +9,12 @@ Node {
readonly property var controls: app.recorderView
Texture { id: fineGrain; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "bead-normal" } scaleU: 2; scaleV: 2 }
Texture { id: knurled; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "knurled-normal" } scaleU: 1.5; scaleV: 1 }
- PrincipledMaterial { id: aluminum; baseColor: "#c3c8cb"; metalness: .85; roughness: .46 }
- PrincipledMaterial { id: faceFinish; baseColor: "#c3c8cb"; metalness: .8; roughness: .52; normalMap: fineGrain; normalStrength: .16 }
- PrincipledMaterial { id: wheelFinish; baseColor: "#b9bfc5"; metalness: .84; roughness: .52; normalMap: fineGrain; normalStrength: .1 }
- PrincipledMaterial { id: polished; baseColor: "#d5dbe0"; metalness: 1; roughness: .27 }
+ Texture { id: satin; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "satin" } }
+ Texture { id: turned; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "turned-normal" } }
+ PrincipledMaterial { id: aluminum; baseColor: "#ccd0d2"; metalness: .82; roughness: .38; roughnessMap: satin }
+ PrincipledMaterial { id: faceFinish; baseColor: "#cbd0d3"; metalness: .8; roughness: .43; roughnessMap: satin; normalMap: fineGrain; normalStrength: .13 }
+ PrincipledMaterial { id: wheelFinish; baseColor: "#c6cbce"; metalness: .88; roughness: .43; roughnessMap: satin; normalMap: turned; normalStrength: .055 }
+ PrincipledMaterial { id: polished; baseColor: "#d5dbe0"; metalness: 1; roughness: .23 }
PrincipledMaterial { id: black; baseColor: "#22292e"; roughness: .62 }
PrincipledMaterial { id: engraving; baseColor: "#657078"; metalness: .35; roughness: .65 }
PrincipledMaterial { id: orange; baseColor: "#ed7e1f"; roughness: .63; normalMap: fineGrain; normalStrength: .55 }
@@ -148,7 +150,7 @@ Node {
pickable: true; property int recorderControl: 7
source: "#Cylinder"; position: recorder.surface(294.5,389.5,-9); scale: Qt.vector3d(.35,.29,.35)
eulerRotation.y: recorder.app.deckPlayer.volume*270
- materials: PrincipledMaterial { baseColor: "#c3cbd1"; metalness: 1; roughness: .34; normalMap: knurled; normalStrength: .65 }
+ materials: PrincipledMaterial { baseColor: "#c3cbd1"; metalness: .9; roughness: .39; normalMap: knurled; normalStrength: .3 }
}
Model { pickable: true; property int recorderControl: 7; source: "#Cylinder"; position: recorder.surface(294.5,372,-9); scale: Qt.vector3d(.31,.06,.31); materials: polished }
Model { pickable: true; property int recorderControl: 7; source: "#Cylinder"; position: recorder.surface(294.5,376,-9); scale: Qt.vector3d(.35,.009,.35); materials: polished }
diff --git a/qml/SpunSlider.qml b/qml/SpunSlider.qml
index e637233..82d6eee 100644
--- a/qml/SpunSlider.qml
+++ b/qml/SpunSlider.qml
@@ -10,6 +10,19 @@ Slider {
focusPolicy: Qt.StrongFocus
property bool previewing: false
property string valueText: Math.round(value * 100) + "%"
+ Accessible.description: valueText
+ // Qt's horizontal Slider handles Left/Right; M3 also supports Up/Down
+ // and endpoints. Emit moved only for a user change, as pointer input does.
+ Keys.onUpPressed: { const before=value; increase(); if(value!==before)moved() }
+ Keys.onDownPressed: { const before=value; decrease(); if(value!==before)moved() }
+ Keys.onPressed: event => {
+ if(event.key===Qt.Key_Home || event.key===Qt.Key_End) {
+ const before=value
+ native.setSliderEndpoint(control,event.key===Qt.Key_End)
+ if(value!==before)moved()
+ event.accepted=true
+ } else event.accepted=false
+ }
background: Item {
x: control.leftPadding; y: control.topPadding
width: control.availableWidth; height: control.availableHeight
diff --git a/qml/TrackMenu.qml b/qml/TrackMenu.qml
index 2570de3..898f611 100644
--- a/qml/TrackMenu.qml
+++ b/qml/TrackMenu.qml
@@ -11,7 +11,7 @@ Menu {
property bool confirmDelete: false
readonly property var radioService: pinService || library
readonly property bool radioCandidate: !batch && (currentSong || (!!selection.type && selection.type.endsWith("songs")))
- onOpened: { confirmDelete = false; if (radioCandidate) radioService.prepareRadio(selection, currentSong) }
+ onOpened: { app.focusFirstMenuItem(menu); confirmDelete = false; if (radioCandidate) radioService.prepareRadio(selection, currentSong) }
readonly property bool session: selection.type === "saved-queues"
readonly property bool artist: selection.type === "artists"
readonly property bool station: selection.type === "stations"
diff --git a/qml/Tx6Cable3D.qml b/qml/Tx6Cable3D.qml
new file mode 100644
index 0000000..0897e3a
--- /dev/null
+++ b/qml/Tx6Cable3D.qml
@@ -0,0 +1,117 @@
+import QtQuick
+import QtQuick3D
+import Spun 1.0
+
+Node {
+ id: cable
+
+ // Each connector enters the USB-C socket on the TOP edge, not an audio jack.
+ property vector3d start: Qt.vector3d(-79.1, 157.7, -7.65)
+ property vector3d end: Qt.vector3d(217.25, 149.6, -7.65)
+
+ objectName: "tx6UsbLink"
+
+ PrincipledMaterial {
+ id: metal
+
+ baseColor: "#c7cdd1"
+ metalness: 0.85
+ roughness: 0.36
+ }
+
+ PrincipledMaterial {
+ id: boot
+
+ baseColor: "#d8d8d5"
+ roughness: 0.56
+ }
+
+ PrincipledMaterial {
+ id: rubber
+
+ baseColor: "#131b20"
+ roughness: 0.84
+ normalStrength: 0.2
+
+ normalMap: Texture {
+ generateMipmaps: true
+ mipFilter: Texture.Linear
+
+ textureData: SurfaceTexture {
+ kind: "knurled-normal"
+ }
+
+ }
+
+ }
+
+ Model {
+ objectName: "tx6BraidedCable"
+ materials: rubber
+
+ geometry: CableGeometry {
+ start: cable.start.plus(Qt.vector3d(0, 28, 0))
+ end: cable.end.plus(Qt.vector3d(0, 28, 0))
+ }
+
+ }
+
+ Repeater3D {
+ model: 2
+
+ Node {
+ required property int index
+
+ position: index === 0 ? cable.start : cable.end
+
+ Model {
+ y: 3
+ materials: metal
+
+ geometry: DeckGeometry {
+ dimensions: Qt.vector3d(16, 9, 5.6)
+ radius: 2
+ }
+
+ }
+
+ Model {
+ y: 14
+ materials: boot
+
+ geometry: DeckGeometry {
+ dimensions: Qt.vector3d(19, 18, 8)
+ radius: 3
+ }
+
+ }
+
+ Model {
+ y: 24
+ materials: boot
+
+ geometry: DeckGeometry {
+ dimensions: Qt.vector3d(7, 12, 6)
+ radius: 2
+ }
+
+ }
+
+ Model {
+ y: 15
+ z: 4.05
+ source: "#Rectangle"
+ scale: Qt.vector3d(0.1, 0.02, 1)
+
+ materials: PrincipledMaterial {
+ baseColor: "#98a1a5"
+ roughness: 0.8
+ }
+
+ }
+
+ }
+
+ }
+
+}
diff --git a/qml/Tx6Controls.qml b/qml/Tx6Controls.qml
new file mode 100644
index 0000000..dc23400
--- /dev/null
+++ b/qml/Tx6Controls.qml
@@ -0,0 +1,640 @@
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Dialogs
+import Spun 1.0
+
+Item {
+ id: mixer
+
+ required property var app
+ property int pressedControl: -1
+ property bool armed: false
+ property int selected: 30
+ property real startY: 0
+ property real startValue: 0
+ property real contactX: 0
+ property bool shiftHeld: false
+ property int loadChannel: 1
+ readonly property bool popupOpen: channelMenu.visible || stemFile.visible
+ readonly property var keyItems: {
+ let a = [];
+ for (let i = 0; i < keys.count; i++) a.push(keys.itemAt(i))
+ return a;
+ }
+ readonly property bool operable: tx6.powered && tx6.available && !app.menuOpen && !app.discFlipped
+ readonly property string displayTitle: selected < 18 ? ("CH" + (selected % 6 + 1) + " " + ["HIGH", "MID", "LOW"][Math.floor(selected / 6)]) : selected < 24 ? "CH" + (selected - 17) + " LEVEL" : selected < 30 ? "CH" + (selected - 23) + (tx6.channels[selected - 24].solo ? " SOLO" : " MUTE") : selected === 31 ? "DELAY" : selected === 32 ? "COMP" : "MASTER"
+ readonly property string displayValue: selected < 18 ? Math.round(value(selected)).toString() : selected < 24 || selected === 30 ? Math.round(value(selected) * 100).toString() : selected === 31 ? (tx6.delay ? "ON" : "OFF") : selected === 32 ? (tx6.compressor ? "ON" : "OFF") : selected < 30 ? (tx6.channels[selected - 24].mute ? "OFF" : "ON") : Math.round(app.deckPlayer.volume * 100).toString()
+
+ function position(i) {
+ if (i < 18)
+ return Qt.point(22 + (i % 6) * 29.3, 60 + Math.floor(i / 6) * 44);
+
+ if (i < 24)
+ return Qt.point(22 + (i - 18) * 29.3, 285 - 77 * tx6.channels[i - 18].level);
+
+ if (i < 30)
+ return Qt.point(22 + (i - 24) * 29.3, 324);
+
+ return [Qt.point(210, 148), Qt.point(210, 220), Qt.point(210, 268), Qt.point(210, 324), Qt.point(-6, 283)][i - 30];
+ }
+
+ function value(i) {
+ return i < 18 ? tx6.channels[i % 6][["high", "mid", "low"][Math.floor(i / 6)]] : i < 24 ? tx6.channels[i - 18].level : i === 30 ? app.deckPlayer.volume : 0;
+ }
+
+ function setValue(i, v) {
+ if (i < 18)
+ tx6.setEq(i % 6, Math.floor(i / 6), Math.max(-12, Math.min(12, v)));
+ else if (i < 24)
+ tx6.setLevel(i - 18, Math.max(0, Math.min(1, v)));
+ else if (i === 30)
+ app.deckPlayer.volume = Math.max(0, Math.min(1, v));
+ }
+
+ function caption(i) {
+ if (i === 34)
+ return tx6.powered ? "Power off · bypass mixer" : "Power on";
+
+ if (i===30)return "Master volume · drag or scroll";
+ if (!tx6.available)
+ return "Local audio mixing · switch from Cider to Local";
+
+ if (i < 18)
+ return "Channel " + (i % 6 + 1) + " · " + ["High", "Mid", "Low"][Math.floor(i / 6)] + " EQ · drag or scroll · double-click to reset";
+
+ if (i < 24)
+ return "Channel " + (i - 17) + " · level · " + (tx6.channels[i - 18].name || "No input");
+
+ if (i < 30)
+ return "Channel " + (i - 23) + " · mute · Shift for solo · right-click to load audio";
+
+ return ["Master volume · drag or scroll", "FX I · stereo delay", "FX II · compressor", "Shift · tap, then choose a channel to solo"][i - 30];
+ }
+
+ function canUse(i) {
+ return i === 34 ? !app.menuOpen : i === 30 ? tx6.powered && !app.menuOpen : operable;
+ }
+
+ function begin(i, y, x) {
+ if (!canUse(i))
+ return ;
+
+ const soloArmed = shiftHeld;
+ cancel();
+ shiftHeld = soloArmed;
+ selected = i;
+ pressedControl = i;
+ armed = true;
+ startY = y;
+ startValue = value(i);
+ contactX = Math.max(-1, Math.min(1, x || 0));
+ }
+
+ function move(y, hit, fine) {
+ if (pressedControl < 0)
+ return ;
+
+ const i = pressedControl;
+ if (i < 24 || i === 30)
+ setValue(i, startValue + (startY - y) * (fine ? 0.2 : 1) * (i < 18 ? 0.15 : i < 24 ? 1 / 77 : 0.006));
+ else
+ armed = hit === i;
+ }
+
+ function end(modifiers) {
+ const i = pressedControl;
+ const activate = armed;
+ pressedControl = -1;
+ armed = false;
+ if (i === 33) {
+ if (activate)
+ shiftHeld = !shiftHeld;
+ return ;
+ }
+ if (!activate || i < 24 || i === 30)
+ return ;
+
+ if (i < 30) {
+ if (shiftHeld || (modifiers & Qt.ShiftModifier))
+ tx6.toggleSolo(i - 24);
+ else
+ tx6.toggleMute(i - 24);
+ shiftHeld = false;
+ } else if (i === 31)
+ tx6.delay = !tx6.delay;
+ else if (i === 32)
+ tx6.compressor = !tx6.compressor;
+ else if (i === 34)
+ tx6.powered = !tx6.powered;
+ }
+
+ function cancel() {
+ pressedControl = -1;
+ armed = false;
+ shiftHeld = false;
+ }
+
+ function scroll(i, delta) {
+ if (!canUse(i))
+ return ;
+
+ selected = i;
+ setValue(i, value(i) + (i < 18 ? 0.5 : 0.025) * delta);
+ }
+
+ function resetControl(i) {
+ if (i < 18)
+ setValue(i, 0);
+ else if (i < 24)
+ setValue(i, 1);
+ else if (i === 30)
+ setValue(i, 0.65);
+ }
+
+ function openChannel(i) {
+ loadChannel = i;
+ channelMenu.popup();
+ }
+
+ objectName: "tx6Controls"
+ width: 244
+ height: 400
+ onVisibleChanged: {
+ if (!visible) {
+ cancel();
+ }
+ }
+
+ Connections {
+ function onMenuOpenChanged() {
+ if (app.menuOpen)
+ mixer.cancel();
+
+ }
+
+ function onDiscFlippedChanged() {
+ mixer.cancel();
+ }
+
+ target: app
+ }
+
+ Connections {
+ function onChanged() {
+ if (!tx6.powered || !tx6.available)
+ mixer.cancel();
+
+ }
+
+ target: tx6
+ }
+
+ Rectangle {
+ x: 1
+ y: 5
+ width: 244
+ height: 352
+ radius: 10
+ color: "#32000000"
+ }
+
+ Rectangle {
+ width: 244
+ height: 352
+ radius: 10
+ border.color: "#62666a"
+ border.width: 0.7
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0
+ color: "#e2e3e4"
+ }
+
+ GradientStop {
+ position: 0.2
+ color: "#bfc1c4"
+ }
+
+ GradientStop {
+ position: 0.7
+ color: "#cfd0d1"
+ }
+
+ GradientStop {
+ position: 1
+ color: "#afb1b4"
+ }
+
+ }
+
+ }
+
+ Rectangle {
+ x: 1.5
+ y: 1.5
+ width: 241
+ height: 349
+ radius: 9
+ color: "transparent"
+ border.color: "#ddf5f6f8"
+ border.width: 0.8
+ }
+
+ Tx6Labels {
+ }
+
+ Tx6Display {
+ x: 190
+ y: 51
+ controls: mixer
+ }
+
+ Repeater {
+ model: 6
+
+ Item {
+ required property int index
+
+ x: 22 + index * 29.3
+ y: 201
+
+ Rectangle {
+ x: -5.2
+ width: 10.4
+ height: 89
+ radius: 5
+ color: "#75787a"
+ border.color: "#e5e6e6"
+ border.width: 0.7
+ }
+
+ Rectangle {
+ x: -3
+ y: 2
+ width: 6
+ height: 85
+ radius: 3
+ color: "#161b1e"
+ border.color: "#383d3e"
+ }
+
+ Rectangle {
+ x: -1.7
+ y: 4
+ width: 1
+ height: 81
+ color: "#566065"
+ }
+
+ Rectangle {
+ x: -1
+ y: 110
+ width: 2
+ height: 2
+ radius: 1
+ color: tx6.channels[index].solo ? "#f47822" : tx6.channels[index].mute ? "#a14b32" : "#9caaa5"
+ }
+
+ }
+
+ }
+ // These objects own pressure and rotation in both renderers. 3D picks call
+
+ // the same gesture functions, so a press never competes with orbiting.
+ Repeater {
+ id: keys
+
+ model: 35
+
+ Item {
+ id: key
+
+ required property int index
+ readonly property point center: mixer.position(index)
+ readonly property bool round: index < 24 || (index >= 30 && index <= 32)
+ readonly property bool latched: index >= 24 && index < 30 ? tx6.channels[index - 24].mute : index === 31 ? tx6.delay : index === 32 ? tx6.compressor : index === 33 ? mixer.shiftHeld : false
+ readonly property real pressure: Math.max(-0.025, Math.min(1.03, press.value))
+ readonly property real turn: mixer.value(index) * (index < 18 ? 11 : 270) - (index === 30 ? 135 : 0)
+ property real rotationValue: turn
+
+ objectName: "tx6Control" + index
+ width: index < 18 ? 15 : index < 24 ? 10 : index < 30 ? 13 : index === 30 ? 50 : index === 33 ? 42 : index === 34 ? 10 : 42
+ height: index < 18 ? 15 : index < 24 ? 10 : index < 30 ? 26 : index === 33 ? 22 : index === 34 ? 35 : width
+ x: center.x - width / 2
+ y: center.y - height / 2
+ activeFocusOnTab: mixer.canUse(index)
+ Accessible.role: key.index < 24 || key.index === 30 ? Accessible.Slider : Accessible.Button
+ Accessible.name: mixer.caption(index)
+ Keys.onPressed: (event) => {
+ if (event.isAutoRepeat)
+ return ;
+
+ if (event.key === Qt.Key_Return || event.key === Qt.Key_Space) {
+ mixer.begin(index, 0, 0);
+ event.accepted = true;
+ } else if (event.key === Qt.Key_Up || event.key === Qt.Key_Down) {
+ mixer.scroll(index, event.key === Qt.Key_Up ? 1 : -1);
+ event.accepted = true;
+ }
+ }
+ Keys.onReleased: (event) => {
+ if (event.key === Qt.Key_Return || event.key === Qt.Key_Space) {
+ mixer.end(event.modifiers);
+ event.accepted = true;
+ }
+ }
+
+ SpunSpring {
+ id: press
+
+ targetValue: mixer.pressedControl === key.index && mixer.armed ? 1 : key.latched ? 0.16 : 0
+ epsilon: 0.002
+ animation.spring: 5.5
+ animation.damping: 0.42
+ animation.mass: 0.8
+ }
+
+ Rectangle {
+ visible: key.index===30
+ anchors.centerIn: parent
+ width: 50; height: 50; radius:25
+ color:"#b5b9ba";border.width:.7;border.color:"#73797a"
+ Rectangle {anchors.fill:parent;anchors.margins:1;color:"transparent";radius:24;border.color:"#e1e4e5";border.width:.7}
+ }
+ Rectangle {
+ x: (key.index===30?12:1) + key.pressure
+ y: (key.index===30?13.5:2.5) - key.pressure * 1.5
+ width: key.index===30?28:parent.width
+ height: key.index===30?28:parent.height
+ radius: key.round ? width / 2 : 2
+ color: "#54000000"
+ }
+
+ Rectangle {
+ x: (key.index===30?11:0) + key.pressure * 0.25
+ y: (key.index===30?11:0) + key.pressure * 1.4
+ width: key.index===30?28:parent.width
+ height: key.index===30?28:parent.height
+ radius: key.round ? width / 2 : 2
+ border.width: 0.65
+ border.color: "#717778"
+
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 1
+ radius: parent.radius
+ color: "transparent"
+ border.width: 0.6
+ border.color: "#c9ffffff"
+ }
+
+ Item {
+ anchors.centerIn: parent
+ width: parent.width
+ height: parent.height
+ rotation: key.rotationValue
+ visible: key.index < 18 || key.index === 30
+
+ Rectangle {
+ visible: key.index<18
+ anchors.centerIn: parent
+ width: 6; height: 6; radius: 3
+ color: key.index<6?"#20242b":key.index<12?"#f67628":"#f6f4ee"
+ }
+ Rectangle {
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: 1.2
+ width: key.index === 30 ? 1.5 : 2
+ height: key.index === 30 ? 6 : 6.5
+ radius: 0.8
+ color: key.index < 6 ? "#171d24" : key.index < 12 ? "#f67628" : key.index < 18 ? "#f7f5ef" : "#61696f"
+ }
+
+ }
+
+ Rectangle {
+ visible: key.index === 31 || key.index === 32
+ anchors.centerIn: parent
+ width: 28
+ height: 12
+ radius: 1.8
+ color: key.index === 32 ? "#f76a20" : "#24272d"
+
+ Text {
+ anchors.centerIn: parent
+ text: key.index === 31 ? "I" : "II"
+ color: "#e8e4dd"
+ font.pixelSize: 12
+ }
+
+ }
+
+ Rectangle {
+ visible: key.index === 33
+ anchors.centerIn: parent
+ width: 5
+ height: 5
+ radius: 2.5
+ color: mixer.shiftHeld ? "#f67628" : "#f3f1ed"
+ }
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0
+ color: "#f4f5f5"
+ }
+
+ GradientStop {
+ position: 0.3
+ color: "#d7d8d9"
+ }
+
+ GradientStop {
+ position: 1
+ color: "#a3a7aa"
+ }
+
+ }
+
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: -2
+ radius: parent.width / 2
+ color: "transparent"
+ border.width: key.activeFocus ? 1 : 0
+ border.color: mixer.app.accent
+ }
+
+ MouseArea {
+ id: pointer
+
+ anchors.fill: parent
+ anchors.margins: key.index < 24 ? -4 : 0
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ hoverEnabled: true
+ preventStealing: true
+ cursorShape: mixer.canUse(key.index) ? Qt.PointingHandCursor : Qt.ArrowCursor
+ onPressed: (mouse) => {
+ if (mouse.button === Qt.RightButton) {
+ if (key.index >= 24 && key.index < 30)
+ mixer.openChannel(key.index - 24);
+
+ return ;
+ }
+ key.forceActiveFocus();
+ const p = mapToItem(mixer, mouse.x, mouse.y);
+ mixer.begin(key.index, p.y, (mouse.x - width / 2) / (width / 2));
+ }
+ onPositionChanged: (mouse) => {
+ if (!pressed)
+ return ;
+
+ const p = mapToItem(mixer, mouse.x, mouse.y);
+ mixer.move(p.y, containsMouse ? key.index : -1, mouse.modifiers & Qt.ShiftModifier);
+ }
+ onReleased: (mouse) => {
+ return mixer.end(mouse.modifiers);
+ }
+ onCanceled: mixer.cancel()
+ onWheel: (wheel) => {
+ mixer.scroll(key.index, wheel.angleDelta.y / 120);
+ wheel.accepted = true;
+ }
+ onDoubleClicked: (mouse) => {
+ if (mouse.button === Qt.LeftButton)
+ mixer.resetControl(key.index);
+
+ }
+ }
+
+ SpunToolTip {
+ visible: pointer.containsMouse && !pointer.pressed
+ text: mixer.caption(key.index)
+ }
+
+ Behavior on rotationValue {
+ enabled: mixer.app.animate && mixer.pressedControl !== key.index
+
+ NumberAnimation {
+ duration: 90
+ easing.type: Easing.OutCubic
+ }
+
+ }
+
+ }
+
+ }
+
+ Rectangle {
+ x: 191
+ y: 352
+ width: 37
+ height: 8
+ color: "#92989b"
+ border.color: "#e1e4e5"
+ }
+
+ Rectangle {
+ x: 190
+ y: 359
+ width: 39
+ height: 40
+ radius: 3
+
+ Repeater {
+ model: 16
+
+ Rectangle {
+ required property int index
+
+ x: 1 + index * 2.4
+ y: 2
+ width: 0.7
+ height: 36
+ color: "#6b727a"
+ opacity: 0.5
+ }
+
+ }
+
+ gradient: Gradient {
+ orientation: Gradient.Horizontal
+
+ GradientStop {
+ position: 0
+ color: "#989fa2"
+ }
+
+ GradientStop {
+ position: 0.3
+ color: "#eaeeee"
+ }
+
+ GradientStop {
+ position: 1
+ color: "#8a9298"
+ }
+
+ }
+
+ }
+
+ Repeater {
+ model:2
+ Rectangle {
+ required property int index
+ x:61+index*29;y:352;width:10;height:4;radius:2
+ color:"#b8c0c3";border.color:"#737b80";border.width:.6
+ }
+ }
+ Menu {
+ id: channelMenu
+ objectName: "tx6ChannelMenu"
+ popupType: Popup.Item
+
+ MenuItem {
+ text: mixer.loadChannel === 0 ? "TP-7 playback · USB channels 1/2" : tx6.channels[mixer.loadChannel].name || "Empty input"
+ enabled: false
+ }
+
+ MenuItem {
+ text: "Load local audio…"
+ enabled: mixer.loadChannel > 0
+ onTriggered: stemFile.open()
+ }
+
+ MenuItem {
+ text: "Remove audio"
+ enabled: mixer.loadChannel > 0 && tx6.channels[mixer.loadChannel].loaded
+ onTriggered: tx6.unload(mixer.loadChannel)
+ }
+
+ MenuItem {
+ objectName: "tx6SoloAction"
+ text: "Solo"
+ checkable: true
+ checked: tx6.channels[mixer.loadChannel].solo
+ onTriggered: tx6.toggleSolo(mixer.loadChannel)
+ }
+
+ MenuItem {
+ text: "Reset mixer"
+ onTriggered: tx6.reset()
+ }
+
+ }
+
+ FileDialog {
+ id: stemFile
+
+ title: "Load channel " + (mixer.loadChannel + 1) + " audio"
+ fileMode: FileDialog.OpenFile
+ nameFilters: ["Audio (*.wav *.flac *.mp3 *.m4a *.ogg *.opus *.aiff)"]
+ onAccepted: tx6.load(mixer.loadChannel, selectedFile)
+ }
+
+}
diff --git a/qml/Tx6Display.qml b/qml/Tx6Display.qml
new file mode 100644
index 0000000..62c4941
--- /dev/null
+++ b/qml/Tx6Display.qml
@@ -0,0 +1,68 @@
+import QtQuick
+
+Item {
+ id: screen
+
+ property var controls
+
+ width: 40
+ height: 55
+
+ Rectangle {
+ anchors.fill: parent
+ color: tx6.powered ? "#c4d9de" : "#344146"
+ radius: 4
+ border.color: "#717b80"
+ border.width: 0.8
+ }
+
+ Item {
+ anchors.fill: parent
+ visible: tx6.powered
+
+ Text {
+ x: 3
+ y: 3
+ text: tx6.available ? "USB L R" : "LOCAL"
+ font.family: "monospace"
+ font.pixelSize: 6
+ color: "#182d36"
+ }
+
+ Text {
+ x: 3
+ y: 16
+ text: screen.controls ? screen.controls.displayTitle : "MASTER"
+ font.family: "monospace"
+ font.pixelSize: 6
+ color: "#182d36"
+ }
+
+ Text {
+ x: 3
+ y: 29
+ text: screen.controls ? screen.controls.displayValue : "65"
+ font.family: "monospace"
+ font.pixelSize: 18
+ color: "#172b34"
+ }
+
+ Repeater {
+ model: 2
+ Item {
+ required property int index
+ property int side: index
+ x: 31+index*4
+ Repeater {
+ model: 12
+ Rectangle {
+ required property int index
+ y: 47-index*2.8; width: 2.5; height: 1.7
+ color: "#243b43"
+ opacity: tx6.stereoMeters[parent.side]>Math.pow(10,(-48+index*4)/20)?1:.15
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/qml/Tx6Labels.qml b/qml/Tx6Labels.qml
new file mode 100644
index 0000000..a490d14
--- /dev/null
+++ b/qml/Tx6Labels.qml
@@ -0,0 +1,71 @@
+import QtQuick
+
+Item {
+ width: 244
+ height: 352
+
+ Text {
+ x: 14
+ y: 14
+ text: "TX–6"
+ font.pixelSize: 17
+ font.weight: Font.Light
+ color: "#3e4349"
+ }
+
+ Text {
+ x: 205
+ y: 185
+ text: "FX"
+ font.pixelSize: 10
+ font.weight: Font.Light
+ color: "#45484d"
+ }
+
+ Text {
+ x: 198
+ y: 299
+ text: "shift"
+ font.pixelSize: 10
+ font.weight: Font.Light
+ color: "#45484d"
+ }
+
+ Repeater {
+ model: 6
+
+ Item {
+ required property int index
+
+ x: 22 + index * 29.3
+
+ Repeater {
+ model: 5
+
+ Rectangle {
+ required property int index
+
+ x: -0.9
+ y: 166 + index * 6
+ width: 1.8
+ height: 2.3
+ radius: 1
+ color: "#939695"
+ }
+
+ }
+
+ Rectangle {
+ x: -0.9
+ y: 298
+ width: 1.8
+ height: 1.8
+ radius: 1
+ color: "#939695"
+ }
+
+ }
+
+ }
+
+}
diff --git a/qml/Tx6_3D.qml b/qml/Tx6_3D.qml
new file mode 100644
index 0000000..06ac22b
--- /dev/null
+++ b/qml/Tx6_3D.qml
@@ -0,0 +1,575 @@
+import QtQuick
+import QtQuick3D
+import Spun 1.0
+
+Node {
+ id: mixer
+
+ required property var app
+ readonly property var controls: app.tx6Controls
+
+ function surface(x, y, z) {
+ return Qt.vector3d(x - 122, 176 - y, z);
+ }
+
+ function controlPoint(i) {
+ const p = controls.position(i);
+ return mapPositionToScene(surface(p.x, p.y, i < 18 ? 25 : i === 30 ? 29 : i === 34 ? -8 : 17));
+ }
+
+ objectName: "tx6Model"
+
+ Texture {
+ id: grain
+
+ generateMipmaps: true
+ mipFilter: Texture.Linear
+ scaleU: 2
+ scaleV: 2
+
+ textureData: SurfaceTexture {
+ kind: "bead-normal"
+ }
+
+ }
+
+ Texture {
+ id: knurl
+
+ generateMipmaps: true
+ mipFilter: Texture.Linear
+ scaleU: 1.5
+ scaleV: 1
+
+ textureData: SurfaceTexture {
+ kind: "knurled-normal"
+ }
+
+ }
+
+ Texture { id: satin; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "satin" } }
+ Texture { id: leather; generateMipmaps: true; mipFilter: Texture.Linear; scaleU: 3; scaleV: 4; textureData: SurfaceTexture { kind: "leather-normal" } }
+
+ PrincipledMaterial {
+ id: aluminum
+
+ baseColor: "#c7cbcf"
+ metalness: 0.84
+ roughness: 0.39
+ roughnessMap: satin
+ normalMap: grain
+ normalStrength: 0.12
+ }
+
+ PrincipledMaterial {
+ id: edge
+
+ baseColor: "#d4d9db"
+ metalness: 0.96
+ roughness: 0.24
+ }
+
+ PrincipledMaterial {
+ id: cap
+
+ baseColor: "#d1d4d5"
+ metalness: 0.84
+ roughness: 0.34
+ roughnessMap: satin
+ normalMap: grain
+ normalStrength: 0.13
+ }
+
+ PrincipledMaterial {
+ id: knurled
+
+ baseColor: "#c3cace"
+ metalness: 0.9
+ roughness: 0.4
+ normalMap: knurl
+ normalStrength: 0.28
+ }
+
+ PrincipledMaterial {
+ id: black
+
+ baseColor: "#182128"
+ roughness: 0.69
+ }
+
+ PrincipledMaterial {
+ id: slot
+
+ baseColor: "#0c1014"
+ roughness: 0.91
+ }
+
+ PrincipledMaterial {
+ id: orange
+
+ baseColor: "#f27226"
+ roughness: 0.55
+ }
+
+ PrincipledMaterial {
+ id: white
+
+ baseColor: "#eeeae3"
+ roughness: 0.5
+ }
+
+ Plate {
+ z: -5
+ size: Qt.vector3d(244, 352, 36)
+ rounding: 9
+ }
+
+ Plate {
+ z: 13.1
+ size: Qt.vector3d(241.8, 349.8, 0.8)
+ rounding: 8
+ finish: edge
+ }
+
+ Plate {
+ z: 13.5
+ size: Qt.vector3d(240.4, 348.4, 0.8)
+ rounding: 7.6
+ }
+
+ Plate {
+ z: -23.8
+ size: Qt.vector3d(240, 348, 1.4)
+ rounding: 8
+ finish: edge
+ }
+
+ Plate {
+ x: 10
+ z: -24.8
+ size: Qt.vector3d(218, 339, 1.5)
+ rounding: 5
+
+ finish: PrincipledMaterial {
+ baseColor: "#14212d"
+ roughness: 0.78
+ normalMap: leather
+ normalStrength: 0.55
+ }
+
+ }
+
+ Repeater3D {
+ model: 2
+
+ Node {
+ required property int index
+
+ position: mixer.surface(14, index === 0 ? 44 : 304, -25)
+ eulerRotation.y: 180
+
+ Ring {
+ radius: 3.4
+ depth: 0.8
+ }
+
+ Ring {
+ radius: 1.5
+ depth: 1
+ z: 0.3
+ finish: black
+ }
+
+ }
+
+ }
+
+ Model {
+ position: mixer.surface(122, 176, 14.02)
+ source: "#Rectangle"
+ scale: Qt.vector3d(2.44, 3.52, 1)
+
+ materials: PrincipledMaterial {
+ lighting: PrincipledMaterial.NoLighting
+ alphaMode: PrincipledMaterial.Blend
+ roughness: 0.8
+
+ baseColorMap: Texture {
+ generateMipmaps: true
+ mipFilter: Texture.Linear
+
+ sourceItem: Tx6Labels {
+ }
+
+ }
+
+ }
+
+ }
+
+ Plate {
+ position: mixer.surface(210, 78, 14.1)
+ size: Qt.vector3d(42, 57, 1)
+ rounding: 4
+ finish: edge
+ }
+
+ Model {
+ position: mixer.surface(210, 78, 14.7)
+ source: "#Rectangle"
+ scale: Qt.vector3d(0.4, 0.55, 1)
+
+ materials: PrincipledMaterial {
+ lighting: PrincipledMaterial.NoLighting
+ roughness: 0.55
+
+ baseColorMap: Texture {
+
+ sourceItem: Tx6Display {
+ controls: mixer.controls
+ }
+
+ }
+
+ }
+
+ }
+
+ Repeater3D {
+ model: 6
+
+ Node {
+ required property int index
+
+ x: 22 + index * 29.3 - 122
+
+ Plate {
+ y: 176 - 245
+ z: 14.1
+ size: Qt.vector3d(10.2, 89, 0.5)
+ rounding: 5
+ finish: edge
+ }
+
+ Plate {
+ y: 176 - 245
+ z: 14.4
+ size: Qt.vector3d(7, 86, 0.4)
+ rounding: 3.4
+ finish: slot
+ }
+
+ Plate {
+ x: -1.8
+ y: 176 - 245
+ z: 14.7
+ size: Qt.vector3d(0.7, 81, 0.3)
+ rounding: 0.3
+ finish: aluminum
+ }
+
+ Ring {
+ y: 176 - 309
+ z: 14
+ radius: 1
+ depth: 0.2
+ finish: tx6.channels[index].solo ? orange : black
+ }
+
+ }
+
+ }
+
+ Ring {
+ position: mixer.surface(210, 148, 14.3)
+ radius: 24
+ depth: 0.65
+ finish: black
+ }
+
+ Ring {
+ position: mixer.surface(210, 148, 14.7)
+ radius: 23.6
+ depth: 0.6
+ }
+
+ Repeater3D {
+ model: 35
+
+ Node {
+ id: part
+
+ required property int index
+ readonly property var key: mixer.controls ? mixer.controls.keyItems[index] : null
+ readonly property point point: mixer.controls ? mixer.controls.position(index) : Qt.point(0, 0)
+ readonly property real pressure: key ? key.pressure : 0
+
+ position: mixer.surface(point.x - (index === 34 ? pressure * 1.2 : 0), point.y, index === 34 ? -7 : 14)
+ eulerRotation.z: index < 18 || index === 30 ? -(key ? key.rotationValue : 0) : 0
+
+ Node {
+ z: part.index === 34 ? 0 : -part.pressure * 1.25
+ eulerRotation.y: part.index >= 24 && part.index < 34 ? (mixer.controls ? mixer.controls.contactX : 0) * part.pressure * 1.1 : 0
+
+ // Each index has a fixed physical type. Instantiate only its
+ // meshes; hidden alternative types used to allocate full geometry
+ // for every control. The shared pressure transform stays above.
+ Loader3D {
+ active: part.index < 18 || part.index === 30
+ sourceComponent: Node {
+ Ring {
+ tx6Control: part.index
+ radius: part.index === 30 ? 11 : 4
+ depth: 6; z: 3; finish: edge
+ }
+ Ring {
+ tx6Control: part.index
+ radius: part.index === 30 ? 13.5 : 6.7
+ depth: part.index === 30 ? 9 : 5
+ z: part.index === 30 ? 10 : 8
+ finish: knurled
+ }
+ Ring {
+ tx6Control: part.index
+ radius: part.index === 30 ? 13.3 : 6.55
+ depth: 1.2
+ z: part.index === 30 ? 14.7 : 10.6
+ finish: cap
+ }
+ Ring {
+ visible: part.index < 18
+ tx6Control: part.index
+ radius: 2.8; depth: .18; z: 11.3
+ finish: part.index < 6 ? black : part.index < 12 ? orange : white
+ }
+ Plate {
+ tx6Control: part.index
+ y: part.index === 30 ? 9 : 3.6
+ z: part.index === 30 ? 15.4 : 11.3
+ size: Qt.vector3d(part.index === 30 ? 1.3 : 1.8, part.index === 30 ? 5 : 6, .24)
+ rounding: .5
+ finish: part.index < 6 ? black : part.index < 12 ? orange : part.index < 18 ? white : black
+ }
+ }
+ }
+ Loader3D {
+ active: part.index >= 18 && part.index < 24
+ sourceComponent: Ring {
+ tx6Control: part.index
+ radius: 4.8; depth: 1.2; z: 3; finish: cap
+ }
+ }
+ Loader3D {
+ active: part.index >= 24 && part.index < 30 || part.index === 33
+ sourceComponent: Node {
+ Plate {
+ tx6Control: part.index
+ z: 1.8
+ size: Qt.vector3d(part.index === 33 ? 39 : 10, part.index === 33 ? 20 : 23, 3.5)
+ rounding: 2; finish: cap
+ }
+ Ring {
+ visible: part.index === 33
+ tx6Control: part.index
+ radius: 2.5; z: 3.7; depth: .15
+ finish: mixer.controls && mixer.controls.shiftHeld ? orange : white
+ }
+ }
+ }
+ Loader3D {
+ active: part.index === 31 || part.index === 32
+ sourceComponent: Node {
+ Ring {
+ tx6Control: part.index
+ radius: 20; depth: 3.4; z: 2.4; finish: cap
+ }
+ Plate {
+ tx6Control: part.index
+ z: 4.25; size: Qt.vector3d(28, 12, .24); rounding: 1.5
+ finish: part.index === 32 ? orange : black
+ }
+ Plate {
+ tx6Control: part.index
+ x: part.index === 32 ? -2 : 0
+ z: 4.5; size: Qt.vector3d(.8, 8, .1); rounding: .2; finish: white
+ }
+ Plate {
+ visible: part.index === 32
+ tx6Control: part.index
+ x: 2; z: 4.5; size: Qt.vector3d(.8, 8, .1); rounding: .2; finish: white
+ }
+ }
+ }
+ Loader3D {
+ active: part.index === 34
+ sourceComponent: Plate {
+ tx6Control: part.index
+ size: Qt.vector3d(8, 35, 14); rounding: 3; finish: cap
+ }
+ }
+
+ }
+
+ }
+
+ }
+ // Numbered TRS inputs and USB-C occupy the real upper sidewall.
+
+ Repeater3D {
+ model: 6
+
+ Node {
+ required property int index
+
+ position: mixer.surface(22 + index * 29.3, 0, -9)
+ eulerRotation.x: -90
+
+ Ring {
+ radius: 4.4
+ hole: 3.5
+ depth: 0.5
+ }
+
+ Ring {
+ radius: 3.5
+ depth: 0.45
+ z: -0.2
+ finish: slot
+ }
+
+ }
+
+ }
+
+ Plate {
+ position: mixer.surface(207, 0, -9)
+ eulerRotation.x: -90
+ size: Qt.vector3d(27, 8, 0.5)
+ rounding: 3.8
+ finish: black
+ }
+
+ Plate {
+ position: mixer.surface(207, -0.3, -9)
+ eulerRotation.x: -90
+ size: Qt.vector3d(18, 1.1, 0.5)
+ rounding: 0.5
+ finish: aluminum
+ }
+
+ Repeater3D {
+ model: 2
+
+ Node {
+ required property int index
+
+ position: mixer.surface(140 + index * 29, 352, -9)
+ eulerRotation.x: 90
+
+ Ring {
+ radius: 5
+ hole: 3.8
+ depth: 0.8
+ }
+
+ Ring {
+ radius: 3.8
+ depth: 0.5
+ finish: slot
+ }
+
+ }
+
+ }
+
+ Node {
+ position: mixer.surface(210, 356, -9)
+ eulerRotation.x: 90
+
+ Ring {
+ radius: 17
+ hole: 4.5
+ depth: 8
+ }
+
+ Ring {
+ z: 20
+ radius: 19
+ hole: 4.5
+ depth: 34
+ finish: knurled
+ }
+
+ Ring {
+ z: 37.2
+ radius: 18.2
+ hole: 4.5
+ depth: 1.2
+ }
+
+ }
+
+ component Plate: Model {
+ id: plate
+
+ property vector3d size: Qt.vector3d(244, 352, 36)
+ property real rounding: 7
+ property var finish: aluminum
+ property int tx6Control: -1
+
+ pickable: true
+ materials: finish
+
+ geometry: DeckGeometry {
+ dimensions: plate.size
+ radius: plate.rounding
+ }
+
+ }
+
+ component Ring: Model {
+ id: ring
+
+ property real radius: 8
+ property real hole: 0.001
+ property real depth: 3
+ property var finish: edge
+ property int tx6Control: -1
+
+ pickable: true
+ materials: finish
+
+ geometry: RecordGeometry {
+ radius: ring.radius
+ hole: ring.hole
+ depth: ring.depth
+ }
+
+ }
+
+ Repeater3D {
+ model: 2
+ Node {
+ required property int index
+ position:mixer.surface(66+index*29,353,-9)
+ eulerRotation.x:90
+ Ring {radius:7;depth:1.6;finish:cap;property string tx6Info:"Aux and cue outputs are not connected in the software mixer"}
+ }
+ }
+ Model {
+ position:mixer.surface(122,352.3,-9);eulerRotation.x:90
+ source:"#Rectangle";scale:Qt.vector3d(2.44,.32,1)
+ materials:PrincipledMaterial {
+ lighting:PrincipledMaterial.NoLighting;alphaMode:PrincipledMaterial.Blend
+ baseColorMap:Texture {
+ sourceItem:Item {
+ width:244;height:32
+ Text {x:58;y:1;text:"aux";font.pixelSize:8;color:"#424a4d"}
+ Text {x:87;y:1;text:"cue";font.pixelSize:8;color:"#424a4d"}
+ Text {x:131;y:1;text:"AUX CUE";font.pixelSize:6;color:"#424a4d"}
+ }
+ }
+ }
+ }
+
+}
diff --git a/qml/Vinyl3D.qml b/qml/Vinyl3D.qml
index c28238c..8e6b2e3 100644
--- a/qml/Vinyl3D.qml
+++ b/qml/Vinyl3D.qml
@@ -42,16 +42,16 @@ Node {
Texture { id: powder; generateMipmaps: true; mipFilter: Texture.Linear; scaleU: 4; scaleV: 4; textureData: SurfaceTexture { kind: "powder" } }
Texture { id: fineMetal; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "metal-normal" } }
Texture { id: paperGrain; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "paper" } }
- PrincipledMaterial { id: enclosure; baseColor: "#222529"; roughness: .58; metalness: .03; roughnessMap: powder; normalMap: grain; normalStrength: .18 }
- PrincipledMaterial { id: topFinish; baseColor: "#24272a"; roughness: .54; roughnessMap: powder; normalMap: grain; normalStrength: .24 }
+ PrincipledMaterial { id: enclosure; baseColor: "#202328"; roughness: .64; metalness: .03; roughnessMap: powder; normalMap: grain; normalStrength: .14 }
+ PrincipledMaterial { id: topFinish; baseColor: "#25292d"; roughness: .49; roughnessMap: powder; normalMap: grain; normalStrength: .17 }
PrincipledMaterial { id: rubber; baseColor: "#121519"; roughness: .92; roughnessMap: molded }
PrincipledMaterial { id: armFinish; baseColor: "#33393e"; metalness: .85; roughness: .3; roughnessMap: brushed; normalMap: fineMetal; normalStrength: .18 }
PrincipledMaterial { id: steel; baseColor: "#bac3ca"; metalness: 1; roughness: .23; roughnessMap: brushed; normalMap: fineMetal; normalStrength: .16 }
PrincipledMaterial { id: accentMetal; baseColor: Qt.tint("#be965c",Qt.alpha(app.accent,.5)); metalness: .88; roughness: .3; roughnessMap: brushed; normalMap: fineMetal; normalStrength: .22 }
- PrincipledMaterial { id: discFinish; baseColor: "#11151a"; metalness: 0; roughness: .3; roughnessMap: lacquer; normalMap: microGrooves; normalStrength: .24; clearcoatAmount: .3; clearcoatRoughnessAmount: .26 }
+ PrincipledMaterial { id: discFinish; baseColor: "#101317"; metalness: 0; roughness: .23; roughnessMap: lacquer; normalMap: microGrooves; normalStrength: .18; clearcoatAmount: .4; clearcoatRoughnessAmount: .2 }
PrincipledMaterial { id: runoutFinish; baseColor: "#13171b"; roughness: .28; clearcoatAmount: .2 }
PrincipledMaterial { id: paper; baseColorMap: deck.artworkTexture; roughness: .92; roughnessMap: paperGrain }
- PrincipledMaterial { id: glass; baseColor: Qt.tint("#afbfc4",Qt.alpha(app.accent,.09)); alphaMode: PrincipledMaterial.Blend; opacity: .08; roughness: .22; clearcoatAmount: .08; cullMode: Material.BackFaceCulling; depthDrawMode: Material.NeverDepthDraw }
+ PrincipledMaterial { id: glass; baseColor: Qt.tint("#afbfc4",Qt.alpha(app.accent,.09)); alphaMode: PrincipledMaterial.Blend; opacity: .065; roughness: .16; clearcoatAmount: .2; clearcoatRoughnessAmount: .18; cullMode: Material.BackFaceCulling; depthDrawMode: Material.NeverDepthDraw }
PrincipledMaterial { id: glassEdge; baseColor: "#9eacb0"; alphaMode: PrincipledMaterial.Blend; opacity: .3; roughness: .18; depthDrawMode: Material.NeverDepthDraw }
component Plate: Model {
id: plate
diff --git a/scripts/benchmark.py b/scripts/benchmark.py
index b9529bb..3c4f05b 100755
--- a/scripts/benchmark.py
+++ b/scripts/benchmark.py
@@ -19,13 +19,16 @@ parser.add_argument('--runs', type=int, default=3)
parser.add_argument('--startup-only', action='store_true', help='Exit after the first frame and report startup stages')
parser.add_argument('--renderer', choices=('opengl', 'software'), default='opengl')
parser.add_argument('--scale', type=float, default=1, help='Identical device scale for both builds')
-parser.add_argument('--media', nargs='+', choices=('cd', 'vinyl', 'cassette'), default=['cd'])
+parser.add_argument('--three-d', action='store_true', help='Measure the native 3D assets')
+parser.add_argument('--media', nargs='+', choices=('cd', 'vinyl', 'cassette', 'tp7', 'tx6'), default=['cd'])
parser.add_argument('--scenes', nargs='+', choices=('idle', 'playing', 'mini', 'cycle'), default=['idle', 'playing', 'mini'])
args = parser.parse_args()
if args.runs < 1:
parser.error('--runs must be positive')
if args.scale <= 0:
parser.error('--scale must be positive')
+if args.three_d and args.renderer == 'software':
+ parser.error('3D requires the OpenGL renderer; software OpenGL is supported via LIBGL_ALWAYS_SOFTWARE')
args.output.mkdir(parents=True, exist_ok=True)
versions = [('optimized', args.binary.resolve())]
if args.baseline:
@@ -46,7 +49,10 @@ for trial in range(args.runs):
gpu_mib = None
gpu_sampled = False
with log_path.open('w') as log:
- process = subprocess.Popen([str(binary), '--benchmark', scene, '--benchmark-medium', medium], env=env, stdout=log, stderr=log)
+ command = [str(binary), '--benchmark', scene, '--benchmark-medium', medium]
+ if args.three_d:
+ command.append('--benchmark-3d')
+ process = subprocess.Popen(command, env=env, stdout=log, stderr=log)
start, previous = time.monotonic(), None
try:
while process.poll() is None:
@@ -56,9 +62,8 @@ for trial in range(args.runs):
try:
stat = Path(f'/proc/{process.pid}/stat').read_text().rsplit(')', 1)[1].split()
ticks = int(stat[11]) + int(stat[12])
- # Same settled three-second window, excluding initialization and teardown.
- if previous and 4.5 <= now - start <= 7.5:
- samples.append((ticks - previous[1]) / os.sysconf('SC_CLK_TCK') / (now - previous[0]) * 100)
+ if previous:
+ samples.append((now-start, (ticks - previous[1]) / os.sysconf('SC_CLK_TCK') / (now - previous[0]) * 100))
previous = now, ticks
except FileNotFoundError:
pass
@@ -88,21 +93,28 @@ for trial in range(args.runs):
if measurement is None:
raise RuntimeError(f'{version} {scene}: window closed before measurement; see {log_path}')
row = json.loads(measurement)
+ if args.three_d and scene not in ('mini', 'startup') and not row.get('threeDActive'):
+ raise RuntimeError(f'{version} {medium} {scene}: requested 3D scene was not active')
if args.startup_only:
- row.update(version=version, trial=trial, medium=medium, renderer=args.renderer, scale=args.scale,
+ row.update(version=version, trial=trial, medium=medium, renderer=args.renderer, scale=args.scale, threeD=args.three_d,
binaryBytes=binary.stat().st_size)
results.append(row)
(args.output / 'results.json').write_text(json.dumps(results, indent=2) + '\n')
print(json.dumps(row), flush=True)
continue
memory = row.pop('memory')
+ # Align the three-second CPU window with the app's settled first frame.
+ # Older baseline binaries used a fixed two-second startup delay.
+ measurement_start = row.get('measurementStartMs', 2000) / 1000
+ samples = [cpu for timestamp, cpu in samples
+ if measurement_start + 1.5 <= timestamp <= measurement_start + 4.5]
for key in ('Rss', 'Pss', 'Private_Dirty'):
row[key + 'KiB'] = int(next(line.split()[1] for line in memory.splitlines() if line.startswith(key + ':')))
row.update(version=version, trial=trial, maxCpu250ms=max(samples, default=0),
meanCpu250ms=sum(samples)/len(samples) if samples else 0,
validAnimation=scene in ('idle', 'cycle') or row['frames'] >= 300,
gpuMemoryMiB=gpu_mib,
- renderer=args.renderer, scale=args.scale,
+ renderer=args.renderer, scale=args.scale, threeD=args.three_d,
binaryBytes=binary.stat().st_size)
results.append(row)
(args.output / 'results.json').write_text(json.dumps(results, indent=2) + '\n')
diff --git a/scripts/test-3d.sh b/scripts/test-3d.sh
index c80d95f..edeaeec 100755
--- a/scripts/test-3d.sh
+++ b/scripts/test-3d.sh
@@ -14,14 +14,14 @@ if [[ $renderer == cpu ]]; then
export QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=rhi QSG_RHI_BACKEND=opengl QSG_RENDER_LOOP=basic
export LIBGL_ALWAYS_SOFTWARE=1 __GLX_VENDOR_LIBRARY_NAME=mesa LP_NUM_THREADS=2
export QT_QPA_PLATFORMTHEME=
- suites=(turntable recorder artwork 3d-lighting media-ui)
+ suites=(cd-deck cassette-deck turntable recorder tx6 artwork 3d-lighting media-ui)
echo 'Running focused offscreen CPU checks. Native lifecycle tests require SPUN_TEST_RENDERER=native.'
elif [[ $renderer == native ]]; then
if [[ ${QT_QUICK_BACKEND:-} == software || ${QT_QPA_PLATFORM:-wayland} == offscreen || ( -z ${WAYLAND_DISPLAY:-} && -z ${DISPLAY:-} ) ]]; then
echo 'Native lifecycle tests require a separate Wayland or X11 test session.' >&2
exit 2
fi
- suites=(turntable recorder artwork 3d-lighting 3d-ui 3d-library media-ui)
+ suites=(cd-deck cassette-deck turntable recorder tx6 artwork 3d-lighting 3d-ui 3d-library media-ui)
else
echo 'SPUN_TEST_RENDERER must be cpu or native.' >&2
exit 2
diff --git a/src/artworktest.cpp b/src/artworktest.cpp
index 63b25bc..0423b42 100644
--- a/src/artworktest.cpp
+++ b/src/artworktest.cpp
@@ -1,3 +1,4 @@
+#include "testcapture.h"
#include "artworktest.h"
#include "player.h"
#include "cider.h"
@@ -67,7 +68,10 @@ int exerciseArtwork(Player &player,QQuickWindow *window,const QString &temp,cons
const auto colorIs=[](const QImage &image,QColor c){return !image.isNull()&&image.pixelColor(0,0)==c;};
const auto publish=[&](const QString &id,const QString &file,const QString &album="Remote album") {remote.track(id,file.isEmpty()?QUrl():QUrl::fromLocalFile(file),album);};
const auto inspect=[&](QColor color,bool threeD) {
- if(!wait([&]{return colorIs(presenter->artwork(),color);}))return false;
+ // Presentation and its QML texture bindings can settle on separate
+ // event-loop turns. Keep the same deadline and inspect the whole path.
+ return wait([&] {
+ if(!colorIs(presenter->artwork(),color))return false;
if(!threeD&&player.medium()=="tp7"){auto *face=window->findChild<RecorderSurface*>("recorderWheelSurface");return face&&colorIs(face->property("artwork").value<QImage>(),color);}
if(!threeD){auto *disc=window->findChild<Disc*>("discFace");return disc&&colorIs(disc->artwork(),color);}
#ifdef SPUN_WITH_3D
@@ -85,6 +89,7 @@ int exerciseArtwork(Player &player,QQuickWindow *window,const QString &temp,cons
#else
return false;
#endif
+ });
};
QList<bool> modes{false};if(qmlContext(window)->contextProperty("supports3D").toBool())modes.append(true);
for(bool threeD:modes)for(const QString &medium:{QString("cd"),QString("vinyl"),QString("cassette"),QString("tp7")}) {
@@ -105,7 +110,7 @@ int exerciseArtwork(Player &player,QQuickWindow *window,const QString &temp,cons
publish("no-remote-cover",{});window->setProperty("useCider",true);QTest::qWait(50);
check(presenter->artwork().isNull(),"source switch without artwork does not borrow Local's cover");
publish("capture-blue",temp+"/art-blue.png");check(inspect(Qt::blue,threeD),"artwork recovers after an empty result");
- if(!captures.isEmpty()){QDir().mkpath(captures);window->grabWindow().save(captures+"/"+medium+(threeD?"-3d":"-2d")+".png");}
+ if(!captures.isEmpty()){QDir().mkpath(captures);captureTestWindow(window).save(captures+"/"+medium+(threeD?"-3d":"-2d")+".png");}
}
#ifdef SPUN_WITH_3D
// Inspect the rendered label as well as its CPU-side pixel buffer. A stale
@@ -118,7 +123,7 @@ int exerciseArtwork(Player &player,QQuickWindow *window,const QString &temp,cons
QMetaObject::invokeMethod(view,"projectSurface",Q_RETURN_ARG(QVariant,projected),
Q_ARG(QVariant,tape?128.:player.medium()=="cd"?345.:player.medium()=="tp7"?276.:285.),Q_ARG(QVariant,tape?203.:player.medium()=="tp7"?249.:294.));
const QPointF position=view->mapToScene(projected.toPointF());
- const QImage frame=window->grabWindow();
+ const QImage frame=captureTestWindow(window);
if(frame.isNull())return false;
const double scale=frame.width()/double(window->width());
const QPoint center=(position*scale).toPoint();
diff --git a/src/cablegeometry.cpp b/src/cablegeometry.cpp
new file mode 100644
index 0000000..46b24f8
--- /dev/null
+++ b/src/cablegeometry.cpp
@@ -0,0 +1,20 @@
+#include "cablegeometry.h"
+#include <array>
+#include <cmath>
+CableGeometry::CableGeometry(QQuick3DObject *p):QQuick3DGeometry(p){connect(this,&CableGeometry::shapeChanged,this,&CableGeometry::rebuild);rebuild();}
+void CableGeometry::rebuild(){
+ struct V{float x,y,z,nx,ny,nz,u,v;};QList<V> vertices;QList<quint32> indices;
+ const QVector3D a=m_start,b=a+QVector3D(-32,119,-14),d=m_end,c=d+QVector3D(32,119,-14);
+ QVector3D lo(1e5,1e5,1e5),hi(-1e5,-1e5,-1e5);
+ for(int i=0;i<=96;++i){const float t=i/96.f,s=1-t;const auto p=s*s*s*a+3*s*s*t*b+3*s*t*t*c+t*t*t*d;
+ const auto tangent=(3*s*s*(b-a)+6*s*t*(c-b)+3*t*t*(d-c)).normalized();
+ const auto n=QVector3D::crossProduct(tangent,QVector3D(0,0,1)).normalized(),bn=QVector3D::crossProduct(tangent,n).normalized();
+ for(int j=0;j<=12;++j){float angle=j*2*M_PI/12;auto normal=n*std::cos(angle)+bn*std::sin(angle);auto v=p+normal*1.65;
+ vertices.append({v.x(),v.y(),v.z(),normal.x(),normal.y(),normal.z(),float(j)/12,t*12});
+ for(int axis=0;axis<3;++axis){lo[axis]=std::min(lo[axis],v[axis]);hi[axis]=std::max(hi[axis],v[axis]);}
+ if(i<96&&j<12){quint32 k=i*13+j;indices.append({k,k+1,k+13,k+1,k+14,k+13});}
+ }
+ }
+ clear();setStride(sizeof(V));setPrimitiveType(PrimitiveType::Triangles);addAttribute(Attribute::PositionSemantic,0,Attribute::F32Type);addAttribute(Attribute::NormalSemantic,12,Attribute::F32Type);addAttribute(Attribute::TexCoord0Semantic,24,Attribute::F32Type);addAttribute(Attribute::IndexSemantic,0,Attribute::U32Type);
+ setVertexData(QByteArray(reinterpret_cast<const char*>(vertices.constData()),vertices.size()*sizeof(V)));setIndexData(QByteArray(reinterpret_cast<const char*>(indices.constData()),indices.size()*4));setBounds(lo,hi);update();
+}
diff --git a/src/cablegeometry.h b/src/cablegeometry.h
new file mode 100644
index 0000000..976c627
--- /dev/null
+++ b/src/cablegeometry.h
@@ -0,0 +1,15 @@
+#pragma once
+#include <QQuick3DGeometry>
+#include <QVector3D>
+class CableGeometry : public QQuick3DGeometry {
+ Q_OBJECT
+ Q_PROPERTY(QVector3D start MEMBER m_start NOTIFY shapeChanged)
+ Q_PROPERTY(QVector3D end MEMBER m_end NOTIFY shapeChanged)
+public:
+ explicit CableGeometry(QQuick3DObject *parent=nullptr);
+signals:
+ void shapeChanged();
+private:
+ void rebuild();
+ QVector3D m_start{-79,176,-8},m_end{216,176,-8};
+};
diff --git a/src/cassettedecktest.cpp b/src/cassettedecktest.cpp
new file mode 100644
index 0000000..3bbb47f
--- /dev/null
+++ b/src/cassettedecktest.cpp
@@ -0,0 +1,126 @@
+#include "testcapture.h"
+#include "cassettedecktest.h"
+#include "player.h"
+#include "cider.h"
+#include <QQmlContext>
+#include <QQuickItem>
+#include <QQuickWindow>
+#include <QTest>
+#include <QDir>
+#include <QFile>
+#include <functional>
+#include <iostream>
+#include <cmath>
+
+class CassetteRemote : public Cider {
+ Q_OBJECT
+ Q_PROPERTY(int count READ count NOTIFY trackChanged)
+ Q_PROPERTY(bool canSeek MEMBER seekable NOTIFY trackChanged)
+ Q_PROPERTY(bool playing MEMBER running NOTIFY playingChanged)
+ Q_PROPERTY(qint64 position MEMBER at NOTIFY positionChanged)
+ Q_PROPERTY(qint64 duration READ duration NOTIFY trackChanged)
+ Q_PROPERTY(QString trackKey READ key NOTIFY trackChanged)
+ Q_PROPERTY(double volume MEMBER level NOTIFY volumeChanged)
+public:
+ CassetteRemote():Cider(false){}
+ int count() const {return 1;} qint64 duration() const {return 32000;}
+ QString key() const {return "cassette-fixture";}
+ Q_INVOKABLE void toggle(){running=!running;emit playingChanged();}
+ Q_INVOKABLE void pause(){running=false;emit playingChanged();}
+ Q_INVOKABLE void seek(qint64 value){at=qBound<qint64>(0,value,duration());emit positionChanged();}
+ bool running=false,seekable=true;qint64 at=0;double level=.5;
+};
+
+int exerciseCassetteDeck(Player &player,QQuickWindow *window,const QString &temp,const QString &captures) {
+ int checks=0,failures=0;QString context;
+ const auto check=[&](bool ok,const char *name){++checks;if(!ok)++failures;std::cout<<(ok?"PASS ":"FAIL ")<<context.toStdString()<<": "<<name<<std::endl;return ok;};
+ const auto until=[](const std::function<bool()> &f){QElapsedTimer t;t.start();while(!f()&&t.elapsed()<3000)QTest::qWait(20);return f();};
+ std::function<QQuickItem*(QQuickItem*,QString)> find=[&](QQuickItem *p,QString name)->QQuickItem*{if(p->objectName()==name)return p;for(auto *c:p->childItems())if(auto *result=find(c,name))return result;return nullptr;};
+ const auto item=[&](QString n){return find(window->contentItem(),n);};
+ const auto invoke=[](QObject *o,const char *method){return QMetaObject::invokeMethod(o,method);};
+ const auto capture=[&](QString name){if(captures.isEmpty())return;QTest::mouseMove(window,{3,3});QTest::qWait(130);QDir().mkpath(captures);check(captureTestWindow(window).save(captures+"/"+name+".png"),"rendered frame saved");};
+ const auto move=[&](QPoint p){QMouseEvent e(QEvent::MouseMove,p,window->mapToGlobal(p),Qt::NoButton,Qt::LeftButton,Qt::NoModifier);QGuiApplication::sendEvent(window,&e);QTest::qWait(20);};
+ auto *typography=qmlContext(window)->contextProperty("typography").value<QObject*>();
+ player.setVolume(0);player.setMotion(false);player.setMiniMode(false);player.setThreeD(false);player.setMedium("cassette");player.setShowPlayerBody(true);player.clear();window->setProperty("useCider",false);window->setColor(QColor("#242a30"));
+ const QString path=temp+"/cassette.flac";QFile::copy(QStringLiteral(SPUN_SOURCE_DIR "/assets/First-Light.flac"),path);player.addUrls({QUrl::fromLocalFile(path)},false);
+ if(!check(until([&]{return !player.busy()&&player.count()==1;}),"local fixture imports"))return 2;
+ player.select(0,false);
+ CassetteRemote remote;const auto original=window->property("ciderService");window->setProperty("ciderService",QVariant::fromValue(static_cast<QObject*>(&remote)));
+ const bool supports=qmlContext(window)->contextProperty("supports3D").toBool();
+ for(bool threeD:{false,true}) {
+ if((threeD&&!supports)||(!threeD&&qEnvironmentVariableIsSet("SPUN_TEST_3D_ONLY")))continue;
+ player.setThreeD(threeD);QTest::qWait(180);
+ auto *controls=item("cassetteControls");auto *view=item("player3DView");
+ if(!check(controls&&(!threeD||(view&&window->property("threeDActive").toBool())),"cassette controls and renderer load"))return 2;
+ if(threeD)capture("cassette-3d-initial");
+ if(qEnvironmentVariableIsSet("SPUN_TEST_CAPTURE_ONLY")) {
+ if(threeD) {
+ for(const QString &finish:{QString("clear"),QString("smoke"),QString("cream")}) {player.setCassetteFinish(finish);capture("cassette-"+finish);}
+ controls->setProperty("doorOpen",true);capture("cassette-open");controls->setProperty("doorOpen",false);
+ view->setProperty("cassetteYaw",180.);view->setProperty("cassettePitch",0.);capture("cassette-back");
+ }
+ continue;
+ }
+ const auto point=[&](int index){
+ if(threeD){QVariant r;QMetaObject::invokeMethod(view,"projectCassetteControl",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,index));return view->mapToScene(r.toPointF()).toPoint();}
+ auto *key=item(QStringList{"cassettePlay","cassetteRewind","cassetteForward","cassetteStop","cassetteVolume","cassetteLatch"}[index]);return key->mapToScene(QPointF(key->width()/2,key->height()/2)).toPoint();
+ };
+ const auto click=[&](int index){
+ const auto at=point(index);
+ if(threeD) { const auto local=view->mapFromScene(at);QVariant hit;QMetaObject::invokeMethod(view,"cassetteHit",Q_RETURN_ARG(QVariant,hit),Q_ARG(QVariant,local.x()),Q_ARG(QVariant,local.y()));const auto result=hit.toMap();if(result.value("hardware").toInt()!=index)std::cout<<"TARGET "<<index<<" hit "<<result.value("hardware").toInt()<<" at "<<at.x()<<","<<at.y()<<std::endl; }
+ QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,at);QTest::qWait(65);
+ };
+ for(bool cider:{false,true})for(double scale:{1.,1.25}) {
+ context=QString("%1 %2 %3").arg(threeD?"3D":"2D",cider?"Cider":"local").arg(scale);
+ if(threeD)invoke(view,"resetCassetteOrientation");
+ controls->setProperty("doorOpen",false);
+ typography->setProperty("uiScale",scale);window->setProperty("useCider",cider);player.pause();remote.pause();QTest::qWait(100);
+ const auto playing=[&]{return cider?remote.running:player.playing();};
+ const auto position=[&]{return cider?remote.at:player.position();};
+ const auto level=[&]{return cider?remote.level:player.volume();};
+ click(0);check(until(playing),"play starts playback");click(0);check(!playing(),"play pauses playback");
+ if(cider)remote.seek(0);else player.seek(0);
+ click(2);check(until([&]{return std::abs(position()-10000)<800;}),"forward seeks ten seconds");click(1);check(until([&]{return position()<800;}),"rewind clamps at the start");
+ click(0);check(until(playing),"play settles before testing stop");click(3);check(!playing()&&!controls->property("doorOpen").toBool(),"stop pauses before ejecting");
+ click(3);check(controls->property("doorOpen").toBool(),"second stop opens the door");
+ click(0);check(until(playing)&&!controls->property("doorOpen").toBool(),"play closes the door and starts immediately");
+ click(5);check(!playing()&&controls->property("doorOpen").toBool(),"door latch pauses transport and opens");click(5);check(!controls->property("doorOpen").toBool(),"door latch closes without resuming");
+ const auto p=point(0);QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,p);
+ check(controls->property("pressedControl").toInt()==0&&!playing(),"button action waits for release");
+ check(item("cassettePlay")->property("pressure").toDouble()>.95,"button depresses with reduced motion");
+ move({4,4});QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,{4,4});check(!playing()&&controls->property("pressedControl").toInt()==-1,"dragging off cancels pressure and activation");
+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,point(0));QTest::keyClick(window,Qt::Key_Escape);QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,point(0));check(!playing()&&controls->property("pressedControl").toInt()==-1,"Escape cancels hardware input");
+ if(cider){remote.level=.5;emit remote.volumeChanged();}else player.setVolume(.5);
+ const auto knob=point(4);QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,knob);move(knob-QPoint(0,35));QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,knob-QPoint(0,35));check(level()>.6&&level()<=1,"side knob controls the active source volume");
+ if(!threeD){auto *key=item("cassettePlay");key->forceActiveFocus();QTest::keyClick(window,Qt::Key_Return);check(until(playing),"keyboard activates transport");click(0);}
+ auto *slider=item("cassetteSeek");const auto seekPoint=[&](double fraction){const auto local=slider->mapToItem(item("mediaSurface"),{slider->width()*fraction,slider->height()/2});if(!threeD)return slider->mapToScene({slider->width()*fraction,slider->height()/2}).toPoint();QVariant r;QMetaObject::invokeMethod(view,"projectSurface",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,local.x()),Q_ARG(QVariant,local.y()));return view->mapToScene(r.toPointF()).toPoint();};
+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,seekPoint(.2));move(seekPoint(.7));check(slider->property("scrubbing").toBool()&&window->property("cassetteVisualProgress").toDouble()>.65,"progress drag previews the same tape position");QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,seekPoint(.7));check(until([&]{return position()>20000;}),"progress drag commits to playback");
+ if(cider){remote.seekable=false;emit remote.trackChanged();check(!item("cassetteForward")->isEnabled()&&!slider->isEnabled(),"unseekable source disables seeking");remote.seekable=true;emit remote.trackChanged();}
+ }
+ typography->setProperty("uiScale",1.);window->setProperty("useCider",false);player.pause();player.setVolume(0);QTest::qWait(100);
+ if(threeD) {
+ invoke(view,"resetCassetteOrientation");controls->setProperty("doorOpen",false);
+ for(const QString &finish:{QString("clear"),QString("smoke"),QString("cream")}) {player.setCassetteFinish(finish);QTest::qWait(100);capture("cassette-3d-"+finish);}
+ player.setCassetteFinish("clear");
+ const auto closedCamera=view->property("cassetteCamera");
+ click(5);capture("cassette-3d-door-open");
+ QVariant doorBounds;QMetaObject::invokeMethod(view,"lidBounds",Q_RETURN_ARG(QVariant,doorBounds));
+ check(QRectF(0,0,view->width(),view->height()).contains(doorBounds.toRectF()),"open door remains inside the viewport");
+ check(view->property("cassetteCamera")==closedCamera,"door travel keeps the camera steady");click(5);
+ view->setProperty("cassetteYaw",180.);view->setProperty("cassettePitch",0.);QTest::qWait(100);capture("cassette-3d-back");
+ view->setProperty("cassetteYaw",-45.);view->setProperty("cassettePitch",15.);capture("cassette-3d-side");invoke(view,"resetCassetteOrientation");
+ const QPoint from=view->mapToScene({view->width()/2,view->height()/2}).toPoint();QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,from);move(from+QPoint(60,25));QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,from+QPoint(60,25));check(std::abs(view->property("cassetteYaw").toDouble())>15&&std::abs(view->property("cassettePitch").toDouble())>5,"body drag rotates on both axes");check(!window->property("discFlipped").toBool(),"rotation leaves reverse details separate");invoke(view,"resetCassetteOrientation");
+ player.setMotion(true);QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,point(0));check(until([&]{return item("cassettePlay")->property("pressure").toDouble()>.9;}),"animated button pressure reaches its stop");capture("cassette-3d-key-held");move({4,4});QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,{4,4});check(until([&]{return item("cassettePlay")->property("pressure").toDouble()<.01;}),"button spring settles after release");player.setMotion(false);
+ }else capture("cassette-2d");
+ std::cout<<"CHECK scene reverse lifecycle"<<std::endl;
+ invoke(window,"flipDisc");check(window->property("discFlipped").toBool()&&!window->property("threeDActive").toBool(),"F reverse remains readable and separate");
+ QTest::qWait(120);invoke(window,"flipDisc");QTest::qWait(120);
+ std::cout<<"CHECK Mini lifecycle"<<std::endl;
+ player.setMiniMode(true);QTest::qWait(100);check(!window->property("threeDActive").toBool()&&!item("cassetteControls"),"Mini keeps the compact cassette");player.setMiniMode(false);QTest::qWait(120);
+ for(const QString &medium:QStringList{"tp7","vinyl","cd","cassette"}){player.setMedium(medium);QTest::qWait(100);check(player.medium()==medium,"switching medium releases the cassette scene safely");}
+ }
+ window->setProperty("ciderService",original);window->setProperty("useCider",false);player.setThreeD(false);player.clear();QTest::qWait(100);
+ check(!item("cassettePlay")->isEnabled()&&item("cassetteVolume")->isEnabled()&&item("cassetteStop")->isEnabled(),"empty player keeps only volume and door controls available");
+ std::cout<<"CASSETTE DECK RESULT "<<checks<<" checks, "<<failures<<" failures"<<std::endl;return failures?1:0;
+}
+#include "cassettedecktest.moc"
diff --git a/src/cassettedecktest.h b/src/cassettedecktest.h
new file mode 100644
index 0000000..ce61277
--- /dev/null
+++ b/src/cassettedecktest.h
@@ -0,0 +1,5 @@
+#pragma once
+#include <QString>
+class Player;
+class QQuickWindow;
+int exerciseCassetteDeck(Player &player,QQuickWindow *window,const QString &temp,const QString &captures);
diff --git a/src/cddecktest.cpp b/src/cddecktest.cpp
new file mode 100644
index 0000000..617bc38
--- /dev/null
+++ b/src/cddecktest.cpp
@@ -0,0 +1,116 @@
+#include "testcapture.h"
+#include "cddecktest.h"
+#include "player.h"
+#include "cider.h"
+#include <QQmlContext>
+#include <QQuickItem>
+#include <QQuickWindow>
+#include <QTest>
+#include <QDir>
+#include <QFile>
+#include <functional>
+#include <iostream>
+#include <cmath>
+
+class CdRemote : public Cider {
+ Q_OBJECT
+ Q_PROPERTY(int count READ count NOTIFY trackChanged)
+ Q_PROPERTY(bool canSeek MEMBER seekable NOTIFY trackChanged)
+ Q_PROPERTY(bool playing MEMBER running NOTIFY playingChanged)
+ Q_PROPERTY(qint64 position MEMBER at NOTIFY positionChanged)
+ Q_PROPERTY(qint64 duration READ duration NOTIFY trackChanged)
+ Q_PROPERTY(QString trackKey READ key NOTIFY trackChanged)
+ Q_PROPERTY(double volume MEMBER level NOTIFY volumeChanged)
+ Q_PROPERTY(bool shuffle MEMBER shuffled NOTIFY settingsChanged)
+ Q_PROPERTY(int repeatMode MEMBER repeat NOTIFY settingsChanged)
+public:
+ CdRemote():Cider(false){}
+ int count()const{return 3;} qint64 duration()const{return 32000;}
+ QString key()const{return QString("cd-fixture-%1").arg(track);}
+ Q_INVOKABLE void toggle(){running=!running;emit playingChanged();}
+ Q_INVOKABLE void pause(){running=false;emit playingChanged();}
+ Q_INVOKABLE void seek(qint64 value){at=qBound<qint64>(0,value,duration());emit positionChanged();}
+ Q_INVOKABLE void previous(){track=qMax(0,track-1);at=0;emit trackChanged();emit positionChanged();}
+ Q_INVOKABLE void next(){track=qMin(2,track+1);at=0;emit trackChanged();emit positionChanged();}
+ bool running=false,seekable=true,shuffled=false;int track=0,repeat=0;qint64 at=0;double level=.5;
+};
+
+int exerciseCdDeck(Player &player,QQuickWindow *window,const QString &temp,const QString &captures) {
+ int checks=0,failures=0;QString context="setup";
+ const auto check=[&](bool ok,const char *name){++checks;if(!ok)++failures;std::cout<<(ok?"PASS ":"FAIL ")<<context.toStdString()<<": "<<name<<std::endl;return ok;};
+ const auto until=[](const std::function<bool()> &f){QElapsedTimer t;t.start();while(!f()&&t.elapsed()<3000)QTest::qWait(20);return f();};
+ std::function<QQuickItem*(QQuickItem*,QString)> find=[&](QQuickItem *p,QString n)->QQuickItem*{if(p->objectName()==n)return p;for(auto *c:p->childItems())if(auto *r=find(c,n))return r;return nullptr;};
+ const auto item=[&](QString n){return find(window->contentItem(),n);};
+ const auto invoke=[](QObject *o,const char *m){return QMetaObject::invokeMethod(o,m);};
+ const auto capture=[&](QString name){
+ if(captures.isEmpty())return;
+ QTest::mouseMove(window,{3,3});QTest::qWait(100);QDir().mkpath(captures);
+ auto frame=captureTestWindow(window);
+ int clean=0;for(int y:{110,160,210,260,310})if(frame.rect().contains(8,y)&&frame.pixelColor(8,y)==QColor("#242a30"))++clean;
+ check(clean>=4,"rendered frame has an intact background");
+ check(frame.save(captures+"/"+name+".png"),"rendered frame saved");
+ };
+ const auto move=[&](QPoint p){QMouseEvent e(QEvent::MouseMove,p,window->mapToGlobal(p),Qt::NoButton,Qt::LeftButton,Qt::NoModifier);QGuiApplication::sendEvent(window,&e);QTest::qWait(20);};
+ auto *typography=qmlContext(window)->contextProperty("typography").value<QObject*>();
+ player.setVolume(0);player.setMotion(false);player.setMiniMode(false);player.setThreeD(false);player.setMedium("cd");player.setShowPlayerBody(true);player.setHorizontalSeek(true);player.clear();player.setShuffle(false);player.setRepeatMode(0);window->setProperty("useCider",false);window->setColor(QColor("#242a30"));
+ QList<QUrl> files;for(int i=0;i<3;++i){const auto path=temp+QString("/cd-%1.flac").arg(i);QFile::copy(QStringLiteral(SPUN_SOURCE_DIR "/assets/First-Light.flac"),path);files<<QUrl::fromLocalFile(path);}player.addUrls(files,false);
+ if(!check(until([&]{return !player.busy()&&player.count()==3;}),"local fixtures import"))return 2;
+ player.select(0,false);if(qEnvironmentVariableIsSet("SPUN_TEST_CAPTURE_ONLY"))typography->setProperty("uiScale",1.5);CdRemote remote;const auto original=window->property("ciderService");window->setProperty("ciderService",QVariant::fromValue(static_cast<QObject*>(&remote)));
+ const bool supports=qmlContext(window)->contextProperty("supports3D").toBool();
+ for(bool threeD:{false,true}) {
+ if((threeD&&!supports)||(!threeD&&qEnvironmentVariableIsSet("SPUN_TEST_3D_ONLY")))continue;
+ player.setThreeD(threeD);QTest::qWait(150);
+ auto *controls=item("cdControls"),*view=item("player3DView");
+ if(!check(controls&&(!threeD||(view&&window->property("threeDActive").toBool())),"CD controls and renderer load"))return 2;
+ if(threeD)capture("cd-3d-initial");
+ if(qEnvironmentVariableIsSet("SPUN_TEST_CAPTURE_ONLY")){
+ capture(threeD?"cd-3d":"cd-2d");
+ if(threeD){controls->setProperty("doorOpen",true);QTest::qWait(100);capture("cd-open");controls->setProperty("doorOpen",false);view->setProperty("cdYaw",160.);QTest::qWait(100);capture("cd-back");view->setProperty("cdYaw",45.);view->setProperty("cdPitch",18.);QTest::qWait(100);capture("cd-side");}
+ continue;
+ }
+ const QStringList keys={"cdPlay","cdStop","cdSettings","cdPrevious","cdNext","cdMute","cdVolume","cdLatch","cdShuffle","cdRepeat"};
+ const auto point=[&](int index){if(threeD){QVariant r;QMetaObject::invokeMethod(view,"projectCdControl",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,index));return view->mapToScene(r.toPointF()).toPoint();}auto *key=item(keys[index]);return key->mapToScene({key->width()/2,key->height()/2}).toPoint();};
+ const auto click=[&](int index){const auto p=point(index);if(threeD){QVariant r;const auto local=view->mapFromScene(p);QMetaObject::invokeMethod(view,"cdHit",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,local.x()),Q_ARG(QVariant,local.y()));if(r.toMap().value("hardware").toInt()!=index)std::cout<<"TARGET "<<index<<" hit "<<r.toMap().value("hardware").toInt()<<" at "<<p.x()<<","<<p.y()<<std::endl;}QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,p);QTest::qWait(50);};
+ for(bool cider:{false,true})for(double scale:{1.,1.25}) {
+ context=QString("%1 %2 %3").arg(threeD?"3D":"2D",cider?"Cider":"local").arg(scale);
+ if(threeD)invoke(view,"resetCdOrientation");
+ controls->setProperty("doorOpen",false);typography->setProperty("uiScale",scale);window->setProperty("useCider",cider);player.select(0,false);remote.track=0;remote.pause();QTest::qWait(100);
+ const auto playing=[&]{return cider?remote.running:player.playing();};const auto position=[&]{return cider?remote.at:player.position();};const auto level=[&]{return cider?remote.level:player.volume();};const auto track=[&]{return cider?remote.track:player.currentIndex();};
+ click(0);check(until(playing),"play starts the active source");click(0);check(!playing(),"play pauses the active source");
+ click(4);check(until([&]{return track()==1;}),"next selects the next track");if(cider)remote.seek(0);else player.seek(0);click(3);check(until([&]{return track()==0;}),"previous selects the preceding track");
+ if(cider)remote.seek(7000);else player.seek(7000);click(1);check(!playing()&&until([&]{return position()<600;}),"stop pauses and returns to the start");
+ click(0);check(until(playing),"play resumes before opening lid");click(7);check(!playing()&&controls->property("doorOpen").toBool(),"latch pauses and opens the glass lid");click(7);check(!controls->property("doorOpen").toBool()&&!playing(),"closing lid does not resume playback");
+ click(7);click(0);check(until(playing)&&!controls->property("doorOpen").toBool(),"play closes an open lid");click(1);
+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,point(0));check(controls->property("pressedControl").toInt()==0&&!playing(),"action waits for release");check(item("cdPlay")->property("pressure").toDouble()>.95,"button depresses with reduced motion");move({3,3});QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,{3,3});check(!playing()&&controls->property("pressedControl").toInt()==-1,"drag off cancels the button");
+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,point(0));QTest::keyClick(window,Qt::Key_Escape);QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,point(0));check(!playing()&&controls->property("pressedControl").toInt()==-1,"Escape clears button pressure");
+ if(cider){remote.level=.5;emit remote.volumeChanged();}else player.setVolume(.5);
+ const auto knob=point(6);QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,knob);move(knob-QPoint(0,35));QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,knob-QPoint(0,35));check(level()>.6&&level()<=1,"knob adjusts the active source volume");const auto before=level();click(5);check(level()==0,"mute silences the active source");click(5);check(std::abs(level()-before)<.02,"mute restores the previous volume");
+ click(8);check(cider?remote.shuffled:player.shuffle(),"shuffle selector enables shuffle");click(8);check(!(cider?remote.shuffled:player.shuffle()),"shuffle selector disables shuffle");for(int r=1;r<=3;++r){click(9);check((cider?remote.repeat:player.repeatMode())==r%3,"repeat selector cycles all modes");}
+ click(2);check(window->property("menuOpen").toBool(),"settings key opens settings");QTest::keyClick(window,Qt::Key_Escape);QTest::qWait(70);
+ auto *rim=item("scrubber");const auto seekPoint=[&](double fraction){const double a=fraction*2*std::acos(-1.);const QPointF ring(220+216*std::sin(a),220-216*std::cos(a));if(!threeD)return rim->mapToScene(ring).toPoint();const auto local=rim->mapToItem(item("mediaSurface"),ring);QVariant r;QMetaObject::invokeMethod(view,"projectSurface",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,local.x()),Q_ARG(QVariant,local.y()));return view->mapToScene(r.toPointF()).toPoint();};
+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,seekPoint(.25));move(seekPoint(.5));check(rim->property("scrubbing").toBool()&&std::abs(window->property("recordVisualProgress").toDouble()-.5)<.025,"rim drag previews the shared playback position");check(std::abs(item("horizontalSeek")->property("value").toDouble()-.5)<.025,"horizontal progress follows the rim preview");QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,seekPoint(.5));check(until([&]{return std::abs(position()-(cider?remote.duration():player.duration())*.5)<900;}),"rim drag commits the same position");
+ if(cider){remote.seekable=false;emit remote.trackChanged();check(!rim->property("canSeek").toBool(),"unseekable source disables the rim");remote.seekable=true;emit remote.trackChanged();}
+ if(!threeD){auto *key=item("cdPlay");key->forceActiveFocus();QTest::keyClick(window,Qt::Key_Return);check(until(playing),"keyboard activates the hardware button");click(1);}
+ }
+ typography->setProperty("uiScale",1.);window->setProperty("useCider",false);player.pause();player.setVolume(0);QTest::qWait(100);
+ if(threeD){
+ invoke(view,"resetCdOrientation");const auto camera=view->property("cdCamera");click(7);capture("cd-3d-lid-open");QVariant bounds;QMetaObject::invokeMethod(view,"lidBounds",Q_RETURN_ARG(QVariant,bounds));check(QRectF(0,0,view->width(),view->height()).contains(bounds.toRectF()),"open lid fits inside viewport");check(view->property("cdCamera")==camera,"lid opening keeps camera fixed");click(7);
+ view->setProperty("cdYaw",160.);capture("cd-3d-back");view->setProperty("cdYaw",45.);view->setProperty("cdPitch",18.);capture("cd-3d-side");invoke(view,"resetCdOrientation");
+ const QPoint from=view->mapToScene({view->width()/2,view->height()/2}).toPoint();QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,from);move(from+QPoint(65,30));QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,from+QPoint(65,30));check(std::abs(view->property("cdYaw").toDouble())>15&&std::abs(view->property("cdPitch").toDouble())>5,"housing drag rotates on both axes");check(!window->property("discFlipped").toBool(),"rotation is separate from F reverse");invoke(view,"resetCdOrientation");
+ player.setMotion(true);QTest::qWait(160);QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,point(0));check(until([&]{return item("cdPlay")->property("pressure").toDouble()>.9;}),"spring reaches button stop");move({3,3});QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,{3,3});check(until([&]{return item("cdPlay")->property("pressure").toDouble()<.01;}),"spring settles on release");
+ controls->setProperty("doorOpen",true);QTest::qWait(400);
+ auto *presenter=qmlContext(window)->contextProperty("presentation").value<QObject*>();
+ invoke(presenter,"swapRequested");QTest::qWait(40);
+ check(window->property("swapRunning").toBool(),"album exchange starts with an already open lid");
+ bool stayedOpen=true;QElapsedTimer exchange;exchange.start();
+ while(window->property("swapRunning").toBool()&&exchange.elapsed()<2500){stayedOpen&=controls->property("doorAngle").toDouble()>69.;QTest::qWait(20);}
+ check(stayedOpen&&!window->property("swapRunning").toBool()&&controls->property("doorOpen").toBool(),"album exchange keeps a manually opened lid raised");
+ controls->setProperty("doorOpen",false);player.setMotion(false);
+ }else capture("cd-2d");
+ invoke(window,"flipDisc");check(window->property("discFlipped").toBool()&&!window->property("threeDActive").toBool(),"reverse stays readable");QTest::qWait(100);invoke(window,"flipDisc");QTest::qWait(100);player.setMiniMode(true);QTest::qWait(100);check(!window->property("threeDActive").toBool()&&!item("cdControls"),"Mini unloads the detailed hardware");player.setMiniMode(false);QTest::qWait(100);
+ for(const QString &medium:QStringList{"tp7","vinyl","cassette","cd"}){player.setMedium(medium);QTest::qWait(100);check(player.medium()==medium,"medium switch releases and restores the CD assembly");}
+ }
+ window->setProperty("ciderService",original);window->setProperty("useCider",false);if(qEnvironmentVariableIsSet("SPUN_TEST_CAPTURE_ONLY"))return failures?1:0;player.clear();QTest::qWait(100);capture("cd-empty");check(!item("cdPlay")->isEnabled()&&item("cdVolume")->isEnabled()&&item("cdLatch")->isEnabled(),"empty transport keeps volume and lid available");
+ player.setThreeD(false);std::cout<<"CD DECK RESULT "<<checks<<" checks, "<<failures<<" failures"<<std::endl;return failures?1:0;
+}
+#include "cddecktest.moc"
diff --git a/src/cddecktest.h b/src/cddecktest.h
new file mode 100644
index 0000000..691e701
--- /dev/null
+++ b/src/cddecktest.h
@@ -0,0 +1,5 @@
+#pragma once
+#include <QString>
+class Player;
+class QQuickWindow;
+int exerciseCdDeck(Player &player,QQuickWindow *window,const QString &temp,const QString &captures);
diff --git a/src/deckgeometry.cpp b/src/deckgeometry.cpp
index 00bea34..2fb59b9 100644
--- a/src/deckgeometry.cpp
+++ b/src/deckgeometry.cpp
@@ -7,12 +7,14 @@ DeckGeometry::DeckGeometry(QQuick3DObject *parent):QQuick3DGeometry(parent) {
connect(this,&DeckGeometry::shapeChanged,this,&DeckGeometry::rebuild);rebuild();
}
void DeckGeometry::rebuild() {
+ if(m_initializing)return;
struct Vertex {float x,y,z,nx,ny,nz,u,v;};
QByteArray vertices;
const float w=qMax(.01f,m_dimensions.x()/2),h=qMax(.01f,m_dimensions.y()/2),d=qMax(.01f,m_dimensions.z()/2);
const float r=qBound(.001f,m_radius,qMin(w,h));
const float bevel=qMin(qMin(3.f,d/2),r*.75f);
constexpr int perimeter=68;
+ vertices.reserve(perimeter*16*3*sizeof(Vertex));
const auto outward=[](int i){
const int corner=(i/17)%4;
const float angle=(corner*90+(i%17)*90.f/16)*float(M_PI)/180;
diff --git a/src/deckgeometry.h b/src/deckgeometry.h
index 527a587..fc752f0 100644
--- a/src/deckgeometry.h
+++ b/src/deckgeometry.h
@@ -10,7 +10,11 @@ public:
explicit DeckGeometry(QQuick3DObject *parent=nullptr);
signals:
void shapeChanged();
+protected:
+ void classBegin() override { QQuick3DGeometry::classBegin(); m_initializing=true; }
+ void componentComplete() override { m_initializing=false; rebuild(); QQuick3DGeometry::componentComplete(); }
private:
+ bool m_initializing=false;
void rebuild();
QVector3D m_dimensions{428,428,26};
float m_radius=22;
diff --git a/src/geometrytest.cpp b/src/geometrytest.cpp
index 82afa28..b2ddbfc 100644
--- a/src/geometrytest.cpp
+++ b/src/geometrytest.cpp
@@ -2,6 +2,12 @@
#include "deckgeometry.h"
#include <QTest>
#include <QPointer>
+#include <QFile>
+#include <QDir>
+#include <QQmlComponent>
+#include <QQmlEngine>
+#include <memory>
+#include <type_traits>
#include <cmath>
#include <map>
#include <array>
@@ -9,6 +15,116 @@
class GeometryTest : public QObject {
Q_OBJECT
private slots:
+ void qmlInitializationRetainsFinalPropertiesAndLiveUpdates() {
+ // Batching initial QML assignments must produce the same data as the
+ // C++ setters, and must not suppress changes after componentComplete.
+ const auto verify=[&]<typename T>(const char *name,const QByteArray &declaration,
+ const QVariantMap &initial,const char *property,const QVariant &next) {
+ qmlRegisterType<T>("GeometryLifecycle",1,0,name);
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick\nimport GeometryLifecycle 1.0\n"+QByteArray(name)+" { "+declaration+" }",QUrl());
+ QTRY_VERIFY_WITH_TIMEOUT(component.status()!=QQmlComponent::Loading,3000);
+ QVERIFY2(component.isReady(),qPrintable(component.errorString()));
+ std::unique_ptr<QObject> object(component.create());
+ auto *qml=qobject_cast<T*>(object.get());QVERIFY(qml);
+ T native;
+ for(auto it=initial.cbegin();it!=initial.cend();++it)QVERIFY(native.setProperty(it.key().toLatin1(),it.value()));
+ const auto bytes=[](T *item) {
+ if constexpr(std::is_base_of_v<QQuick3DGeometry,T>)return item->vertexData();
+ else return item->textureData();
+ };
+ QCOMPARE(bytes(qml),bytes(&native));
+ const auto before=bytes(qml);
+ QVERIFY(qml->setProperty(property,next));QVERIFY(native.setProperty(property,next));
+ QCOMPARE(bytes(qml),bytes(&native));QVERIFY(bytes(qml)!=before);
+ };
+ verify.operator()<DeckGeometry>("DeckGeometry","dimensions: Qt.vector3d(12, 21, 11); radius: 3",
+ {{"dimensions",QVector3D(12,21,11)},{"radius",3.f}},"radius",2.f);
+ verify.operator()<RecordGeometry>("RecordGeometry","radius: 40; hole: 4; depth: 3; grooves: true",
+ {{"radius",40.f},{"hole",4.f},{"depth",3.f},{"grooves",true}},"radius",36.f);
+ verify.operator()<WaveGeometry>("WaveGeometry","progress: 0.6; phase: 1.7; amplitude: 2.4; linear: true",
+ {{"progress",.6f},{"phase",1.7f},{"amplitude",2.4f},{"linear",true}},"phase",2.f);
+ verify.operator()<TurntableDetailGeometry>("TurntableDetailGeometry","fascia: true",{{"fascia",true}},"fascia",false);
+ verify.operator()<SurfaceTexture>("SurfaceTexture","kind: \"vinyl-normal\"",{{"kind","vinyl-normal"}},"kind","bead-normal");
+ verify.operator()<StudioTexture>("StudioTexture","tint: \"#80b8e8\"; ambientLift: 0.3",
+ {{"tint",QColor("#80b8e8")},{"ambientLift",.3f}},"tint",QColor("#e8ac80"));
+ verify.operator()<CoverTexture>("CoverTexture","paper: true; title: \"Album\"; artist: \"Artist\"",
+ {{"paper",true},{"title","Album"},{"artist","Artist"}},"title","Changed album");
+ }
+ void exportCompatibilitySamples() {
+ const auto path=qEnvironmentVariable("SPUN_GEOMETRY_SNAPSHOTS");
+ if(path.isEmpty())QSKIP("Set SPUN_GEOMETRY_SNAPSHOTS to compare generated bytes across builds");
+ QDir().mkpath(path);
+ const auto save=[&](const QString &name,const QByteArray &bytes) {
+ QFile file(path+"/"+name);QVERIFY(file.open(QIODevice::WriteOnly));QCOMPARE(file.write(bytes),bytes.size());
+ };
+ for(const QString kind:{"brushed","molded","vinyl","disc","turned","metal-normal","paper","knurled-normal","bead-normal","vinyl-normal","lacquer","powder","satin","leather-normal","turned-normal"}) {
+ SurfaceTexture texture;texture.setProperty("kind",kind);save("texture-"+kind,texture.textureData());
+ }
+ int i=0;
+ for(const QColor tint:{QColor(Qt::white),QColor("#80b8e8"),QColor("#e8ac80")})for(float lift:{0.f,.3f}) {
+ StudioTexture texture;texture.setProperty("tint",tint);texture.setProperty("ambientLift",lift);save("studio-"+QString::number(i++),texture.textureData());
+ }
+ i=0;
+ for(const auto dimensions:{QVector3D(4,.7,.3),QVector3D(428,428,28),QVector3D(12,21,11),QVector3D(535,398,42)})for(float radius:{.1f,2.f,22.f}) {
+ DeckGeometry mesh;mesh.setProperty("dimensions",dimensions);mesh.setProperty("radius",radius);save("deck-"+QString::number(i++),mesh.vertexData());
+ }
+ i=0;
+ for(float radius:{3.2f,26.f,40.f,176.f})for(float depth:{.05f,2.f,12.f})for(bool grooves:{false,true}) {
+ RecordGeometry mesh;mesh.setProperty("radius",radius);mesh.setProperty("depth",depth);mesh.setProperty("grooves",grooves);save("record-"+QString::number(i++),mesh.vertexData());
+ }
+ i=0;
+ for(bool linear:{false,true})for(float progress:{0.f,.25f,1.f})for(float phase:{0.f,1.7f}) {
+ WaveGeometry mesh;mesh.setProperty("linear",linear);mesh.setProperty("progress",progress);mesh.setProperty("phase",phase);mesh.setProperty("amplitude",2.4f);save("wave-"+QString::number(i++),mesh.vertexData());
+ }
+ }
+ void cassetteCarrierHasOpeningsAndClosedEdges() {
+ CassettePlateGeometry mesh;
+ const auto data=mesh.vertexData();QVERIFY(!data.isEmpty());QVERIFY(data.size()<60000);
+ const auto *v=reinterpret_cast<const float*>(data.constData());
+ std::map<std::array<float,6>,int> edges;
+ for(int i=0;i<data.size()/int(sizeof(float));i+=24) {
+ std::array<std::array<float,3>,3> points;
+ for(int k=0;k<3;++k) {
+ const int n=i+k*8;
+ for(int j=0;j<8;++j)QVERIFY(std::isfinite(v[n+j]));
+ QVERIFY(std::abs(QVector3D(v[n+3],v[n+4],v[n+5]).length()-1)<.001);
+ points[k]={v[n],v[n+1],v[n+2]};
+ }
+ for(int k=0;k<3;++k) {
+ auto a=points[k],b=points[(k+1)%3];if(b<a)std::swap(a,b);
+ ++edges[{a[0],a[1],a[2],b[0],b[1],b[2]}];
+ }
+ const float cx=(v[i]+v[i+8]+v[i+16])/3,cy=(v[i+1]+v[i+9]+v[i+17])/3;
+ if(std::abs(v[i+5])>.99) {
+ QVERIFY(!(cx>-109&&cx<-76&&cy>-7&&cy<36));
+ QVERIFY(!(cx>35&&cx<60&&cy>-31&&cy<36));
+ }
+ }
+ for(const auto &[edge,count]:edges){Q_UNUSED(edge);QCOMPARE(count,2);}
+ QCOMPARE(mesh.boundsMax().z()-mesh.boundsMin().z(),3.f);
+ }
+ void cassetteGearHasThicknessAndOpenShaft() {
+ CassetteGearGeometry gear;
+ const auto data=gear.vertexData();QVERIFY(!data.isEmpty());QVERIFY(data.size()<100000);
+ const auto *v=reinterpret_cast<const float*>(data.constData());
+ float low=100,high=-100;
+ for(int i=0;i<data.size()/int(sizeof(float));i+=24) {
+ for(int k=0;k<24;++k)QVERIFY(std::isfinite(v[i+k]));
+ const QVector3D a(v[i],v[i+1],v[i+2]),b(v[i+8],v[i+9],v[i+10]),c(v[i+16],v[i+17],v[i+18]);
+ QVERIFY(QVector3D::crossProduct(b-a,c-a).lengthSquared()>1e-10f);
+ for(int k=0;k<24;k+=8) {
+ QVERIFY(std::hypot(v[i+k],v[i+k+1])>=2.99f);
+ QVERIFY(std::hypot(v[i+k],v[i+k+1])<=20.01f);
+ QVERIFY(std::abs(QVector3D(v[i+k+3],v[i+k+4],v[i+k+5]).length()-1)<.001);
+ low=qMin(low,v[i+k+2]);high=qMax(high,v[i+k+2]);
+ }
+ const float area=(v[i+14]-v[i+6])*(v[i+23]-v[i+7])-(v[i+15]-v[i+7])*(v[i+22]-v[i+6]);
+ QVERIFY(std::abs(area)>1e-9f);
+ }
+ QCOMPARE(high-low,4.f);
+ }
void turntableDetails() {
for(bool fascia:{false,true}) {
TurntableDetailGeometry mesh;mesh.setProperty("fascia",fascia);
@@ -138,7 +254,7 @@ private slots:
}
void materialMapsAreBoundedAndRepeatable() {
QByteArray previous;
- for(const QString kind:{QString("brushed"),QString("molded"),QString("vinyl"),QString("disc"),QString("turned"),QString("metal-normal"),QString("paper"),QString("knurled-normal"),QString("bead-normal"),QString("vinyl-normal"),QString("lacquer"),QString("powder")}){
+ for(const QString kind:{QString("brushed"),QString("molded"),QString("vinyl"),QString("disc"),QString("turned"),QString("metal-normal"),QString("paper"),QString("knurled-normal"),QString("bead-normal"),QString("vinyl-normal"),QString("lacquer"),QString("powder"),QString("satin"),QString("leather-normal"),QString("turned-normal")}){
SurfaceTexture first,second;first.setProperty("kind",kind);second.setProperty("kind",kind);
const int size=(kind=="vinyl-normal"||kind=="lacquer")?1024:kind=="powder"?512:256;
QCOMPARE(first.size(),QSize(size,size));QCOMPARE(first.textureData().size(),size*size*4);
@@ -146,6 +262,21 @@ private slots:
previous=first.textureData();
}
}
+ void fineFinishesHaveFiniteNormalsAndNoTileSeams() {
+ for(const QString &kind:{QString("leather-normal"),QString("turned-normal"),QString("knurled-normal")}) {
+ SurfaceTexture texture;texture.setProperty("kind",kind);
+ const auto data=texture.textureData();const auto *p=reinterpret_cast<const unsigned char*>(data.constData());
+ for(int i=0;i<256*256;++i) {
+ const QVector3D normal(p[i*4]/127.5f-1,p[i*4+1]/127.5f-1,p[i*4+2]/127.5f-1);
+ QVERIFY(std::abs(normal.length()-1)<.012f);QVERIFY(normal.z()>.9f);
+ QCOMPARE(p[i*4+3],255);
+ }
+ if(kind=="leather-normal")for(int i=0;i<256;++i)for(int c=0;c<3;++c) {
+ QVERIFY(std::abs(int(p[(i*256)*4+c])-int(p[(i*256+255)*4+c]))<24);
+ QVERIFY(std::abs(int(p[i*4+c])-int(p[((255*256)+i)*4+c]))<24);
+ }
+ }
+ }
void coversUseBoundedIndependentPixels() {
CoverTexture cover;QImage input(1200,600,QImage::Format_RGBA8888);input.fill(Qt::red);cover.setProperty("artwork",input);
QCOMPARE(cover.size(),QSize(512,512));QCOMPARE(cover.textureData().size(),512*512*4);
diff --git a/src/main.cpp b/src/main.cpp
index 45611ab..5011eb7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,9 +1,11 @@
#ifdef SPUN_WITH_3D
#include "deckgeometry.h"
#include "mediageometry.h"
+#include "cablegeometry.h"
#include <QtQuick3D/qquick3d.h>
#endif
#include "player.h"
+#include "tx6.h"
#include "tapesound.h"
#include "vinylnoise.h"
#include "library.h"
@@ -16,6 +18,10 @@
#include "threedtest.h"
#include "recordertest.h"
#include "turntabletest.h"
+#include "cassettedecktest.h"
+#include "cddecktest.h"
+#include "tx6test.h"
+#include "performancetest.h"
#include "testinput.h"
#endif
#include "lyrics.h"
@@ -109,6 +115,11 @@ public:
}
bool hyprland() const { return !qEnvironmentVariableIsEmpty("HYPRLAND_INSTANCE_SIGNATURE"); }
bool supportsBlur() const { return hyprland() && QGuiApplication::platformName() == "wayland"; }
+ Q_INVOKABLE void setSliderEndpoint(QObject *slider, bool end) {
+ // Like Slider::increase(), use the native setter without replacing
+ // the QML binding that follows playback position or remote volume.
+ if (slider) slider->setProperty("value", slider->property(end ? "to" : "from"));
+ }
Q_INVOKABLE void effects(QWindow *window, bool blur) {
m_window = window; m_blur = blur;
m_effectTimer.start(80);
@@ -129,7 +140,7 @@ public:
const bool mini = window->property("miniMode").toBool();
const bool cassette=window->property("cassette").toBool();
const bool recorder=window->property("recorder").toBool();
- const int targetWidth = mini ? 300 : queue ? 860 : 530;
+ const int targetWidth = window->property("layoutWidth").toInt();
const int targetHeight = window->property("layoutHeight").toInt();
const qreal scale=qBound(.5,window->property("uiScale").toDouble(),1.5);
QTransform zoom;zoom.scale(scale,scale);
@@ -180,18 +191,23 @@ public:
if(window->property("discFlipped").toBool())housing.addRoundedRect(QRectF(87,104,357,387),5,5);
else if(recorder)housing.addRoundedRect(QRectF(95,85,321,420),12,12);
else if(cassette)housing.addRoundedRect(QRectF(58,151,414,295),28,28);
- else housing.addRoundedRect(QRectF(45,74,440,440),window->property("vinyl").toBool()?28:220,window->property("vinyl").toBool()?28:220);
+ else if(window->property("cd").toBool())housing.addRoundedRect(QRectF(54,83,422,445),7,7);
+ else housing.addRoundedRect(QRectF(45,74,440,440),28,28);
region=QRegion(housing.toFillPolygon().toPolygon());
if(cassette)if(auto *seek=window->findChild<QQuickItem *>("cassetteSeek"))region|=itemRegion(seek);
if(window->property("swapRunning").toBool())region|=QRegion(45,74,440,440);
}
- if(window->property("threeDActive").toBool())region=QRegion(12,62,506,460);
+ if(window->property("tx6Visible").toBool())region|=QRegion(20,68,495,435);
+ if(window->property("threeDActive").toBool()) {
+ if(auto *scene=window->findChild<QQuickItem *>("scene3DLoader"))region=itemRegion(scene);
+ }
+ if(recorder&&!mini)if(auto *toggle=window->findChild<QQuickItem *>("tx6Toggle"))region|=itemRegion(toggle);
if(!cassette && !recorder && !body && !window->property("threeDActive").toBool())region -= window->property("vinyl").toBool()?QRegion(259,288,12,12,QRegion::Ellipse):QRegion(243,272,44,44,QRegion::Ellipse);
if (auto *bar = window->findChild<QQuickItem *>("sourceBar"))
region |= itemRegion(bar);
if (auto *deck = window->findChild<QQuickItem *>("playerDeck"))
region |= itemRegion(deck);
- region |= QRegion(65, 701, 400, 26);
+ if(auto *demo=window->findChild<QQuickItem *>("demoHint"))region|=itemRegion(demo);
if (auto *notice=window->findChild<QQuickItem *>("actionNotice"); notice && notice->isVisible())
region |= itemRegion(notice);
// Error notices can overlap the otherwise click-through perimeter.
@@ -610,6 +626,7 @@ static int exercise(Player &player, Theme &theme, Lyrics &lyrics, QQuickWindow *
auto *preferencesAction=window->findChild<QObject *>("preferencesAction");
auto *menuContent=preferencesAction ? preferencesAction->property("contentItem").value<QObject *>() : nullptr;
check(menuContent && menuContent->property("item").value<QObject *>(), "opening a menu creates its visible label and icon content");
+ check(settingsPopup&&settingsPopup->property("currentIndex").toInt()==0&&window->activeFocusItem()&&window->activeFocusItem()->property("text").toString()=="Add tracks","opening settings focuses its first action");
const auto menuVolume=player.volume();
testKeyClick(window,Qt::Key_Down);testKeyClick(window,Qt::Key_Down);
check(settingsPopup&&settingsPopup->property("currentIndex").toInt()>=0&&player.volume()==menuVolume,"menu arrow navigation moves focus without changing playback volume");
@@ -658,6 +675,13 @@ static int exercise(Player &player, Theme &theme, Lyrics &lyrics, QQuickWindow *
check(player.motion()!=priorMotion,"Preferences switch toggles its setting with Space");
testKeyClick(window,Qt::Key_Space);
check(player.motion()==priorMotion,"Preferences switch restores its setting with the keyboard");
+ testKeyClick(window,Qt::Key_Return);
+ check(player.motion()!=priorMotion,"Enter toggles the focused switch once");
+ testKeyClick(window,Qt::Key_Enter);
+ check(player.motion()==priorMotion,"keypad Enter toggles the focused switch once");
+ QKeyEvent heldEnter(QEvent::KeyPress,Qt::Key_Return,Qt::NoModifier,QString(),true);
+ QGuiApplication::sendEvent(window,&heldEnter);
+ check(player.motion()==priorMotion,"holding Enter does not repeatedly toggle the switch");
} else check(false,"Preferences motion switch exists");
click("fontChoice");
auto *picker = window->findChild<QObject *>("fontPicker");
@@ -742,6 +766,15 @@ static int exercise(Player &player, Theme &theme, Lyrics &lyrics, QQuickWindow *
check(player.volume()>.5,"focused volume slider receives Right instead of the global seek shortcut");
testKeyClick(window,Qt::Key_Left);
check(qAbs(player.volume()-.5)<.01,"focused volume slider receives Left and restores the previous level");
+ const double step=volumeControl->property("stepSize").toDouble();
+ testKeyClick(window,Qt::Key_Up);
+ check(qAbs(player.volume()-(.5+step))<.001,"focused slider Up uses its own step rather than the global volume shortcut");
+ testKeyClick(window,Qt::Key_Down);
+ check(qAbs(player.volume()-.5)<.001,"focused slider Down restores its value");
+ testKeyClick(window,Qt::Key_End);check(qAbs(player.volume()-1)<.001,"End selects the slider maximum");
+ testKeyClick(window,Qt::Key_Home);check(player.volume()==0,"Home selects the slider minimum");
+ player.setVolume(.37);
+ check(qAbs(volumeControl->property("value").toDouble()-.37)<.001,"Home and End preserve the slider binding to later source updates");
player.setVolume(originalVolume);
click("ciderSourceButton"); check(window->property("useCider").toBool(), "Cider source selector");
click("localSourceButton"); check(!window->property("useCider").toBool(), "local source selector");
@@ -1521,7 +1554,7 @@ int main(int argc, char **argv) {
for (int i=1; i<argc; ++i) {
const QByteArray option = QByteArray(argv[i]).split('=').first();
if (option == "--") break;
- if (option == "--self-test" || option == "--test-turntable" || option == "--test-recorder" || option == "--test-media-ui" || option == "--test-artwork" || option == "--test-3d-lighting" || option == "--test-3d-ui" || option == "--test-3d-library" || option == "--test-import-ui" || option == "--test-library" || option == "--smoke-live"
+ if (option == "--test-performance" || option == "--self-test" || option == "--test-tx6" || option == "--test-cd-deck" || option == "--test-cassette-deck" || option == "--test-turntable" || option == "--test-recorder" || option == "--test-media-ui" || option == "--test-artwork" || option == "--test-3d-lighting" || option == "--test-3d-ui" || option == "--test-3d-library" || option == "--test-import-ui" || option == "--test-library" || option == "--smoke-live"
|| option == "--verify-cider" || option == "--verify-cider-writes" || option == "--inspect-cider" || option == "--inspect-library") {
const auto executable = QFileInfo(QStringLiteral("/proc/self/exe")).symLinkTarget();
const auto diagnostics = QFile::encodeName(QFileInfo(executable).absolutePath() + "/spun-diagnostics");
@@ -1541,6 +1574,16 @@ int main(int argc, char **argv) {
if (!qEnvironmentVariableIsSet("QT_FFMPEG_ENCODING_HW_DEVICE_TYPES"))
qputenv("QT_FFMPEG_ENCODING_HW_DEVICE_TYPES", ",");
QGuiApplication app(argc, argv);
+ // Some Wayland/OpenGL integrations default to Qt's basic 16 ms animation
+ // driver. Use the vsync-driven loop for the native hardware renderer.
+ // Keep software rendering and explicit compatibility overrides intact.
+ if (QGuiApplication::platformName().startsWith("wayland")
+ && !qEnvironmentVariableIsSet("QSG_RENDER_LOOP")
+ && !qEnvironmentVariableIsSet("QML_BAD_GUI_RENDER_LOOP")
+ && qEnvironmentVariable("QT_QUICK_BACKEND") != "software"
+ && qEnvironmentVariable("LIBGL_ALWAYS_SOFTWARE") != "1"
+ && qEnvironmentVariable("QT_OPENGL") != "software")
+ qputenv("QSG_RENDER_LOOP", "threaded");
#ifdef SPUN_WITH_3D
QSurfaceFormat::setDefaultFormat(QQuick3D::idealSurfaceFormat());
#endif
@@ -1551,12 +1594,17 @@ int main(int argc, char **argv) {
QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption();
parser.addOption({"benchmark", "Measure an isolated startup, idle, playing, mini, or cycle scene", "scene"});
parser.addOption({"benchmark-medium", "Appearance for isolated measurements", "medium", "cd"});
+ parser.addOption({"benchmark-3d", "Measure the native 3D asset rather than its 2D face"});
parser.addOption({"test-library", "Run isolated music browser checks"});
parser.addOption({"self-test", "Run isolated playback and UI checks"});
parser.addOption({"test-artwork", "Verify artwork updates across playback sources and physical media"});
parser.addOption({"test-3d-lighting", "Verify live palette changes in rendered 3D pixels"});
parser.addOption({"test-3d-ui", "Run isolated native 3D interaction and lifecycle checks"});
parser.addOption({"test-3d-library", "Run isolated library checks with 3D enabled"});
+ parser.addOption({"test-performance", "Measure isolated mode switches and display frame pacing"});
+ parser.addOption({"test-tx6", "Verify TX-6 mixer DSP, controls and rendering"});
+ parser.addOption({"test-cd-deck", "Verify CD deck controls, lid, rotation and seeking"});
+ parser.addOption({"test-cassette-deck", "Verify cassette deck controls, rotation and door mechanics"});
parser.addOption({"test-turntable", "Verify 3D turntable hardware, motion and seeking"});
parser.addOption({"test-recorder", "Verify recorder playback, controls, seeking and renderer combinations"});
parser.addOption({"test-media-ui", "Run isolated vinyl and cassette interaction checks"});
@@ -1572,7 +1620,7 @@ int main(int argc, char **argv) {
parser.addPositionalArgument("files", "Music files or album folders to play", "[files…]");
parser.process(app);
if (parser.isSet("export-cover")) return Disc::fallbackArt().save(parser.value("export-cover")) ? 0 : 1;
- const bool test = parser.isSet("test-turntable") || parser.isSet("test-recorder") || parser.isSet("test-artwork") || parser.isSet("test-3d-lighting") || parser.isSet("test-3d-ui") || parser.isSet("test-3d-library") || parser.isSet("test-media-ui") || parser.isSet("benchmark") || parser.isSet("test-import-ui") || parser.isSet("self-test") || parser.isSet("smoke-live") || parser.isSet("test-library");
+ const bool test = parser.isSet("test-performance") || parser.isSet("test-tx6") || parser.isSet("test-cd-deck") || parser.isSet("test-cassette-deck") || parser.isSet("test-turntable") || parser.isSet("test-recorder") || parser.isSet("test-artwork") || parser.isSet("test-3d-lighting") || parser.isSet("test-3d-ui") || parser.isSet("test-3d-library") || parser.isSet("test-media-ui") || parser.isSet("benchmark") || parser.isSet("test-import-ui") || parser.isSet("self-test") || parser.isSet("smoke-live") || parser.isSet("test-library");
if(test && qEnvironmentVariableIsSet("SPUN_TEST_SCREEN"))app.setDesktopFileName("spun-diagnostics");
if (!test && !parser.isSet("config")) {
auto bus = QDBusConnection::sessionBus();
@@ -1606,6 +1654,7 @@ int main(int argc, char **argv) {
const qint64 fontReady = startup.elapsed();
Theme theme(configRoot, stateRoot);
Player player(settings);
+ Tx6 tx6(&player,settings,!test || qEnvironmentVariableIsSet("SPUN_TEST_MIXER_OUTPUT"));
Cider cider(!test, QFileInfo(settings).absolutePath() + "/cider-connection.json");
Lyrics lyrics(&player, &cider);
Library library(&cider);
@@ -1619,8 +1668,11 @@ int main(int argc, char **argv) {
qmlRegisterType<Symbol>("Spun", 1, 0, "Symbol");
#ifdef SPUN_WITH_3D
+ qmlRegisterType<CableGeometry>("Spun",1,0,"CableGeometry");
qmlRegisterType<DeckGeometry>("Spun",1,0,"DeckGeometry");
qmlRegisterType<RecordGeometry>("Spun",1,0,"RecordGeometry");
+ qmlRegisterType<CassetteGearGeometry>("Spun",1,0,"CassetteGearGeometry");
+ qmlRegisterType<CassettePlateGeometry>("Spun",1,0,"CassettePlateGeometry");
qmlRegisterType<ReelGeometry>("Spun",1,0,"ReelGeometry");
qmlRegisterType<TurntableDetailGeometry>("Spun",1,0,"TurntableDetailGeometry");
qmlRegisterType<CoverTexture>("Spun",1,0,"CoverTexture");
@@ -1645,6 +1697,7 @@ int main(int argc, char **argv) {
#endif
engine.rootContext()->setContextProperty("player3DUrl", QUrl(QStringLiteral("qrc:/qml/Player3D.qml")));
engine.rootContext()->setContextProperty("player", &player);
+ engine.rootContext()->setContextProperty("tx6", &tx6);
engine.rootContext()->setContextProperty("theme", &theme);
engine.rootContext()->setContextProperty("typography", &typography);
engine.rootContext()->setContextProperty("native", &native);
@@ -1659,8 +1712,10 @@ int main(int argc, char **argv) {
engine.rootContext()->setContextProperty("testMode", test);
const auto benchmarkMedium = parser.value("benchmark-medium");
if (parser.isSet("benchmark")) {
- if (!QStringList{"cd","vinyl","cassette","tp7"}.contains(benchmarkMedium)) return 2;
- player.setMedium(benchmarkMedium);
+ if (!QStringList{"cd","vinyl","cassette","tp7","tx6"}.contains(benchmarkMedium)) return 2;
+ player.setMedium(benchmarkMedium=="tx6"?"tp7":benchmarkMedium);
+ player.setThreeD(parser.isSet("benchmark-3d"));
+ tx6.setVisible(benchmarkMedium=="tx6");
}
QList<double> frameIntervals;
qint64 lastFrameNs = 0;
@@ -1711,23 +1766,51 @@ int main(int argc, char **argv) {
player.demo();
window->setProperty("progress", 0.75);
}
+ if (parser.isSet("benchmark-3d") && scene=="idle") {
+ player.demo();
+ QTimer::singleShot(500,&player,&Player::pause);
+ }
if (scene == "mini") player.setMiniMode(true);
if (scene == "cycle") {
QTimer::singleShot(250,&app,[&]{player.setMedium("vinyl");});
QTimer::singleShot(650,&app,[&]{player.setMedium("cassette");});
- QTimer::singleShot(1100,&app,[&]{player.setMedium(benchmarkMedium);});
+ QTimer::singleShot(1100,&app,[&]{player.setMedium(benchmarkMedium=="tx6"?"tp7":benchmarkMedium);});
}
- QTimer::singleShot(2000, &app, [&, scene] {
+ const auto renderStats=[window]() -> QObject * {
+ auto *view=window->findChild<QObject *>("player3DView");
+ return view?view->property("renderStats").value<QObject*>():nullptr;
+ };
+ if(parser.isSet("benchmark-3d"))QTimer::singleShot(1000,&app,[renderStats] {
+ if(auto *stats=renderStats();stats&&stats->metaObject()->indexOfProperty("extendedDataCollectionEnabled")>=0)
+ stats->setProperty("extendedDataCollectionEnabled",true);
+ });
+ auto *settleTimer = new QTimer(&app);
+ settleTimer->setInterval(100);
+ QObject::connect(settleTimer, &QTimer::timeout, &app, [&, scene, renderStats, settleTimer] {
+ // Cold 3D shader compilation can outlast a fixed startup delay.
+ if (firstFrame < 0 || startup.elapsed()-firstFrame < 1500) return;
+ settleTimer->stop();
+ settleTimer->deleteLater();
+ frameIntervals.clear();
+ lastFrameNs = 0;
+ const auto measurementStart = startup.elapsed();
struct rusage before{}; getrusage(RUSAGE_SELF, &before);
const int startFrames = frames;
- QTimer::singleShot(6000, &app, [&, scene, before, startFrames] {
+ QTimer::singleShot(6000, &app, [&, scene, before, startFrames, renderStats, measurementStart] {
struct rusage after{}; getrusage(RUSAGE_SELF, &after);
auto cpu = [](const rusage &r) { return r.ru_utime.tv_sec + r.ru_stime.tv_sec + (r.ru_utime.tv_usec + r.ru_stime.tv_usec) / 1e6; };
QFile memory("/proc/self/smaps_rollup");
if (!memory.open(QIODevice::ReadOnly)) { app.exit(1); return; }
- QJsonObject result{{"scene",scene},{"firstFrameMs",firstFrame},{"cpuSeconds",cpu(after)-cpu(before)},
+ QJsonObject result{{"scene",scene},{"firstFrameMs",firstFrame},{"measurementStartMs",measurementStart},{"cpuSeconds",cpu(after)-cpu(before)},
{"frames",frames-startFrames},{"memory",QString::fromUtf8(memory.readAll())},
{"medium",benchmarkMedium},{"objects",window->findChildren<QObject *>().size()}};
+ result["threeDActive"]=window->property("threeDActive").toBool();
+ if(parser.isSet("benchmark-3d"))if(auto *stats=renderStats()) {
+ QJsonObject rendering;
+ for(const char *property:{"drawCallCount","drawVertexCount","imageDataSize","meshDataSize","renderPassCount","lastCompletedGpuTime"})
+ if(stats->metaObject()->indexOfProperty(property)>=0)rendering[property]=QJsonValue::fromVariant(stats->property(property));
+ result["rendering"]=rendering;
+ }
std::sort(frameIntervals.begin(),frameIntervals.end());
if (!frameIntervals.isEmpty()) {
result["frameMedianMs"] = frameIntervals[frameIntervals.size()/2];
@@ -1737,6 +1820,7 @@ int main(int argc, char **argv) {
app.quit();
});
});
+ settleTimer->start();
}
#ifdef SPUN_DIAGNOSTICS
else if (parser.isSet("inspect-library")) QTimer::singleShot(650, &app, [&] {
@@ -2080,6 +2164,10 @@ int main(int argc, char **argv) {
std::cout << "RESULT " << failures << " failures" << std::endl;
app.exit(failures ? 1 : 0);
});
+ else if (parser.isSet("test-performance")) QTimer::singleShot(650, &app, [&] { app.exit(exercisePerformance(player,window,parser.value("capture-dir"))); });
+ else if (parser.isSet("test-tx6")) QTimer::singleShot(650, &app, [&] { app.exit(exerciseTx6(player,tx6,window,temp.path(),parser.value("capture-dir"))); });
+ else if (parser.isSet("test-cd-deck")) QTimer::singleShot(650, &app, [&] { app.exit(exerciseCdDeck(player,window,temp.path(),parser.value("capture-dir"))); });
+ else if (parser.isSet("test-cassette-deck")) QTimer::singleShot(650, &app, [&] { app.exit(exerciseCassetteDeck(player,window,temp.path(),parser.value("capture-dir"))); });
else if (parser.isSet("test-turntable")) QTimer::singleShot(650, &app, [&] { app.exit(exerciseTurntable(player,window,temp.path(),parser.value("capture-dir"))); });
else if (parser.isSet("test-recorder")) QTimer::singleShot(650, &app, [&] { app.exit(exerciseRecorder(player,window,temp.path(),parser.value("capture-dir"))); });
else if (parser.isSet("test-artwork")) QTimer::singleShot(650, &app, [&] { app.exit(exerciseArtwork(player,window,temp.path(),parser.value("capture-dir"))); });
diff --git a/src/mediageometry.cpp b/src/mediageometry.cpp
index 518a98e..c2ebf9e 100644
--- a/src/mediageometry.cpp
+++ b/src/mediageometry.cpp
@@ -42,8 +42,47 @@ void upload(QQuick3DGeometry *geometry,const QByteArray &data,QVector3D low,QVec
geometry->setBounds(low,high);geometry->update();
}
}
+CassettePlateGeometry::CassettePlateGeometry(QQuick3DObject *parent):QQuick3DGeometry(parent) {
+ // A stamped carrier with open service slots, not dark rectangles painted on
+ // a solid face. Only exposed edges have walls, so adjacent cells cannot flicker.
+ constexpr float xs[]={-128,-109,-76,-55,-29,-10,35,60,101,128};
+ constexpr float ys[]={-55,-31,-7,15,36,55};
+ const auto filled=[](int x,int y) {
+ if(x<0||x>=9||y<0||y>=5)return false;
+ return !((x==1&&y>=2&&y<=3)||(x==3&&y==1)||(x==6&&y>=1&&y<=3)||(x>=6&&y==0));
+ };
+ QByteArray data;
+ const auto quad=[&](QVector3D a,QVector3D b,QVector3D c,QVector3D d){triangle(data,a,b,c,130);triangle(data,a,c,d,130);};
+ for(int y=0;y<5;++y)for(int x=0;x<9;++x)if(filled(x,y)) {
+ const float l=xs[x],r=xs[x+1],b=ys[y],t=ys[y+1],z=1.5f;
+ quad({l,b,z},{r,b,z},{r,t,z},{l,t,z});
+ quad({l,t,-z},{r,t,-z},{r,b,-z},{l,b,-z});
+ if(!filled(x-1,y))quad({l,b,-z},{l,b,z},{l,t,z},{l,t,-z});
+ if(!filled(x+1,y))quad({r,t,-z},{r,t,z},{r,b,z},{r,b,-z});
+ if(!filled(x,y-1))quad({r,b,-z},{r,b,z},{l,b,z},{l,b,-z});
+ if(!filled(x,y+1))quad({l,t,-z},{l,t,z},{r,t,z},{r,t,-z});
+ }
+ upload(this,data,{-128,-55,-1.5f},{128,55,1.5f});
+}
+
+CassetteGearGeometry::CassetteGearGeometry(QQuick3DObject *parent):QQuick3DGeometry(parent) {
+ QByteArray vertices;
+ constexpr int count=24*4;
+ const auto point=[](int i,float radius,float z){const float a=i*2*float(M_PI)/count;return QVector3D(radius*std::cos(a),radius*std::sin(a),z);};
+ const auto quad=[&](QVector3D a,QVector3D b,QVector3D c,QVector3D d){triangle(vertices,a,b,c,20);triangle(vertices,a,c,d,20);};
+ for(int i=0;i<count;++i) {
+ const float r=i%4==0||i%4==3?17.5f:20.f,r2=(i+1)%4==0||(i+1)%4==3?17.5f:20.f;
+ quad(point(i,3,2),point(i,r,2),point(i+1,r2,2),point(i+1,3,2));
+ quad(point(i+1,3,-2),point(i+1,r2,-2),point(i,r,-2),point(i,3,-2));
+ quad(point(i,r,-2),point(i+1,r2,-2),point(i+1,r2,2),point(i,r,2));
+ quad(point(i,3,2),point(i+1,3,2),point(i+1,3,-2),point(i,3,-2));
+ }
+ upload(this,vertices,{-20,-20,-2},{20,20,2});
+}
+
RecordGeometry::RecordGeometry(QQuick3DObject *parent):QQuick3DGeometry(parent){connect(this,&RecordGeometry::shapeChanged,this,&RecordGeometry::rebuild);rebuild();}
void RecordGeometry::rebuild() {
+ if(m_initializing)return;
const float radius=qBound(1.f,m_radius,300.f),hole=qBound(.1f,m_hole,radius-.1f),depth=qBound(.05f,m_depth,60.f);
QByteArray data;const int radial=m_grooves?80:1,segments=qBound(24,int(std::ceil(radius*1.1f)),128);
constexpr float grooveHeight=.012f;
@@ -66,6 +105,7 @@ TurntableDetailGeometry::TurntableDetailGeometry(QQuick3DObject *parent):QQuick3
connect(this,&TurntableDetailGeometry::shapeChanged,this,&TurntableDetailGeometry::rebuild);rebuild();
}
void TurntableDetailGeometry::rebuild() {
+ if(m_initializing)return;
QByteArray data;
const auto quad=[&](QVector3D a,QVector3D b,QVector3D c,QVector3D d) {triangle(data,a,b,c,300);triangle(data,a,c,d,300);};
if(m_fascia) {
@@ -141,8 +181,9 @@ ReelGeometry::ReelGeometry(QQuick3DObject *parent):QQuick3DGeometry(parent) {
upload(this,data,{-32,-32,-z},{32,32,z});
}
-CoverTexture::CoverTexture(QObject *parent):QObject(parent){connect(this,&CoverTexture::artworkChanged,this,&CoverTexture::rebuild);rebuild();}
+CoverTexture::CoverTexture(QObject *parent):QObject(parent){connect(this,&CoverTexture::artworkChanged,this,&CoverTexture::rebuild);}
void CoverTexture::rebuild(){
+ if(m_initializing)return;
QImage image=m_artwork.isNull()?Disc::placeholderArt(512):m_artwork;
const int side=qMin(image.width(),image.height());image=image.copy((image.width()-side)/2,(image.height()-side)/2,side,side).scaled(512,512,Qt::KeepAspectRatio,Qt::SmoothTransformation).convertToFormat(QImage::Format_RGBA8888);
if(m_paper) {
@@ -170,12 +211,20 @@ void CoverTexture::rebuild(){
}
WaveGeometry::WaveGeometry(QQuick3DObject *parent):QQuick3DGeometry(parent){connect(this,&WaveGeometry::shapeChanged,this,&WaveGeometry::rebuild);rebuild();}
void WaveGeometry::rebuild(){
+ if(m_initializing)return;
QByteArray data;const float progress=qBound(0.f,m_progress,1.f);const int count=qMax(1,int(256*progress));
+ data.reserve(count*6*sizeof(Vertex));
const auto p=[&](float f,float side){const float wave=std::sin(f*(m_linear?45.f:150.f)+m_phase)*m_amplitude;
if(m_linear)return QVector3D(-123+246*f,-125+wave+side,5);
const float a=f*2*float(M_PI),r=186+wave+side;return QVector3D(r*std::sin(a),r*std::cos(a),5);
};
- for(int i=0;i<count;++i){const float a=progress*i/count,b=progress*(i+1)/count;triangle(data,p(a,-1.3f),p(b,-1.3f),p(b,1.3f),200);triangle(data,p(a,-1.3f),p(b,1.3f),p(a,1.3f),200);}
+ auto al=p(0,-1.3f),ar=p(0,1.3f);
+ for(int i=0;i<count;++i){
+ const float b=progress*(i+1)/count;
+ const auto bl=p(b,-1.3f),br=p(b,1.3f);
+ triangle(data,al,bl,br,200);triangle(data,al,br,ar,200);
+ al=bl;ar=br;
+ }
upload(this,data,{-200,-200,4},{200,200,6});
}
@@ -183,6 +232,7 @@ StudioTexture::StudioTexture(QQuick3DObject *parent):QQuick3DTextureData(parent)
connect(this,&StudioTexture::tintChanged,this,&StudioTexture::rebuild);rebuild();
}
void StudioTexture::rebuild() {
+ if(m_initializing)return;
// RGBE preserves bright reflection sources in four bytes per pixel. The
// probe is rebuilt only when the wallpaper accent changes.
constexpr int width=512,height=256;
@@ -190,17 +240,23 @@ void StudioTexture::rebuild() {
auto *out=reinterpret_cast<unsigned char*>(pixels.data());
const QColor tint=m_tint.isValid()?m_tint:QColor(Qt::white);
const QColor bounce=QColor::fromHsvF(qMax(0.,tint.hsvHueF()),qMin(.55,tint.hsvSaturationF()*1.5),1);
- for(int y=0;y<height;++y)for(int x=0;x<width;++x) {
- const double u=(x+.5)/width,v=(y+.5)/height;
+ for(int y=0;y<height;++y) {
+ const double v=(y+.5)/height;
+ const double ambient=.045+qBound(0.f,m_ambientLift,.5f)+.2*std::pow(1-v,2);
+ const double ceiling=.85*std::exp(-2*std::pow(v/.13,4));
+ for(int x=0;x<width;++x) {
+ const double u=(x+.5)/width;
const auto strip=[&](double center,double elevation,double breadth,double tallness) {
const double dx=qMin(std::abs(u-center),1-std::abs(u-center))/breadth;
const double dy=(v-elevation)/tallness;
return std::exp(-2*(dx*dx*dx*dx+dy*dy*dy*dy));
};
- const double key=2.8*strip(.18,.34,.065,.27);
- const double fill=1.1*strip(.73,.38,.17,.10);
- const double ambient=.055+.23*std::pow(1-v,2);
- const double base=ambient+key;
+ // Broad neutral softboxes retain silver highlights, with a narrow edge
+ // reflection and wallpaper-colored bounce. No extra scene lights/passes.
+ const double key=2.65*strip(.18,.30,.11,.22);
+ const double edge=1.55*strip(.46,.37,.026,.21);
+ const double fill=1.05*strip(.73,.39,.17,.15);
+ const double base=ambient+key+edge+ceiling;
const double r=base+fill*(.18+.82*bounce.redF())+ambient*.35*bounce.redF();
const double g=base+fill*(.18+.82*bounce.greenF())+ambient*.35*bounce.greenF();
const double b=base+fill*(.18+.82*bounce.blueF())+ambient*.35*bounce.blueF();
@@ -209,6 +265,7 @@ void StudioTexture::rebuild() {
const int offset=(y*width+x)*4;
out[offset]=qBound(0,int(r*scale),255);out[offset+1]=qBound(0,int(g*scale),255);
out[offset+2]=qBound(0,int(b*scale),255);out[offset+3]=exponent+128;
+ }
}
setSize(QSize(width,height));setFormat(RGBE8);setHasTransparency(false);setTextureData(pixels);
}
@@ -217,53 +274,82 @@ SurfaceTexture::SurfaceTexture(QQuick3DObject *parent):QQuick3DTextureData(paren
connect(this,&SurfaceTexture::kindChanged,this,&SurfaceTexture::rebuild);rebuild();
}
void SurfaceTexture::rebuild() {
+ if(m_initializing)return;
// Small deterministic material maps, generated once per material rather
// than every frame. Geometry supplies the silhouette and physical grooves.
const int size=(m_kind=="vinyl-normal"||m_kind=="lacquer")?1024:m_kind=="powder"?512:256;
- QImage image(size,size,QImage::Format_RGBA8888);
+ QByteArray pixels(size*size*4,Qt::Uninitialized);
+ auto *out=reinterpret_cast<unsigned char*>(pixels.data());
+ // Resolve the material once; per-pixel QString comparisons otherwise
+ // dominate these small maps. Bytes stay in the same RGBA8 layout.
+ static const QStringList kinds={"vinyl-normal","lacquer","powder","disc","knurled-normal","leather-normal","turned-normal","bead-normal","metal-normal","brushed","turned","satin","vinyl","paper"};
+ const int kind=kinds.indexOf(m_kind);
const auto noise=[](unsigned x,unsigned y){unsigned n=x*374761393u+y*668265263u;n=(n^(n>>13))*1274126177u;return int((n^(n>>16))&255);};
+ // Periodic, smoothly interpolated grain avoids blocky patches and seams.
+ const auto grain=[&](double x,double y,int cells) {
+ x=x/size*cells;y=y/size*cells;
+ const int ix=int(std::floor(x)),iy=int(std::floor(y));
+ const auto wrap=[&](int n){return (n%cells+cells)%cells;};
+ const auto sample=[&](int a,int b){return noise(wrap(a),wrap(b))/255.;};
+ double u=x-ix,v=y-iy;u=u*u*(3-2*u);v=v*v*(3-2*v);
+ return (1-v)*((1-u)*sample(ix,iy)+u*sample(ix+1,iy))+v*((1-u)*sample(ix,iy+1)+u*sample(ix+1,iy+1));
+ };
+ const auto encodedNormal=[](double x,double y) {
+ const auto n=QVector3D(x,y,1).normalized();
+ return QColor(qRound((n.x()+1)*127.5),qRound((n.y()+1)*127.5),qRound((n.z()+1)*127.5));
+ };
for(int y=0;y<size;++y)for(int x=0;x<size;++x) {
QColor color;
- if(m_kind=="vinyl-normal") {
+ if(kind==0) {
const double dx=x-(size-1)*.5,dy=y-(size-1)*.5,r=std::hypot(dx,dy);
const double slope=.16*std::sin(r*2*M_PI*180/(size*.5));
const auto n=QVector3D(r>0?slope*dx/r:0,r>0?slope*dy/r:0,1).normalized();
color=QColor(qRound((n.x()+1)*127.5),qRound((n.y()+1)*127.5),qRound((n.z()+1)*127.5));
- } else if(m_kind=="lacquer") {
+ } else if(kind==1) {
const double r=std::hypot(x-(size-1)*.5,y-(size-1)*.5)/(size*.5);
- const int value=199+qRound(9*std::sin(r*71)+3*std::sin(r*311))+noise(x/12,y/12)/64;
+ const int value=211+qRound(7*std::sin(r*71)+3*std::sin(r*311)+3*grain(x,y,48));
color=QColor(value,value,value);
- } else if(m_kind=="powder") {
- const int value=205+noise(x,y)/12+noise(x/8,y/8)/32;
+ } else if(kind==2) {
+ const int value=218+qRound(12*grain(x,y,96)+5*grain(x,y,24));
color=QColor(value,value,value);
- } else if(m_kind=="disc") {
+ } else if(kind==3) {
const double a=std::atan2(y-127.5,x-127.5);
const double hue=(a+M_PI)/(2*M_PI);
color=QColor::fromHsvF(hue,.18,.88+.06*std::sin(a*3));
- } else if(m_kind=="knurled-normal") {
- const float a=x*float(M_PI)/8,b=y*float(M_PI)/16;
- const auto n=QVector3D(.32f*std::sin(a)*std::cos(b),.16f*std::cos(a)*std::sin(b),1).normalized();
- color=QColor(qRound((n.x()+1)*127.5),qRound((n.y()+1)*127.5),qRound((n.z()+1)*127.5));
- } else if(m_kind=="bead-normal") {
+ } else if(kind==4) {
+ const double a=x*M_PI/4,b=y*M_PI/8;
+ color=encodedNormal(.25*std::sin(a)*std::cos(b),.25*std::cos(a)*std::sin(b));
+ } else if(kind==5) {
+ const auto height=[&](double a,double b) {
+ const double cell=grain(a,b,32);
+ return .7*std::pow(std::abs(cell-.5)*2,.65)+.12*grain(a,b,96);
+ };
+ color=encodedNormal((height(x-1,y)-height(x+1,y))*.7,(height(x,y-1)-height(x,y+1))*.7);
+ } else if(kind==6) {
+ const double dx=x-(size-1)*.5,dy=y-(size-1)*.5,r=std::hypot(dx,dy);
+ const double slope=.075*std::sin(r*2*M_PI/3.2);
+ color=encodedNormal(r>0?slope*dx/r:0,r>0?slope*dy/r:0);
+ } else if(kind==7) {
const float sx=(noise((x+1)%256,y)-noise((x+255)%256,y))/2048.f;
const float sy=(noise(x,(y+1)%256)-noise(x,(y+255)%256))/2048.f;
const auto n=QVector3D(sx,sy,1).normalized();
color=QColor(qRound((n.x()+1)*127.5),qRound((n.y()+1)*127.5),qRound((n.z()+1)*127.5));
- } else if(m_kind=="metal-normal") {
+ } else if(kind==8) {
const float slope=(noise(0,(y+1)%256)-noise(0,(y+255)%256))/1024.f;
const auto n=QVector3D(0,slope,1).normalized();
color=QColor(qRound((n.x()+1)*127.5),qRound((n.y()+1)*127.5),qRound((n.z()+1)*127.5));
} else {
int value=0;
- if(m_kind=="brushed")value=205+noise(0,y)/12+noise(x,y)/64;
- else if(m_kind=="turned") {const double r=std::hypot(x-127.5,y-127.5);value=188+int(12*std::sin(r*2.8))+noise(x,y)/32;}
- else if(m_kind=="vinyl") {const double r=std::hypot(x-127.5,y-127.5);value=210+int(4*std::sin(r*5))+noise(x,y)/64;}
- else if(m_kind=="paper")value=228+noise(x,y)/16+noise(x/3,y/2)/32;
+ if(kind==9)value=219+noise(0,y)/16+qRound(6*grain(x,y,16));
+ else if(kind==10) {const double r=std::hypot(x-127.5,y-127.5);value=220+int(6*std::sin(r*2.8))+noise(x,y)/64;}
+ else if(kind==11)value=223+qRound(12*grain(x,y,40)+4*grain(x,y,12));
+ else if(kind==12) {const double r=std::hypot(x-127.5,y-127.5);value=210+int(4*std::sin(r*5))+noise(x,y)/64;}
+ else if(kind==13)value=228+noise(x,y)/16+noise(x/3,y/2)/32;
else value=222+noise(x,y)/32;
color=QColor(value,value,value);
}
- image.setPixelColor(x,y,color);
+ const int offset=(y*size+x)*4;
+ out[offset]=color.red();out[offset+1]=color.green();out[offset+2]=color.blue();out[offset+3]=color.alpha();
}
- setSize(image.size());setFormat(RGBA8);setHasTransparency(false);
- setTextureData(QByteArray(reinterpret_cast<const char*>(image.constBits()),image.sizeInBytes()));
+ setSize(QSize(size,size));setFormat(RGBA8);setHasTransparency(false);setTextureData(pixels);
}
diff --git a/src/mediageometry.h b/src/mediageometry.h
index f4be588..e0be89a 100644
--- a/src/mediageometry.h
+++ b/src/mediageometry.h
@@ -2,6 +2,7 @@
#include <QQuick3DGeometry>
#include <QQuick3DTextureData>
#include <QImage>
+#include <QQmlParserStatus>
class RecordGeometry : public QQuick3DGeometry {
Q_OBJECT
@@ -13,7 +14,11 @@ public:
explicit RecordGeometry(QQuick3DObject *parent=nullptr);
signals:
void shapeChanged();
+protected:
+ void classBegin() override { QQuick3DGeometry::classBegin(); m_initializing=true; }
+ void componentComplete() override { m_initializing=false; rebuild(); QQuick3DGeometry::componentComplete(); }
private:
+ bool m_initializing=false;
void rebuild();
float m_radius=176,m_hole=3,m_depth=2;
bool m_grooves=false;
@@ -24,6 +29,18 @@ public:
explicit ReelGeometry(QQuick3DObject *parent=nullptr);
};
+class CassetteGearGeometry : public QQuick3DGeometry {
+ Q_OBJECT
+public:
+ explicit CassetteGearGeometry(QQuick3DObject *parent=nullptr);
+};
+
+class CassettePlateGeometry : public QQuick3DGeometry {
+ Q_OBJECT
+public:
+ explicit CassettePlateGeometry(QQuick3DObject *parent=nullptr);
+};
+
class TurntableDetailGeometry : public QQuick3DGeometry {
Q_OBJECT
Q_PROPERTY(bool fascia MEMBER m_fascia NOTIFY shapeChanged)
@@ -31,13 +48,18 @@ public:
explicit TurntableDetailGeometry(QQuick3DObject *parent=nullptr);
signals:
void shapeChanged();
+protected:
+ void classBegin() override { QQuick3DGeometry::classBegin(); m_initializing=true; }
+ void componentComplete() override { m_initializing=false; rebuild(); QQuick3DGeometry::componentComplete(); }
private:
+ bool m_initializing=false;
void rebuild();
bool m_fascia=false;
};
-class CoverTexture : public QObject {
+class CoverTexture : public QObject, public QQmlParserStatus {
Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QQuick3DTextureData *texture READ texture NOTIFY textureChanged)
Q_PROPERTY(QImage artwork MEMBER m_artwork NOTIFY artworkChanged)
Q_PROPERTY(bool paper MEMBER m_paper NOTIFY artworkChanged)
@@ -45,14 +67,17 @@ class CoverTexture : public QObject {
Q_PROPERTY(QString artist MEMBER m_artist NOTIFY artworkChanged)
public:
explicit CoverTexture(QObject *parent=nullptr);
- QQuick3DTextureData *texture() const { return m_texture; }
- QSize size() const { return m_texture->size(); }
- QByteArray textureData() const { return m_texture->textureData(); }
+ QQuick3DTextureData *texture() { if(!m_texture && !m_initializing)rebuild(); return m_texture; }
+ QSize size() { const auto *t=texture(); return t?t->size():QSize(); }
+ QByteArray textureData() { const auto *t=texture(); return t?t->textureData():QByteArray(); }
+ void classBegin() override { m_initializing=true; }
+ void componentComplete() override { m_initializing=false; rebuild(); }
signals:
void artworkChanged();
void textureChanged();
private:
void rebuild();
+ bool m_initializing=false;
QQuick3DTextureData *m_texture=nullptr;
QImage m_artwork;
bool m_paper=false;
@@ -68,7 +93,11 @@ public:
explicit WaveGeometry(QQuick3DObject *parent=nullptr);
signals:
void shapeChanged();
+protected:
+ void classBegin() override { QQuick3DGeometry::classBegin(); m_initializing=true; }
+ void componentComplete() override { m_initializing=false; rebuild(); QQuick3DGeometry::componentComplete(); }
private:
+ bool m_initializing=false;
void rebuild();
float m_progress=0,m_phase=0,m_amplitude=0;
bool m_linear=false;
@@ -77,13 +106,19 @@ private:
class StudioTexture : public QQuick3DTextureData {
Q_OBJECT
Q_PROPERTY(QColor tint MEMBER m_tint NOTIFY tintChanged)
+ Q_PROPERTY(float ambientLift MEMBER m_ambientLift NOTIFY tintChanged)
public:
explicit StudioTexture(QQuick3DObject *parent=nullptr);
signals:
void tintChanged();
+protected:
+ void classBegin() override { QQuick3DTextureData::classBegin(); m_initializing=true; }
+ void componentComplete() override { m_initializing=false; rebuild(); QQuick3DTextureData::componentComplete(); }
private:
+ bool m_initializing=false;
void rebuild();
QColor m_tint=Qt::white;
+ float m_ambientLift=0;
};
class SurfaceTexture : public QQuick3DTextureData {
@@ -93,7 +128,11 @@ public:
explicit SurfaceTexture(QQuick3DObject *parent=nullptr);
signals:
void kindChanged();
+protected:
+ void classBegin() override { QQuick3DTextureData::classBegin(); m_initializing=true; }
+ void componentComplete() override { m_initializing=false; rebuild(); QQuick3DTextureData::componentComplete(); }
private:
+ bool m_initializing=false;
void rebuild();
QString m_kind="brushed";
};
diff --git a/src/mediauitest.cpp b/src/mediauitest.cpp
index 69d68f3..d7451e1 100644
--- a/src/mediauitest.cpp
+++ b/src/mediauitest.cpp
@@ -1,6 +1,8 @@
#include "mediauitest.h"
#include "player.h"
#include "disc.h"
+#include "theme.h"
+#include "testcapture.h"
#include <QQmlContext>
#include <QQuickWindow>
#include <QQuickItem>
@@ -9,6 +11,7 @@
#include <QElapsedTimer>
#include <QDir>
#include <QFile>
+#include <QSaveFile>
#include <taglib/fileref.h>
#include <taglib/tag.h>
#include <cmath>
@@ -49,6 +52,49 @@ int exerciseMediaUi(Player &player, QQuickWindow *window, const QString &temp, c
files.append(QUrl::fromLocalFile(path));
}
player.addUrls(files,false);check(wait([&]{return !player.busy();})&&player.count()==3,"album fixture imports three tracks");
+ // Check actual reverse pixels: valid theme properties alone missed a
+ // hardcoded silver backing behind light ink in the CD/cassette booklets.
+ {
+ auto *theme=qmlContext(window)->contextProperty("theme").value<Theme*>();
+ QFile palette(temp+"/config/gtk-4.0/noctalia.css");
+ if(!theme||!palette.open(QIODevice::ReadOnly))return 2;
+ const auto original=palette.readAll();palette.close();
+ const auto contrast=[](QColor a,QColor b) {
+ const auto luminance=[](QColor c) {
+ const auto linear=[](double v){return v<=.04045?v/12.92:std::pow((v+.055)/1.055,2.4);};
+ return .2126*linear(c.redF())+.7152*linear(c.greenF())+.0722*linear(c.blueF());
+ };
+ const double x=luminance(a),y=luminance(b);return (qMax(x,y)+.05)/(qMin(x,y)+.05);
+ };
+ for(bool light:{false,true}) {
+ auto css=original;
+ if(light){css.replace("#17191f","#f6f0e8");css.replace("#eee5dc","#342d29");css.replace("#24252b","#e9e0d5");css.replace("#e6b599","#8b492d");}
+ QSaveFile replacement(palette.fileName());if(!replacement.open(QIODevice::WriteOnly))return 2;
+ replacement.write(css);if(!replacement.commit())return 2;
+ check(wait([&]{return theme->colors()["card"].value<QColor>()==QColor(light?"#e9e0d5":"#24252b");}),"reverse follows live light/dark theme changes");
+ for(const QString medium:{"cd","vinyl","cassette","tp7"}) {
+ player.setMedium(medium);window->setProperty("discFlipped",false);QMetaObject::invokeMethod(window,"flipDisc");QTest::qWait(100);
+ auto *booklet=item("albumBooklet"),*title=item("discAlbumTitle");
+ const auto frame=captureTestWindow(window);
+ if(!booklet||!title||frame.isNull()){check(false,"reverse frame is available");continue;}
+ const double scale=frame.width()/double(window->width());
+ const auto point=booklet->mapToScene(QPointF(205,325))*scale;
+ const auto background=frame.pixelColor(point.toPoint());
+ check(background.alpha()==255,"reverse text surface is opaque");
+ check(contrast(title->property("color").value<QColor>(),background)>=4.5,"rendered reverse title has readable contrast");
+ check(contrast(window->property("mutedInk").value<QColor>(),background)>=4.5,"rendered reverse supporting text has readable contrast");
+ check(contrast(window->property("accent").value<QColor>(),background)>=4.5,"rendered reverse active track has readable contrast");
+ auto *list=item("albumTrackList");check(list&&list->hasActiveFocus(),"flip moves keyboard focus into album details");
+ if(!captures.isEmpty()){QDir().mkpath(captures);check(frame.save(captures+"/reverse-"+medium+(light?"-light":"-dark")+".png"),"reverse capture saved");}
+ QMetaObject::invokeMethod(window,"flipDisc");QTest::qWait(30);
+ check(!list->hasActiveFocus(),"closing album details releases its keyboard focus");
+ }
+ }
+ QSaveFile restore(palette.fileName());if(!restore.open(QIODevice::WriteOnly))return 2;
+ restore.write(original);if(!restore.commit())return 2;
+ check(wait([&]{return theme->colors()["card"].value<QColor>()==QColor("#24252b");}),"test theme restored");
+ if(qEnvironmentVariableIsSet("SPUN_TEST_REVERSE_ONLY"))return failures?1:0;
+ }
player.setVinyl(true);player.setVinylAlbumMode(true);QTest::qWait(350);
check(!window->property("recordKey").toString().isEmpty(),"album grooves expose a stable gesture identity");
player.setHorizontalSeek(true);QTest::qWait(100);
diff --git a/src/performancetest.cpp b/src/performancetest.cpp
new file mode 100644
index 0000000..8f59d63
--- /dev/null
+++ b/src/performancetest.cpp
@@ -0,0 +1,163 @@
+#include "performancetest.h"
+#include "player.h"
+#include "testcapture.h"
+#include <QQmlContext>
+#include <QScreen>
+#include <QSignalSpy>
+#include <QMutex>
+#include <QMutexLocker>
+#include <QJsonArray>
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QFile>
+#include <QDir>
+#include <QEventLoop>
+#include <QTimer>
+#include <functional>
+#include <atomic>
+#include <iostream>
+#include <algorithm>
+#include <cmath>
+#include <memory>
+
+namespace {
+bool until(const std::function<bool()> &ready, int ms=15000) {
+ QElapsedTimer t;t.start();
+ while(!ready()&&t.elapsed()<ms)QTest::qWait(10);
+ return ready();
+}
+QJsonObject memory() {
+ QJsonObject result;QFile file("/proc/self/smaps_rollup");
+ if(file.open(QIODevice::ReadOnly))for(const auto &line:file.readAll().split('\n'))
+ for(const auto &key:{QByteArray("Rss"),QByteArray("Pss"),QByteArray("Private_Dirty")})
+ if(line.startsWith(key+':'))result[QString::fromLatin1(key)+"KiB"]=line.mid(key.size()+1).simplified().split(' ').first().toInt();
+ return result;
+}
+int verifyMotion(Player &player,QQuickWindow *window) {
+ int checks=0,failures=0;
+ const auto check=[&](bool ok,const char *label) {
+ ++checks;failures+=!ok;std::cout<<(ok?"PASS ":"FAIL ")<<label<<std::endl;
+ };
+ player.setMotion(false);player.setThreeD(false);player.setRepeatMode(2);
+ for(const QString medium:{"cd","vinyl","cassette","tp7"})for(bool fast:{false,true}) {
+ if(fast&&medium!="cd")continue;
+ player.setMedium(medium);player.setCd500Rpm(fast);player.play();
+ if(!until([&]{return player.playing();}))return 2;
+ const double speed=medium=="tp7"?36:medium=="cd"&&fast?3000:medium=="vinyl"?window->property("vinylDegreesPerSecond").toDouble():9;
+ double left=0,right=0;
+ for(int hz:{60,120,165,240}) {
+ window->setProperty("discFlipped",false);window->setProperty("spinSpeed",speed);
+ for(const char *property:{"spinAngle","cassetteLeftAngle","cassetteRightAngle","wavePhase","tapeWindSpeed"})window->setProperty(property,0.);
+ for(int i=0;i<hz*2;++i) {
+ QVariant result;
+ if(!QMetaObject::invokeMethod(window,"advanceMediaFrame",Q_RETURN_ARG(QVariant,result),Q_ARG(QVariant,1./hz),Q_ARG(QVariant,1000.+i*1000./hz)))return 2;
+ }
+ const double angle=window->property("spinAngle").toDouble();
+ check(std::abs(std::remainder(angle-speed*2,360.))<.001,"media rotation keeps its speed at 60/120/165/240 Hz");
+ check(std::abs(window->property("wavePhase").toDouble()-5.6)<.001,"wave motion is independent of refresh rate");
+ if(medium=="cassette") {
+ if(hz==60){left=window->property("cassetteLeftAngle").toDouble();right=window->property("cassetteRightAngle").toDouble();}
+ check(std::abs(window->property("cassetteLeftAngle").toDouble()-left)<.001&&std::abs(window->property("cassetteRightAngle").toDouble()-right)<.001,"both tape reels retain their elapsed-time motion across refresh rates");
+ }
+ }
+ player.pause();
+ }
+ auto *clock=window->findChild<QObject*>("mediaFrameAnimation");
+ check(clock&&!clock->property("running").toBool(),"reduced motion stops the frame callback");
+ std::cout<<"MOTION_RESULT "<<checks<<" checks, "<<failures<<" failures"<<std::endl;
+ return failures?1:0;
+}
+
+}
+
+int exercisePerformance(Player &player,QQuickWindow *window,const QString &captures) {
+ auto *mixer=qmlContext(window)->contextProperty("tx6").value<QObject*>();
+ if(!mixer)return 2;
+ window->setProperty("benchmarkPinned",true);window->setProperty("useCider",false);
+ player.setVolume(0);player.setMotion(false);player.setMiniMode(false);
+ player.setMedium("cd");player.setThreeD(false);player.demo();player.pause();
+ if(!until([&]{return player.count()>0&&!player.busy()&&player.duration()>0&&window->isExposed();}))return 2;
+ player.pause();
+ QTest::qWait(600);
+ if(qEnvironmentVariableIsSet("SPUN_PERF_TIMING_ONLY"))return verifyMotion(player,window);
+ const bool pacing=qEnvironmentVariableIsSet("SPUN_PERF_PACING");
+ const auto media=qEnvironmentVariable("SPUN_PERF_MEDIA","cd,vinyl,cassette,tp7,tx6").split(',');
+ QList<QPair<QString,bool>> stages;
+ for(const auto &medium:media)for(bool threeD:{false,true})stages.append({medium,threeD});
+ if(!pacing)for(const auto &medium:media)stages.append({medium,true});
+ QJsonArray rows;int failures=0;
+ for(int round=0;round<(pacing?1:2);++round)for(const auto &stage:stages) {
+ const auto &medium=stage.first;const bool threeD=stage.second;
+ // Direct render-thread callbacks own their sample. Disconnecting a
+ // signal need not wait for a callback already in flight.
+ struct Presentation { std::atomic<bool> synchronized=false; std::atomic<qint64> presented=-1; QElapsedTimer clock; };
+ const auto presentation=std::make_shared<Presentation>();presentation->clock.start();
+ const auto sync=QObject::connect(window,&QQuickWindow::afterSynchronizing,window,[presentation]{presentation->synchronized=true;},Qt::DirectConnection);
+ const auto swap=QObject::connect(window,&QQuickWindow::frameSwapped,window,[presentation]{
+ qint64 expected=-1;
+ if(presentation->synchronized.load())presentation->presented.compare_exchange_strong(expected,presentation->clock.nsecsElapsed());
+ },Qt::DirectConnection);
+ mixer->setProperty("visible",medium=="tx6");
+ player.setMedium(medium=="tx6"?"tp7":medium);player.setThreeD(threeD);
+ const auto setMs=presentation->clock.nsecsElapsed()/1e6;
+ window->update();
+ const bool ready=until([&]{return presentation->presented.load()>=0;});
+ QObject::disconnect(sync);QObject::disconnect(swap);
+ const bool correct=window->property("threeDActive").toBool()==threeD;
+ failures+=!ready||!correct;
+ QJsonObject row{{"medium",medium},{"threeD",threeD},{"round",round},{"setMs",setMs},
+ {"firstPresentMs",presentation->presented.load()/1e6},{"correct",ready&&correct}};
+ QTest::qWait(600);
+ if(!captures.isEmpty()&&round==0) {
+ QDir().mkpath(captures);
+ if(!captureTestWindow(window).save(captures+"/"+medium+(threeD?"-3d":"-2d")+".png"))++failures;
+ }
+ if(pacing) {
+ player.setMotion(true);player.setRepeatMode(2);player.play();QTest::qWait(1500);
+ struct Frames { QList<double> intervals;QMutex lock;QElapsedTimer clock;qint64 previous=0; };
+ const auto frames=std::make_shared<Frames>();frames->clock.start();
+ QSignalSpy motion(window,SIGNAL(spinAngleChanged()));
+ const auto sample=QObject::connect(window,&QQuickWindow::frameSwapped,window,[frames]{
+ const auto now=frames->clock.nsecsElapsed();QMutexLocker guard(&frames->lock);
+ if(frames->previous)frames->intervals.append((now-frames->previous)/1e6);
+ frames->previous=now;
+ },Qt::DirectConnection);
+ QEventLoop measurement;QTimer::singleShot(3000,&measurement,&QEventLoop::quit);
+ measurement.exec();const double seconds=frames->clock.elapsed()/1000.;
+ QObject::disconnect(sample);
+ {QMutexLocker guard(&frames->lock);
+ auto &intervals=frames->intervals;
+ // An interrupted nested event loop is not a valid pacing
+ // sample. Do not silently report NaN/null rates as a pass.
+ const bool validSample=seconds>=2.5&&!intervals.isEmpty();
+ row["validPacingSample"]=validSample;
+ failures+=!validSample;
+ std::sort(intervals.begin(),intervals.end());
+ if(validSample) {
+ row["presentHz"]=(intervals.size()+1)/seconds;
+ row["motionHz"]=motion.count()/seconds;
+ }
+ row["screenHz"]=window->screen()->refreshRate();
+ if(!intervals.isEmpty()) {
+ row["frameMedianMs"]=intervals[intervals.size()/2];
+ row["frameP95Ms"]=intervals[qMin(intervals.size()-1,qsizetype(intervals.size()*.95))];
+ }
+ }
+ player.setMotion(false);QTest::qWait(100);
+ auto *animation=window->findChild<QObject*>("mediaFrameAnimation");
+ const auto still=window->property("spinAngle");QTest::qWait(120);
+ row["reducedMotionStopped"]=animation&&!animation->property("running").toBool()&&still==window->property("spinAngle");
+ failures+=!row["reducedMotionStopped"].toBool();
+ player.setMotion(true);window->hide();QTest::qWait(100);
+ const auto hidden=window->property("spinAngle");QTest::qWait(120);
+ row["hiddenMotionStopped"]=animation&&!animation->property("running").toBool()&&hidden==window->property("spinAngle");
+ failures+=!row["hiddenMotionStopped"].toBool();
+ player.pause();player.setMotion(false);window->show();until([&]{return window->isExposed();});QTest::qWait(200);
+ }
+ row["memory"]=memory();rows.append(row);
+ std::cout<<"PERFORMANCE "<<QJsonDocument(row).toJson(QJsonDocument::Compact).constData()<<std::endl;
+ }
+ player.pause();player.setThreeD(false);
+ std::cout<<"PERFORMANCE_RESULT "<<QJsonDocument(QJsonObject{{"failures",failures},{"rows",rows}}).toJson(QJsonDocument::Compact).constData()<<std::endl;
+ return failures?1:0;
+}
diff --git a/src/performancetest.h b/src/performancetest.h
new file mode 100644
index 0000000..2e0d05a
--- /dev/null
+++ b/src/performancetest.h
@@ -0,0 +1,5 @@
+#pragma once
+#include <QString>
+class Player;
+class QQuickWindow;
+int exercisePerformance(Player &, QQuickWindow *, const QString &captures);
diff --git a/src/player.cpp b/src/player.cpp
index 5cf6489..9ce8288 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -1,4 +1,5 @@
#include "player.h"
+#include "tx6.h"
#include "artwork.h"
#include <QDir>
#include <QDirIterator>
@@ -92,6 +93,10 @@ Player::~Player() {
m_importJob.waitForFinished();
save();
if (m_preparingAudio) m_audioPreparation.waitForFinished();
+ // QAudioBufferOutput detaches itself from its player during destruction.
+ // Keep that player alive until the tap is gone, including after bypass.
+ if(m_media){m_media->stop();m_media->setAudioBufferOutput(nullptr);}
+ m_mixOutput.reset();
// No worker keeps a Player pointer. Finish its bounded cache write before exit.
if (m_artJobActive) {
m_artLoader.waitForFinished();
@@ -105,6 +110,7 @@ void Player::ensureMedia() {
m_audio->setVolume(m_volume);
m_media = std::make_unique<QMediaPlayer>();
m_media->setAudioOutput(m_audio.get());
+ refreshMixerRoute();
connect(m_media.get(), &QMediaPlayer::playbackStateChanged, this, &Player::playingChanged);
connect(m_media.get(), &QMediaPlayer::positionChanged, this, &Player::positionChanged);
connect(m_media.get(), &QMediaPlayer::durationChanged, this, &Player::durationChanged);
@@ -566,3 +572,15 @@ QString Player::albumKey() const {
const auto &t=m_tracks[m_index];
return t.album.isEmpty() ? t.path : t.album+"|"+(t.albumArtist.isEmpty() ? QFileInfo(t.path).absolutePath() : t.albumArtist);
}
+
+void Player::attachMixer(Tx6 *mixer) { m_mixer=mixer;refreshMixerRoute(); }
+void Player::refreshMixerRoute() {
+ if(!m_media)return;
+ const bool active=m_mixer&&m_mixer->active();
+ if(active&&!m_mixOutput){
+ m_mixOutput=std::make_unique<QAudioBufferOutput>(Tx6::format());
+ connect(m_mixOutput.get(),&QAudioBufferOutput::audioBufferReceived,this,[this](const QAudioBuffer &buffer){if(m_mixer)m_mixer->consume(buffer);});
+ }
+ m_media->setAudioBufferOutput(active?m_mixOutput.get():nullptr);
+ m_audio->setMuted(active);
+}
diff --git a/src/player.h b/src/player.h
index 77a995c..f3f69da 100644
--- a/src/player.h
+++ b/src/player.h
@@ -20,6 +20,9 @@ struct Track {
struct LoadedArtwork { QImage image; QString file; bool created = false; };
struct ImportedTracks { QList<Track> tracks; QString firstPath; };
+class Tx6;
+class QAudioBufferOutput;
+
class Player : public QObject {
Q_OBJECT
Q_PROPERTY(QString trackKey READ trackKey NOTIFY trackChanged)
@@ -126,6 +129,8 @@ public:
QString artworkFile() const { return m_artFile; }
QString trackId() const;
void setVolume(double value);
+ void attachMixer(Tx6 *mixer);
+ void refreshMixerRoute();
void setShuffle(bool value);
void setRepeatMode(int value);
void setLight(bool value);
@@ -184,8 +189,10 @@ private:
QFutureWatcher<void> m_audioPreparation;
bool m_preparingAudio = false, m_playPending = false;
double m_volume = .65;
+ Tx6 *m_mixer=nullptr;
std::unique_ptr<QAudioOutput> m_audio;
std::unique_ptr<QMediaPlayer> m_media;
+ std::unique_ptr<QAudioBufferOutput> m_mixOutput;
QSettings m_settings;
QImage m_art;
QFutureWatcher<LoadedArtwork> m_artLoader;
diff --git a/src/playerbody.cpp b/src/playerbody.cpp
index f82f790..fe398a4 100644
--- a/src/playerbody.cpp
+++ b/src/playerbody.cpp
@@ -12,7 +12,7 @@ void PlayerBody::paint(QPainter *p) {
const bool tape=m_medium=="cassette",cd=m_medium=="cd";
const auto metal=[&](const QRectF &r,qreal radius){
// Broad face, rounded bevel and a dark underside share one light source.
- const QColor base=m_surface;
+ const QColor base=(tape||cd)?QColor("#bfc7ce"):m_surface;
p->setPen(Qt::NoPen);p->setBrush(base.darker(210));
p->drawRoundedRect(r,radius,radius);
QLinearGradient edge(r.topLeft(),r.bottomRight());
@@ -53,7 +53,11 @@ void PlayerBody::paint(QPainter *p) {
p->setPen(Qt::NoPen);p->setBrush(QColor(0,0,0,100));p->drawRoundedRect(r.translated(2,5),5,5);
metal(r,cd?5:2);
const QRectF cover=r.adjusted(cd?18:5,5,-5,-5);
- if(!m_artwork.isNull()) {
+ if(m_layer==3) {
+ // The reverse carries themed text, unlike the silver hardware or
+ // artwork sleeve. Keep its ink paired with an opaque theme surface.
+ p->fillRect(cover,m_surface);
+ } else if(!m_artwork.isNull()) {
const auto side=qMin(m_artwork.width(),m_artwork.height());
p->drawImage(cover,m_artwork,QRectF((m_artwork.width()-side)/2.,(m_artwork.height()-side)/2.,side,side));
}
@@ -65,7 +69,31 @@ void PlayerBody::paint(QPainter *p) {
p->setPen(QPen(QColor(0,0,0,65),1));p->drawLine(r.topRight()-QPointF(2,0),r.bottomRight()-QPointF(2,0));
}
QLinearGradient gloss(r.topLeft(),r.bottomRight());gloss.setColorAt(0,QColor(255,255,255,cd?40:12));gloss.setColorAt(.48,Qt::transparent);gloss.setColorAt(.5,QColor(255,255,255,cd?16:4));gloss.setColorAt(1,Qt::transparent);
- p->fillRect(r.adjusted(1,1,-1,-1),gloss);return;
+ if(m_layer!=3)p->fillRect(r.adjusted(1,1,-1,-1),gloss);
+ return;
+ }
+ if(cd) {
+ const QRectF body(10,10,420,408),window(20,20,400,392);
+ if(m_layer==1) {
+ QPainterPath glass;glass.addRoundedRect(window,4,4);
+ QLinearGradient reflection(window.topLeft(),window.bottomRight());
+ reflection.setColorAt(0,QColor(232,243,248,20));reflection.setColorAt(.43,QColor(232,243,248,3));
+ reflection.setColorAt(.44,QColor(245,252,255,17));reflection.setColorAt(1,QColor(26,42,49,9));
+ p->fillPath(glass,reflection);glassEdge(glass);
+ hinge(QRectF(75,17,28,7));hinge(QRectF(337,17,28,7));
+ return;
+ }
+ p->setPen(Qt::NoPen);p->setBrush(QColor(0,0,0,55));p->drawRoundedRect(body.translated(1,4),7,7);
+ metal(body,7);
+ p->setPen(QPen(QColor("#76848d"),.7));p->setBrush(QColor("#aeb9c0"));p->drawRoundedRect(window,4,4);
+ QRandomGenerator grain(731);
+ p->save();p->setClipRect(window);
+ for(int i=0;i<2200;++i){p->setPen(QPen(QColor(255,255,255,i%3?8:14),.4));const QPointF a(20+400*grain.generateDouble(),20+392*grain.generateDouble());p->drawLine(a,a+QPointF(3.5,0));}
+ p->restore();
+ p->setPen(QPen(QColor("#5c6971"),2));p->setBrush(QColor("#13191d"));p->drawEllipse(QPointF(220,220),187,187);
+ p->setPen(QPen(QColor("#d0d8dd"),.7));p->setBrush(Qt::NoBrush);p->drawEllipse(QPointF(220,220),188.5,188.5);
+ for(QPointF at:{QPointF(29,29),QPointF(411,29),QPointF(29,400),QPointF(411,400)})screw(at);
+ return;
}
if(m_layer==1) {
if(m_medium=="vinyl") {
@@ -78,7 +106,7 @@ void PlayerBody::paint(QPainter *p) {
p->setBrush(spindle);p->drawEllipse(QPointF(220,220),4.5,5.5);return;
}
QPainterPath glass;
- if(tape)glass.addRoundedRect(QRectF(42,112,356,225),12,12);
+ if(tape)glass.addRoundedRect(QRectF(27,91,386,266),6,6);
else glass.addEllipse(QPointF(220,220),194,194);
QLinearGradient g(60,70,345,365);g.setColorAt(0,QColor(219,237,244,32));g.setColorAt(.32,QColor(200,220,230,2));g.setColorAt(.33,QColor(243,250,255,22));g.setColorAt(.48,QColor(235,247,255,4));g.setColorAt(1,QColor(8,12,18,30));
p->fillPath(glass,g);glassEdge(glass);
@@ -87,7 +115,7 @@ void PlayerBody::paint(QPainter *p) {
p->setPen(QPen(QColor(241,246,247,13),.45));
for(int i=0;i<11;++i){const double x=65+i*27;const double y=tape?124+(i%4)*4:71+(i%4)*5;p->drawLine(QPointF(x,y),QPointF(x+12+(i%3)*6,y-2));}
p->restore();
- if(tape){hinge(QRectF(80,107,31,8));hinge(QRectF(329,107,31,8));metal(QRectF(195,334,50,9),3);}
+ if(tape){hinge(QRectF(66,353,31,8));hinge(QRectF(329,353,31,8));}
else{
hinge(QRectF(159,26,24,8));hinge(QRectF(257,26,24,8));
QConicalGradient clamp(QPointF(220,220),25);clamp.setColorAt(0,QColor("#b8bfc0"));clamp.setColorAt(.4,QColor("#45494d"));clamp.setColorAt(.7,QColor("#dae0df"));clamp.setColorAt(1,QColor("#b8bfc0"));
@@ -101,8 +129,8 @@ void PlayerBody::paint(QPainter *p) {
const QRectF body=tape?QRectF(19,83,402,283):QRectF(6,6,428,428);
p->setPen(Qt::NoPen);
for(int i=6;i>0;--i){p->setBrush(QColor(0,0,0,7));p->drawRoundedRect(body.adjusted(-i,-i,i,i).translated(0,3),cd?220:23,cd?220:23);}
- metal(body,cd?214:22);
- p->save();QPainterPath face;face.addRoundedRect(body.adjusted(3,3,-3,-7),cd?211:20,cd?211:20);p->setClipPath(face);
+ metal(body,cd?214:tape?7:22);
+ p->save();QPainterPath face;face.addRoundedRect(body.adjusted(3,3,-3,-7),cd?211:tape?5:20,cd?211:tape?5:20);p->setClipPath(face);
QRandomGenerator grain(317);
for(int i=0;i<2600;++i){
const double x=body.left()+grain.generateDouble()*body.width(),y=body.top()+grain.generateDouble()*body.height();
diff --git a/src/recordertest.cpp b/src/recordertest.cpp
index a86aa82..f5d0835 100644
--- a/src/recordertest.cpp
+++ b/src/recordertest.cpp
@@ -1,3 +1,4 @@
+#include "testcapture.h"
#include "recordertest.h"
#include "player.h"
#include "cider.h"
@@ -62,7 +63,7 @@ int exerciseRecorder(Player &player,QQuickWindow *window,const QString &temp,con
};
const auto click=[&](const char *name){auto *key=item(name);if(!check(key&&key->isEnabled(),qPrintable(QString(name)+" is enabled")))return;QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,point(key,QPointF(key->width()/2,key->height()/2)));QTest::qWait(70);};
const auto move=[&](QPoint p,Qt::KeyboardModifiers modifier=Qt::NoModifier){QMouseEvent e(QEvent::MouseMove,p,window->mapToGlobal(p),Qt::NoButton,Qt::LeftButton,modifier);QGuiApplication::sendEvent(window,&e);QTest::qWait(15);};
- const auto capture=[&](QString name){if(captures.isEmpty())return;QTest::mouseMove(window,QPoint(8,8));QTest::qWait(180);const QImage image=window->grabWindow();check(!image.isNull(),"frame renders");if(!image.isNull()){QDir().mkpath(captures);check(image.save(captures+"/"+name+".png"),"capture saved");}};
+ const auto capture=[&](QString name){if(captures.isEmpty())return;QTest::mouseMove(window,QPoint(8,8));QTest::qWait(180);const QImage image=captureTestWindow(window);check(!image.isNull(),"frame renders");if(!image.isNull()){QDir().mkpath(captures);check(image.save(captures+"/"+name+".png"),"capture saved");}};
player.setVolume(0);player.setMotion(false);player.setThreeD(false);player.setMiniMode(false);player.setShowPlayerBody(false);player.clear();
QList<QUrl> files;for(int i=0;i<3;++i){const QString path=temp+QString("/recorder-%1.flac").arg(i);QFile::copy(QStringLiteral(SPUN_SOURCE_DIR "/assets/First-Light.flac"),path);files.append(QUrl::fromLocalFile(path));}
player.addUrls(files,false);if(!check(until([&]{return !player.busy()&&player.count()==3;}),"local fixtures import"))return 2;
@@ -167,7 +168,7 @@ int exerciseRecorder(Player &player,QQuickWindow *window,const QString &temp,con
auto *key=item(entry.first);QPoint at;
if(threeD){auto *view=item("player3DView");view->setProperty("recorderYaw",entry.second>=8?-75.:0.);QTest::qWait(80);QVariant p;QMetaObject::invokeMethod(view,"projectRecorderControl",Q_RETURN_ARG(QVariant,p),Q_ARG(QVariant,entry.second));at=view->mapToScene(p.toPointF()).toPoint();}
else at=point(key,QPointF(key->width()/2,key->height()/2));
- const QImage resting=window->grabWindow();QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,at);
+ const QImage resting=captureTestWindow(window);QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,at);
check(key->property("held").toBool()&&key->property("armed").toBool(),"press reaches the physical button face");
// Software 3D frames can be much slower than the animation clock.
// Wait for the rendered state instead of treating CPU render time as input latency.
@@ -175,7 +176,7 @@ int exerciseRecorder(Player &player,QQuickWindow *window,const QString &temp,con
const double depth=key->property("pressDepth").toDouble();
std::cout<<"PRESSURE "<<entry.first.toStdString()<<" depth "<<depth<<std::endl;
check(depth>.65&&depth<1.15,qPrintable(entry.first+" develops bounded physical travel"));
- const QImage pressed=window->grabWindow();check(!pressed.isNull()&&pressed!=resting,"button travel changes the rendered frame");
+ const QImage pressed=captureTestWindow(window);check(!pressed.isNull()&&pressed!=resting,"button travel changes the rendered frame");
if(entry.second==1&&!captures.isEmpty())pressed.save(captures+(threeD?"/tp7-3d-pressed.png":"/tp7-2d-pressed.png"));
move(QPoint(8,8));QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,QPoint(8,8));
check(until([&]{return std::abs(key->property("pressDepth").toDouble())<.01;}),"released button settles back into its housing");
diff --git a/src/testcapture.h b/src/testcapture.h
new file mode 100644
index 0000000..dc39692
--- /dev/null
+++ b/src/testcapture.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <QGuiApplication>
+#include <QQuickItem>
+#include <QQuickItemGrabResult>
+#include <QQuickWindow>
+#include <QPainter>
+#include <QElapsedTimer>
+#include <QTest>
+
+// The offscreen GLX platform's window readback can return a stale drawable
+// after resizing. Capture the actual scene graph into a Qt-owned render target
+// instead. Native checks still read the presented window, including its alpha.
+inline QImage captureTestWindow(QQuickWindow *window) {
+ if (QGuiApplication::platformName() != "offscreen"
+ || qEnvironmentVariable("QT_QUICK_BACKEND") == "software")
+ return window->grabWindow();
+
+ const auto result = window->contentItem()->grabToImage();
+ if (!result) return {};
+ QElapsedTimer timer;
+ timer.start();
+ while (result->image().isNull() && timer.elapsed() < 4000)
+ QTest::qWait(20);
+ const auto scene = result->image();
+ if (scene.isNull()) return {};
+
+ QImage frame(scene.size(), QImage::Format_ARGB32_Premultiplied);
+ frame.fill(window->color());
+ QPainter painter(&frame);
+ painter.drawImage(0, 0, scene);
+ return frame;
+}
diff --git a/src/threedtest.cpp b/src/threedtest.cpp
index cb6eceb..89dc7b2 100644
--- a/src/threedtest.cpp
+++ b/src/threedtest.cpp
@@ -1,3 +1,4 @@
+#include "testcapture.h"
#include "threedtest.h"
#include "player.h"
#include "disc.h"
@@ -58,7 +59,7 @@ int exerciseThreeD(Player &player,QQuickWindow *window,const QString &temp,const
QTest::mouseRelease(window,Qt::LeftButton,mods,to);QTest::qWait(60);
};
const auto render=[&](const QString &name){
- const auto frame=window->grabWindow();
+ const auto frame=captureTestWindow(window);
if(!check(!frame.isNull(),"rendered frame is available"))return;
const auto sx=frame.width()/double(window->width());const auto scale=window->property("uiScale").toDouble()*sx;
int opaque=0,total=0;
@@ -230,8 +231,10 @@ int exerciseThreeDLighting(Player &player,QQuickWindow *window,const QString &te
player.setVolume(0);player.setMotion(false);window->setProperty("useCider",false);player.demo();player.pause();player.setThreeD(true);
if(!check(until([&]{return window->isExposed()&&window->property("threeDActive").toBool();}),"3D scene is exposed"))return 2;
QFile palette(temp+"/config/gtk-4.0/noctalia.css");if(!palette.open(QIODevice::ReadOnly))return 2;const auto original=palette.readAll();palette.close();
- for(const auto &medium:QStringList{"cd","vinyl","cassette","tp7"}) {
- player.setMedium(medium);QTest::qWait(200);double coolBalance=0;
+ auto *mixer=qmlContext(window)->contextProperty("tx6").value<QObject*>();
+ if(!check(mixer!=nullptr,"TX-6 participates in wallpaper lighting checks"))return 2;
+ for(const auto &medium:QStringList{"cd","vinyl","cassette","tp7","tx6"}) {
+ player.setMedium(medium=="tx6"?"tp7":medium);mixer->setProperty("visible",medium=="tx6");QTest::qWait(200);double coolBalance=0;
for(const auto &accent:QStringList{"#82bed5","#e4a17f","#d9bafa","#916ba8"}) {
auto css=original;css.replace("#e6b599",accent.toUtf8());
const bool lightPalette=accent=="#916ba8";
@@ -246,9 +249,9 @@ int exerciseThreeDLighting(Player &player,QQuickWindow *window,const QString &te
// accent-colored progress indicators and the tonearm.
const QPointF surfacePoint=medium=="cassette"?QPointF(320,369):medium=="tp7"?QPointF(240,325):QPointF(150,349);
if(!view)return 2;
- if(lightPalette&&medium!="tp7"&&medium!="vinyl")check(view->property("caseTint").value<QColor>().lightnessF()>.75,"light Noctalia palette updates the physical enclosure material");
- QMetaObject::invokeMethod(view,"projectSurface",Q_RETURN_ARG(QVariant,projected),Q_ARG(QVariant,surfacePoint.x()),Q_ARG(QVariant,surfacePoint.y()));
- const auto scenePoint=view->mapToScene(projected.toPointF());const QImage frame=window->grabWindow();
+ if(medium=="tx6")QMetaObject::invokeMethod(view,"projectTx6Face",Q_RETURN_ARG(QVariant,projected),Q_ARG(QVariant,122.),Q_ARG(QVariant,45.));
+ else QMetaObject::invokeMethod(view,"projectSurface",Q_RETURN_ARG(QVariant,projected),Q_ARG(QVariant,surfacePoint.x()),Q_ARG(QVariant,surfacePoint.y()));
+ const auto scenePoint=view->mapToScene(projected.toPointF());const QImage frame=captureTestWindow(window);
if(!check(!frame.isNull(),"lighting test captures rendered pixels"))return 2;
const double scale=frame.width()/double(window->width());const QPoint center(qRound(scenePoint.x()*scale),qRound(scenePoint.y()*scale));
double red=0,blue=0;int samples=0;
@@ -279,12 +282,17 @@ int exerciseThreeDLighting(Player &player,QQuickWindow *window,const QString &te
player.seek(player.duration()/2);
for(const QString &finish:{QString("clear"),QString("smoke"),QString("cream")}) {
player.setCassetteFinish(finish);QTest::qWait(180);
- const auto frame=window->grabWindow();check(!frame.isNull(),"cassette finish renders with its transport details");
+ const auto frame=captureTestWindow(window);check(!frame.isNull(),"cassette finish renders with its transport details");
if(!captures.isEmpty())frame.save(captures+"/cassette-"+finish+".png");
}
}
if(medium=="cd"||medium=="cassette") {
for(double fraction:{0.,.5,1.}) {
+ if(medium=="cassette"||medium=="cd") {
+ auto *controls=findItem(window->contentItem(),medium=="cd"?"cdControls":"cassetteControls");
+ if(!check(controls!=nullptr,"door controls are available"))return 2;
+ controls->setProperty("doorAngle",fraction*(medium=="cd"?70:58));
+ }
window->setProperty("lidOpen",fraction);QTest::qWait(150);
auto *view=findItem(window->contentItem(),"player3DView");QVariant projected;
if(!view)return 2;
@@ -292,12 +300,13 @@ int exerciseThreeDLighting(Player &player,QQuickWindow *window,const QString &te
const auto bounds=projected.toRectF();
check(bounds.left()>=0&&bounds.top()>=0&&bounds.right()<=view->width()&&bounds.bottom()<=view->height(),
"detailed lid stays inside the player throughout opening");
- const auto frame=window->grabWindow();check(!frame.isNull(),"open lid renders without losing the scene");
+ const auto frame=captureTestWindow(window);check(!frame.isNull(),"open lid renders without losing the scene");
if(!captures.isEmpty())frame.save(captures+"/"+medium+QString("-lid-%1.png").arg(fraction*100));
}
window->setProperty("lidOpen",0);
}
}
+ mixer->setProperty("visible",false);
player.setMedium("vinyl");player.setHorizontalSeek(true);player.pause();player.seek(4000);QTest::qWait(180);
auto *bar=findItem(window->contentItem(),"horizontalSeek");
auto *arm=findItem(window->contentItem(),"vinylTonearm");
diff --git a/src/turntabletest.cpp b/src/turntabletest.cpp
index 69e6ab9..d18ac48 100644
--- a/src/turntabletest.cpp
+++ b/src/turntabletest.cpp
@@ -1,3 +1,4 @@
+#include "testcapture.h"
#include "turntabletest.h"
#include "player.h"
#include "cider.h"
@@ -83,7 +84,7 @@ int exerciseTurntable(Player &player,QQuickWindow *window,const QString &temp,co
const auto projected=[&](QQuickItem *c,QPointF p){auto *surface=item("mediaSurface");const auto local=c->mapToItem(surface,p);QVariant r;QMetaObject::invokeMethod(view,"projectSurface",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,local.x()),Q_ARG(QVariant,local.y()));return view->mapToScene(r.toPointF()).toPoint();};
const auto move=[&](QPoint p,Qt::KeyboardModifiers m=Qt::NoModifier){QMouseEvent e(QEvent::MouseMove,p,window->mapToGlobal(p),Qt::NoButton,Qt::LeftButton,m);QGuiApplication::sendEvent(window,&e);QTest::qWait(20);};
const auto clickHardware=[&](int index){QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,hardware(index));QTest::qWait(80);};
- const auto capture=[&](const QString &name){if(captures.isEmpty())return;QTest::mouseMove(window,QPoint(5,5));QTest::qWait(150);QDir().mkpath(captures);check(window->grabWindow().save(captures+"/"+name+".png"),"turntable capture saved");};
+ const auto capture=[&](const QString &name){if(captures.isEmpty())return;QTest::mouseMove(window,QPoint(5,5));QTest::qWait(150);QDir().mkpath(captures);check(captureTestWindow(window).save(captures+"/"+name+".png"),"turntable capture saved");};
capture("vinyl-front");
if(qEnvironmentVariableIsSet("SPUN_TEST_VISUAL_ONLY")) {
window->setColor(QColor("#25272c"));
diff --git a/src/tx6.cpp b/src/tx6.cpp
new file mode 100644
index 0000000..ad32470
--- /dev/null
+++ b/src/tx6.cpp
@@ -0,0 +1,123 @@
+#include "tx6.h"
+#include "player.h"
+#include <QAudioDevice>
+#include <QMediaDevices>
+#include <QFileInfo>
+#include <cmath>
+#include <cstring>
+#include <algorithm>
+
+QAudioFormat Tx6::format() { QAudioFormat f;f.setSampleRate(48000);f.setChannelCount(2);f.setSampleFormat(QAudioFormat::Float);return f; }
+Tx6::Tx6(Player *player,const QString &settings,bool outputEnabled):QObject(player),m_player(player),m_settings(settings,QSettings::IniFormat),m_outputEnabled(outputEnabled) {
+ m_visible=m_settings.value("tx6Visible",false).toBool();
+ m_channels[0].name="TP-7 · USB 1/2";
+ for(int c=0;c<6;++c)for(int b=0;b<3;++b)coefficients(c,b);
+ player->attachMixer(this);
+ connect(player,&Player::mediumChanged,this,&Tx6::updateRoute);
+ connect(player,&Player::trackChanged,this,&Tx6::flush);
+ connect(player,&Player::seeked,this,&Tx6::flush);
+ connect(player,&Player::playingChanged,this,[this]{if(!m_player->playing())flush();});
+ m_pump.setInterval(8);
+ connect(&m_pump,&QTimer::timeout,this,[this]{
+ if(!m_output || m_pending.isEmpty())return;
+ const auto written=m_output->write(m_pending.constData(),std::min<qint64>(m_pending.size(),m_sink->bytesFree()));
+ if(written>0){m_pending.remove(0,written);m_writtenFrames+=written/8;}
+ });
+ m_meterTimer.setInterval(40);
+ connect(&m_meterTimer,&QTimer::timeout,this,[this]{bool alive=false;for(auto &p:m_outputPeak)p*=.77f;for(auto &c:m_channels){c.peak*=.77f;alive|=c.peak>.001f;}emit metersChanged();if(!alive&&!m_player->playing())m_meterTimer.stop();});
+ updateRoute();
+}
+Tx6::~Tx6() { m_player->attachMixer(nullptr);flush(); }
+bool Tx6::active() const { return m_visible&&m_powered&&m_available&&m_player->medium()=="tp7"; }
+QString Tx6::status() const { return !m_powered?"OFF":!m_available?"LOCAL ONLY":active()?"USB 1–12":"BYPASS"; }
+QVariantList Tx6::channels() const {
+ QVariantList rows;
+ for(const auto &c:m_channels)rows.append(QVariantMap{{"name",c.name},{"loaded",!c.name.isEmpty()},{"loading",c.loading},{"level",c.level},{"high",c.eq[0]},{"mid",c.eq[1]},{"low",c.eq[2]},{"mute",c.mute},{"solo",c.solo}});
+ return rows;
+}
+QVariantList Tx6::meters() const { QVariantList result;for(const auto &c:m_channels)result.append(double(c.peak));return result; }
+void Tx6::updateRoute(){flush();m_player->refreshMixerRoute();emit changed();}
+void Tx6::setVisible(bool v){if(v==m_visible)return;m_visible=v;m_settings.setValue("tx6Visible",v);updateRoute();}
+void Tx6::setPowered(bool v){if(v==m_powered)return;m_powered=v;updateRoute();}
+void Tx6::setAvailable(bool v){if(v==m_available)return;m_available=v;updateRoute();}
+void Tx6::setDelay(bool v){if(v==m_delay)return;m_delay=v;if(!v)m_echo.fill(0);emit changed();}
+void Tx6::setCompressor(bool v){if(v==m_compressor)return;m_compressor=v;emit changed();}
+void Tx6::setLevel(int c,double v){if(c<0||c>=6||!std::isfinite(v))return;m_channels[c].level=std::clamp(v,0.,1.);emit changed();}
+void Tx6::setEq(int c,int b,double v){if(c<0||c>=6||b<0||b>=3||!std::isfinite(v))return;m_channels[c].eq[b]=std::clamp(v,-12.,12.);coefficients(c,b);emit changed();}
+void Tx6::toggleMute(int c){if(c<0||c>=6)return;m_channels[c].mute=!m_channels[c].mute;emit changed();}
+void Tx6::toggleSolo(int c){if(c<0||c>=6)return;m_channels[c].solo=!m_channels[c].solo;emit changed();}
+void Tx6::reset(){for(int c=0;c<6;++c){m_channels[c].level=1;m_channels[c].mute=false;m_channels[c].solo=false;for(int b=0;b<3;++b)setEq(c,b,0);}m_delay=false;m_compressor=false;flush();emit changed();}
+void Tx6::fail(const QString &s){emit feedback(s,true);}
+void Tx6::load(int c,const QUrl &url) {
+ if(c<1||c>=6||!url.isLocalFile()||!QFileInfo(url.toLocalFile()).isFile()){fail("Choose a local audio file for channels 2–6.");return;}
+ auto &ch=m_channels[c];ch.decoder.reset();ch.pending.reset();ch.loading=false;
+ ch.pending=std::make_unique<QTemporaryFile>();
+ if(!ch.pending->open()){ch.pending.reset();fail("Could not prepare a temporary mixer track.");return;}
+ ch.loading=true;ch.decoder=std::make_unique<QAudioDecoder>();
+ auto *decoder=ch.decoder.get();decoder->setAudioFormat(format());
+ auto cancel=[this,c,decoder](const QString &error){auto &ch=m_channels[c];if(ch.decoder.get()!=decoder)return;decoder->stop();ch.decoder.release()->deleteLater();ch.pending.reset();ch.loading=false;emit changed();fail(error);};
+ connect(decoder,&QAudioDecoder::bufferReady,this,[this,c,decoder,cancel]{
+ if(m_channels[c].decoder.get()!=decoder)return;
+ auto buffer=decoder->read();auto &ch=m_channels[c];
+ if(buffer.format()!=format()){cancel("This decoder cannot supply stereo 48 kHz audio to the mixer.");return;}
+ // Keep RAM bounded. Stems are streamed from private, automatically removed PCM files.
+ if(ch.pending->size()+buffer.byteCount()>512LL*1024*1024){cancel("This stem exceeds the mixer’s 23-minute stereo limit. Choose a shorter file.");return;}
+ if(ch.pending->write(buffer.constData<char>(),buffer.byteCount())!=buffer.byteCount())cancel("Could not write the mixer’s temporary audio cache.");
+ });
+ connect(decoder,&QAudioDecoder::finished,this,[this,c,decoder,url]{auto &ch=m_channels[c];if(ch.decoder.get()!=decoder)return;ch.pending->flush();ch.pcm=std::move(ch.pending);ch.name=QFileInfo(url.toLocalFile()).completeBaseName();ch.loading=false;ch.decoder.release()->deleteLater();emit changed();emit feedback("Channel "+QString::number(c+1)+" ready · follows TP-7 transport",false);});
+ connect(decoder,qOverload<QAudioDecoder::Error>(&QAudioDecoder::error),this,[decoder,cancel](QAudioDecoder::Error){cancel("Could not decode this mixer track: "+decoder->errorString());});
+ decoder->setSource(url);decoder->start();emit changed();
+}
+void Tx6::unload(int c){if(c<1||c>=6)return;auto &ch=m_channels[c];ch.decoder.reset();ch.pending.reset();ch.pcm.reset();ch.name.clear();ch.loading=false;ch.peak=0;emit changed();}
+float Tx6::Filter::run(float x,int c){const double y=b0*x+z1[c];z1[c]=b1*x-a1*y+z2[c];z2[c]=b2*x-a2*y;return float(y);}
+void Tx6::coefficients(int c,int b){
+ auto &f=m_channels[c].filters[b];const double db=m_channels[c].eq[b];
+ const double A=std::pow(10.,db/40.),w=2*M_PI*(b==0?8000:b==1?1000:160)/48000.,co=std::cos(w),si=std::sin(w);
+ double b0,b1,b2,a0,a1,a2;
+ if(b==1){const double alpha=si/1.4;b0=1+alpha*A;b1=-2*co;b2=1-alpha*A;a0=1+alpha/A;a1=-2*co;a2=1-alpha/A;}
+ else {const double beta=2*std::sqrt(A)*si/std::sqrt(2.);
+ if(b==2){b0=A*((A+1)-(A-1)*co+beta);b1=2*A*((A-1)-(A+1)*co);b2=A*((A+1)-(A-1)*co-beta);a0=(A+1)+(A-1)*co+beta;a1=-2*((A-1)+(A+1)*co);a2=(A+1)+(A-1)*co-beta;}
+ else {b0=A*((A+1)+(A-1)*co+beta);b1=-2*A*((A-1)+(A+1)*co);b2=A*((A+1)+(A-1)*co-beta);a0=(A+1)-(A-1)*co+beta;a1=2*((A-1)-(A+1)*co);a2=(A+1)-(A-1)*co-beta;}
+ }
+ f.b0=b0/a0;f.b1=b1/a0;f.b2=b2/a0;f.a1=a1/a0;f.a2=a2/a0;
+}
+QByteArray Tx6::process(const QAudioBuffer &buffer){
+ if(!buffer.isValid()||buffer.format()!=format())return {};
+ const int frames=buffer.frameCount();const auto *in=buffer.constData<float>();
+ QByteArray result(buffer.byteCount(),0);auto *out=reinterpret_cast<float*>(result.data());
+ const bool solo=std::any_of(m_channels.begin(),m_channels.end(),[](const auto &c){return c.solo;});
+ std::array<QByteArray,6> stems;
+ for(int c=1;c<6;++c)if(m_channels[c].pcm){auto &f=*m_channels[c].pcm;const auto offset=std::max<qint64>(0,qRound64(buffer.startTime()*48000./1000000.))*8;if(f.seek(offset))stems[c]=f.read(buffer.byteCount());}
+ for(int i=0;i<frames;++i){float mix[2]{};
+ for(int c=0;c<6;++c){auto &ch=m_channels[c];const float target=ch.mute||(solo&&!ch.solo)?0:ch.level;ch.smoothed+=(target-ch.smoothed)*.004;
+ for(int side=0;side<2;++side){float sample=c==0?in[i*2+side]:stems[c].size()>=(i+1)*8?reinterpret_cast<const float*>(stems[c].constData())[i*2+side]:0;
+ if(!std::isfinite(sample))sample=0;
+ for(auto &filter:ch.filters)sample=filter.run(sample,side);
+ sample*=ch.smoothed;ch.peak=std::max(ch.peak,std::abs(sample));mix[side]+=sample;
+ }
+ }
+ const float peak=std::max(std::abs(mix[0]),std::abs(mix[1]));m_envelope+=(peak-m_envelope)*(peak>m_envelope?.02f:.0003f);
+ const float gain=m_compressor&&m_envelope>.35f?std::pow(.35f/m_envelope,.75f):1;
+ m_master+=(m_player->volume()-m_master)*.004;
+ for(int side=0;side<2;++side){float sample=mix[side]*gain;
+ if(m_delay){const float echo=m_echo[m_echoCursor];m_echo[m_echoCursor]=sample+echo*.32f;sample+=echo*.23f;m_echoCursor=(m_echoCursor+1)%m_echo.size();}
+ // The master has a peak safety ceiling, not a makeup-gain boost.
+ out[i*2+side]=std::clamp(float(sample*m_master),-1.f,1.f);
+ m_outputPeak[side]=std::max(m_outputPeak[side],std::abs(out[i*2+side]));
+ }
+ }
+ if(!m_meterTimer.isActive())m_meterTimer.start();
+ return result;
+}
+void Tx6::consume(const QAudioBuffer &buffer){
+ if(!active()||!buffer.isValid()||!m_player->playing())return;
+ if(buffer.format()!=format()){setPowered(false);fail("Mixer bypassed: this audio backend does not provide stereo PCM.");return;}
+ auto pcm=process(buffer);if(!m_outputEnabled)return;
+ if(!m_sink){const auto device=QMediaDevices::defaultAudioOutput();if(device.isNull()||!device.isFormatSupported(format())){setPowered(false);fail("Mixer bypassed: no stereo 48 kHz output is available.");return;}
+ m_sink=std::make_unique<QAudioSink>(device,format());m_sink->setBufferSize(16384);m_output=m_sink->start();
+ if(!m_output){setPowered(false);fail("Could not start mixer output. Normal playback restored.");return;}m_pump.start();
+ }
+ if(m_pending.size()+pcm.size()>128000){setPowered(false);fail("Mixer bypassed after an audio output interruption.");return;}
+ m_pending.append(pcm);
+}
+void Tx6::flush(){m_pump.stop();m_output=nullptr;if(m_sink)m_sink->stop();m_sink.reset();m_pending.clear();m_echo.fill(0);m_echoCursor=0;m_envelope=0;m_outputPeak[0]=m_outputPeak[1]=0;m_master=m_player->volume();for(auto &c:m_channels){c.peak=0;for(auto &f:c.filters){std::fill_n(f.z1,2,0);std::fill_n(f.z2,2,0);}}emit metersChanged();}
diff --git a/src/tx6.h b/src/tx6.h
new file mode 100644
index 0000000..2cfe86c
--- /dev/null
+++ b/src/tx6.h
@@ -0,0 +1,91 @@
+#pragma once
+#include <QObject>
+#include <QAudioBuffer>
+#include <QAudioBufferOutput>
+#include <QAudioDecoder>
+#include <QAudioSink>
+#include <QTemporaryFile>
+#include <QSettings>
+#include <QTimer>
+#include <array>
+#include <memory>
+
+class Player;
+// The USB link is represented in the UI. Audio stays inside Spun: the decoded
+// TP-7 stream supplies the clock for all six stereo channels.
+class Tx6 : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY changed)
+ Q_PROPERTY(bool powered READ powered WRITE setPowered NOTIFY changed)
+ Q_PROPERTY(bool available READ available WRITE setAvailable NOTIFY changed)
+ Q_PROPERTY(bool active READ active NOTIFY changed)
+ Q_PROPERTY(QVariantList channels READ channels NOTIFY changed)
+ Q_PROPERTY(QVariantList meters READ meters NOTIFY metersChanged)
+ Q_PROPERTY(QVariantList stereoMeters READ stereoMeters NOTIFY metersChanged)
+ Q_PROPERTY(bool delay READ delay WRITE setDelay NOTIFY changed)
+ Q_PROPERTY(bool compressor READ compressor WRITE setCompressor NOTIFY changed)
+ Q_PROPERTY(QString status READ status NOTIFY changed)
+public:
+ explicit Tx6(Player *player, const QString &settings, bool outputEnabled = true);
+ ~Tx6() override;
+ bool visible() const { return m_visible; }
+ bool powered() const { return m_powered; }
+ bool available() const { return m_available; }
+ bool active() const;
+ qint64 writtenFrames() const { return m_writtenFrames; }
+ bool delay() const { return m_delay; }
+ bool compressor() const { return m_compressor; }
+ QString status() const;
+ QVariantList channels() const;
+ QVariantList meters() const;
+ QVariantList stereoMeters() const { return {double(m_outputPeak[0]),double(m_outputPeak[1])}; }
+ void setVisible(bool value);
+ void setPowered(bool value);
+ void setAvailable(bool value);
+ void setDelay(bool value);
+ void setCompressor(bool value);
+ Q_INVOKABLE void setLevel(int channel, double value);
+ Q_INVOKABLE void setEq(int channel, int band, double db);
+ Q_INVOKABLE void toggleMute(int channel);
+ Q_INVOKABLE void toggleSolo(int channel);
+ Q_INVOKABLE void load(int channel, const QUrl &file);
+ Q_INVOKABLE void unload(int channel);
+ Q_INVOKABLE void reset();
+ void consume(const QAudioBuffer &buffer);
+ void flush();
+ static QAudioFormat format();
+ QByteArray process(const QAudioBuffer &buffer); // Deterministic PCM path, also exercised by diagnostics.
+signals:
+ void changed();
+ void metersChanged();
+ void feedback(const QString &message, bool error);
+private:
+ struct Filter { double b0=1,b1=0,b2=0,a1=0,a2=0,z1[2]{},z2[2]{}; float run(float x,int c); };
+ struct Channel {
+ double level=1, smoothed=1;
+ std::array<double,3> eq{};
+ std::array<Filter,3> filters;
+ bool mute=false,solo=false,loading=false;
+ float peak=0;
+ QString name;
+ std::unique_ptr<QTemporaryFile> pcm, pending;
+ std::unique_ptr<QAudioDecoder> decoder;
+ };
+ void updateRoute();
+ void coefficients(int channel, int band);
+ void fail(const QString &message);
+ Player *m_player;
+ QSettings m_settings;
+ std::array<Channel,6> m_channels;
+ bool m_visible=false,m_powered=true,m_available=true,m_delay=false,m_compressor=false,m_outputEnabled=true;
+ std::unique_ptr<QAudioSink> m_sink;
+ QIODevice *m_output=nullptr;
+ qint64 m_writtenFrames=0;
+ QByteArray m_pending;
+ QTimer m_pump,m_meterTimer;
+ std::array<float,48000> m_echo{};
+ size_t m_echoCursor=0;
+ float m_envelope=0;
+ float m_outputPeak[2]{};
+ double m_master=0.65;
+};
diff --git a/src/tx6test.cpp b/src/tx6test.cpp
new file mode 100644
index 0000000..c832337
--- /dev/null
+++ b/src/tx6test.cpp
@@ -0,0 +1,104 @@
+#include "tx6test.h"
+#include "tx6.h"
+#include "player.h"
+#include "testcapture.h"
+#include <QQuickItem>
+#include <QQuickWindow>
+#include <QQmlContext>
+#include <QTest>
+#include <QDataStream>
+#include <QDir>
+#include <iostream>
+#include <cmath>
+
+namespace {
+QAudioBuffer tone(double hz,double amplitude=.1,int frames=48000,qint64 start=0){QByteArray b(frames*8,0);auto *p=reinterpret_cast<float*>(b.data());for(int i=0;i<frames;++i)p[i*2]=p[i*2+1]=amplitude*std::sin(i*2*M_PI*hz/48000.);return QAudioBuffer(b,Tx6::format(),start);}
+double rms(const QByteArray &b){if(b.isEmpty())return 0;const auto *p=reinterpret_cast<const float*>(b.constData());int size=b.size()/4;double power=0;for(int i=size/2;i<size;++i)power+=p[i]*p[i];return std::sqrt(power/(size-size/2));}
+bool until(const std::function<bool()> &f){QElapsedTimer t;t.start();while(!f()&&t.elapsed()<6000)QTest::qWait(20);return f();}
+QQuickItem *find(QQuickItem *root,const QString &name){if(root->objectName()==name)return root;for(auto *child:root->childItems())if(auto *result=find(child,name))return result;return nullptr;}
+}
+int exerciseTx6(Player &player,Tx6 &mixer,QQuickWindow *window,const QString &temp,const QString &captures){
+ int checks=0,failures=0;auto check=[&](bool ok,const char *text){++checks;if(!ok)++failures;std::cout<<(ok?"PASS ":"FAIL ")<<text<<std::endl;return ok;};
+ auto invoke=[](QObject *o,const char *method){return o&&QMetaObject::invokeMethod(o,method);};
+ player.setMedium("tp7");player.setMiniMode(false);player.setThreeD(false);player.setVolume(1);window->setProperty("useCider",false);window->setColor(QColor("#242a30"));mixer.setVisible(true);mixer.setPowered(true);mixer.reset();
+ check(mixer.active(),"USB software route is active only in TP-7 view");
+ auto dry=tone(1000);check(std::abs(rms(mixer.process(dry))-.07071)<.001,"neutral mixer preserves PCM level");
+ for(int band=0;band<3;++band){mixer.reset();mixer.setEq(0,band,-12);check(rms(mixer.process(tone(band==0?18000:band==1?1000:40)))<.025,"each EQ band attenuates its frequency range");}
+ mixer.reset();mixer.setLevel(0,.25);check(std::abs(rms(mixer.process(dry))-.01768)<.001,"channel fader changes actual PCM gain");
+ mixer.toggleMute(0);check(rms(mixer.process(dry))<.00001,"mute silences PCM after de-click ramp");
+ mixer.reset();mixer.toggleSolo(1);check(rms(mixer.process(dry))<.00001,"solo suppresses all other channels");
+ mixer.reset();mixer.process(tone(1000,0));mixer.setDelay(true);auto impulse=tone(1000,0,48000);auto impulseData=impulse.data<float>();impulseData[0]=impulseData[1]=.4;mixer.process(impulse);auto tail=mixer.process(tone(1000,0,48000));check(rms(tail)>0.000001,"delay produces a decaying audible tail");
+ mixer.reset();mixer.setCompressor(true);check(rms(mixer.process(tone(1000,.9)))<.42,"compressor reduces hot signals");
+ mixer.reset();mixer.setEq(0,1,12);auto loud=mixer.process(tone(1000,1));bool finite=true;for(int i=0;i<loud.size()/4;++i){const auto x=reinterpret_cast<const float*>(loud.constData())[i];finite&=std::isfinite(x)&&std::abs(x)<=1;}check(finite,"master output remains finite and bounded");
+ mixer.reset();player.setVolume(0);check(rms(mixer.process(dry))<.00001,"master volume reaches silence");
+ const auto stem=temp+"/tx6-fixture.wav";QFile f(stem);if(!f.open(QIODevice::WriteOnly))return 2;QDataStream out(&f);out.setByteOrder(QDataStream::LittleEndian);const int n=48000*4;out.writeRawData("RIFF",4);out<<quint32(36+n*4);out.writeRawData("WAVEfmt ",8);out<<quint32(16)<<quint16(1)<<quint16(2)<<quint32(48000)<<quint32(192000)<<quint16(4)<<quint16(16);out.writeRawData("data",4);out<<quint32(n*4);for(int i=0;i<n;++i){qint16 sample=3200*std::sin(i*2*M_PI*440/48000.);out<<sample<<sample;}f.close();
+ for(int c=1;c<6;++c)mixer.load(c,QUrl::fromLocalFile(stem));
+ check(until([&]{for(const auto &v:mixer.channels())if(v.toMap().value("loading").toBool())return false;return true;}),"five optional inputs finish decoding");
+ player.setVolume(1);mixer.flush();
+ for(int c=1;c<6;++c){mixer.reset();mixer.toggleSolo(c);check(rms(mixer.process(tone(1000,0)))>.06,"each imported channel contributes real samples");check(rms(mixer.process(tone(1000,0,48000,6000000)))<.0001,"stem ends silently and follows transport timestamp");}
+ mixer.reset();for(int c=1;c<6;++c)mixer.unload(c);check(!mixer.channels()[1].toMap().value("loaded").toBool(),"unloading releases input");
+ player.addUrls({QUrl::fromLocalFile(stem)},false);check(until([&]{return player.count()>0&&!player.busy();}),"TP-7 local fixture loaded");player.setVolume(0);mixer.flush();player.play();check(until([&]{return mixer.meters()[0].toDouble()>.01;}),"QMediaPlayer decoded audio actually reaches mixer");if(qEnvironmentVariableIsSet("SPUN_TEST_MIXER_OUTPUT"))check(until([&]{return mixer.writtenFrames()>0;}),"processed PCM reaches the native audio output");player.pause();
+ player.setMotion(true);auto *typography=qmlContext(window)->contextProperty("typography").value<QObject*>();typography->setProperty("uiScale",1.25);
+ auto capture=[&](const QString &name){if(captures.isEmpty())return;QTest::mouseMove(window,{4,4});QTest::qWait(100);QDir().mkpath(captures);auto image=captureTestWindow(window);check(!image.isNull()&&image.save(captures+"/"+name+".png"),"rendered capture saved");};
+ for(bool threeD:{false,true}){
+ if(threeD&&!qmlContext(window)->contextProperty("supports3D").toBool())continue;
+ player.setThreeD(threeD);QTest::qWait(400);auto *controls=find(window->contentItem(),"tx6Controls"),*view=find(window->contentItem(),"player3DView");
+ if(!check(controls&&(!threeD||view),"mixer and renderer load"))return 2;
+ capture(threeD?"tx6-3d":"tx6-2d");
+ const auto point=[&](int index){if(threeD){QVariant r;QMetaObject::invokeMethod(view,"projectTx6Control",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,index));return view->mapToScene(r.toPointF()).toPoint();}auto *key=find(window->contentItem(),"tx6Control"+QString::number(index));return key->mapToScene({key->width()/2,key->height()/2}).toPoint();};
+ if(qEnvironmentVariableIsSet("SPUN_TEST_CAPTURE_ONLY")){if(threeD){view->setProperty("recorderYaw",70.);QTest::qWait(180);capture("tx6-side");view->setProperty("recorderYaw",172.);QTest::qWait(180);capture("tx6-back");}continue;}
+ for(int i=0;i<34;++i){if(threeD)QTest::qWait(450);const auto p=point(i);auto *key=find(window->contentItem(),"tx6Control"+QString::number(i));
+ if(threeD){QVariant hit;const auto loc=view->mapFromScene(p);QMetaObject::invokeMethod(view,"recorderHit",Q_RETURN_ARG(QVariant,hit),Q_ARG(QVariant,loc.x()),Q_ARG(QVariant,loc.y()));check(hit.toMap().value("tx6",-1).toInt()==i,"3D visible control is correctly picked");}
+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,p);check(until([&]{return controls->property("pressedControl").toInt()==i&&key->property("pressure").toDouble()>.4;}),"press animation reaches travel");check(controls->property("pressedControl").toInt()==i&&key->property("pressure").toDouble()>.4,"hardware pressure is applied while held");
+ if(i==31)capture(threeD?"tx6-3d-pressed":"tx6-2d-pressed");
+ QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,p);check(until([&]{return controls->property("pressedControl").toInt()==-1&&key->property("pressure").toDouble()<.4;}),"return animation settles");check(controls->property("pressedControl").toInt()==-1&&key->property("pressure").toDouble()<.4,"hardware springs back after release");
+ }
+ QTest::qWait(450);QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,point(34));check(!mixer.powered(),"side power button bypasses mixer");QTest::qWait(450);QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,point(34));check(mixer.powered(),"side power button reconnects mixer");
+ mixer.reset();
+ QTest::qWait(450);auto p=point(18);QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,p);const auto dest=p+QPoint(0,45);QMouseEvent e(QEvent::MouseMove,dest,window->mapToGlobal(dest),Qt::NoButton,Qt::LeftButton,Qt::NoModifier);QGuiApplication::sendEvent(window,&e);QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,dest);check(mixer.channels()[0].toMap().value("level").toDouble()<.8,"dragging physical fader changes channel gain");
+ QTest::qWait(450);p=point(24);QTest::mouseClick(window,Qt::LeftButton,Qt::ShiftModifier,p);check(mixer.channels()[0].toMap().value("solo").toBool(),"Shift click solos a channel");
+ QTest::qWait(450);QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,point(33));check(controls->property("shiftHeld").toBool(),"physical Shift button arms solo with a mouse");
+ QTest::qWait(450);QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,point(25));check(mixer.channels()[1].toMap().value("solo").toBool()&&!controls->property("shiftHeld").toBool(),"next channel consumes the one-shot solo modifier");
+ p=point(30);QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,p);invoke(controls,"cancel");check(controls->property("pressedControl").toInt()==-1,"cancel clears pressure and gesture state");QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,p);
+ if(threeD){
+ check(window->property("layoutWidth").toInt()==740 && view->width()==740,"paired view reserves a wider interaction area");
+ const auto face=[&](double x,double y){QVariant r;QMetaObject::invokeMethod(view,"projectTx6Face",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,x),Q_ARG(QVariant,y));return view->mapToScene(r.toPointF()).toPoint();};
+ const auto hitAt=[&](QPoint p){QVariant r;const auto local=view->mapFromScene(p);QMetaObject::invokeMethod(view,"recorderHit",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,local.x()),Q_ARG(QVariant,local.y()));return r.toMap().value("tx6",-1).toInt();};
+ const auto faceWidth=QLineF(face(0,176),face(244,176)).length()/window->property("uiScale").toDouble();
+ std::cout<<"Mixer face width: "<<faceWidth<<" logical pixels"<<std::endl;
+ check(faceWidth>210,"mixer is visibly larger than the former compact model");
+ for(int index=0;index<18;++index)check(hitAt(point(index)+QPoint(11,0))==index,"near-edge knob click picks its nearest channel");
+ mixer.reset();
+ for(int channel=0;channel<6;++channel){
+ QTest::qWait(450);const auto rail=face(22+channel*29.3,260);QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,rail);
+ check(std::abs(mixer.channels()[channel].toMap().value("level").toDouble()-25./77)<.04,"clicking anywhere along a fader rail sets that channel only");
+ }
+ const auto nearKnob=point(0)+QPoint(11,0);QTest::qWait(450);QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,nearKnob);
+ check(controls->property("pressedControl").toInt()==0 && !view->property("orbiting").toBool(),"forgiving knob grab does not start orbiting");
+ const auto knobDest=nearKnob+QPoint(0,-30);QMouseEvent knobMove(QEvent::MouseMove,knobDest,window->mapToGlobal(knobDest),Qt::NoButton,Qt::LeftButton,Qt::NoModifier);QGuiApplication::sendEvent(window,&knobMove);QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,knobDest);
+ check(mixer.channels()[0].toMap().value("high").toDouble()>1 && mixer.channels()[1].toMap().value("high").toDouble()==0,"near-edge drag changes only the intended EQ knob");
+ QTest::qWait(450);QTest::mouseClick(window,Qt::RightButton,Qt::NoModifier,point(1));
+ auto *channelMenu=controls->findChild<QObject*>("tx6ChannelMenu");auto *settingsMenu=window->findChild<QObject*>("settingsMenu");
+ check(until([&]{return channelMenu&&channelMenu->property("visible").toBool();}) && settingsMenu && !settingsMenu->property("visible").toBool(),"channel right-click stays open without the main menu stealing it");
+ QTest::qWait(250);auto *soloItem=find(window->contentItem(),"tx6SoloAction");
+ if(check(soloItem&&soloItem->isVisible()&&soloItem->isEnabled(),"channel menu action is usable in 3D"))QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,soloItem->mapToScene({soloItem->width()/2,soloItem->height()/2}).toPoint());
+ check(until([&]{return mixer.channels()[1].toMap().value("solo").toBool();}),"channel context menu acts on the selected channel");
+ if(channelMenu)invoke(channelMenu,"close");
+ QTest::qWait(150);
+ view->setProperty("recorderYaw",45.);QTest::qWait(450);
+ check(hitAt(point(6)+QPoint(7,0))==6,"assisted picking follows the rotated mixer");
+ view->setProperty("recorderYaw",180.);QTest::qWait(450);
+ check(hitAt(face(22,60))<0,"rear-face clicks cannot reach the front knobs");
+ invoke(view,"resetRecorderOrientation");QTest::qWait(450);
+ QTest::qWait(450);QVariant r;QMetaObject::invokeMethod(view,"projectRecorderControl",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,1));
+ const auto playPoint=view->mapToScene(r.toPointF()).toPoint();QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,playPoint);
+ check(until([&]{return player.playing();}),"paired TP-7 transport still plays through the mixer");player.pause();
+ view->setProperty("recorderYaw",58.);view->setProperty("recorderPitch",14.);QTest::qWait(200);capture("tx6-side");view->setProperty("recorderYaw",172.);QTest::qWait(200);capture("tx6-back");invoke(view,"resetRecorderOrientation");}
+ window->setProperty("useCider",true);check(!mixer.active(),"Cider source bypasses unsupported local DSP");window->setProperty("useCider",false);
+ mixer.setVisible(false);check(!mixer.active(),"hiding mixer restores normal playback route");
+ check(window->property("layoutWidth").toInt()==530,"hiding mixer restores compact window width");
+ mixer.setVisible(true);QTest::qWait(150);
+ }
+ player.pause();mixer.reset();player.setMedium("cd");check(!mixer.active(),"leaving TP-7 restores direct audio");
+ std::cout<<checks<<" checks, "<<failures<<" failures"<<std::endl;return failures?1:0;
+}
diff --git a/src/tx6test.h b/src/tx6test.h
new file mode 100644
index 0000000..8f412ca
--- /dev/null
+++ b/src/tx6test.h
@@ -0,0 +1,4 @@
+#pragma once
+#include <QString>
+class Player;class Tx6;class QQuickWindow;
+int exerciseTx6(Player &,Tx6 &,QQuickWindow *,const QString &,const QString &);