A CD-shaped music player for Linux, with local playback and Cider integration.
Add TP-7 players and refine the 3D turntable
yappologistic0fc48dfc9c1c
diff --git a/CMakeLists.txt b/CMakeLists.txtindex b398804..c3c2d9c 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -46,7 +46,7 @@ qt_add_library(spun_core STATICsrc/listening.cpp src/listening.h src/tapesound.cpp src/tapesound.h src/vinylnoise.cpp src/vinylnoise.hsrc/musicactions.cpp src/musicactions.hsrc/library.cpp src/library.h src/lyrics.cpp src/lyrics.h src/artwork.cpp src/artwork.h- src/player.cpp src/player.h src/disc.cpp src/disc.h src/playerbody.cpp src/playerbody.h src/mpris.cpp src/mpris.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.hsrc/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::QuickControls2Qt6::Svg Qt6::Multimedia Qt6::Concurrent Qt6::DBus Qt6::Network PkgConfig::TAGLIB)@@ -54,7 +54,7 @@ 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_link_libraries(spun_core PUBLIC Qt6::Quick3D)target_compile_definitions(spun_core PUBLIC SPUN_WITH_3D=1)- set(SPUN_3D_QML qml/Player3D.qml)+ set(SPUN_3D_QML qml/Player3D.qml qml/Recorder3D.qml qml/Vinyl3D.qml)endif()target_compile_definitions(spun_core PUBLIC SPUN_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")target_compile_options(spun_core PRIVATE -Wall -Wextra -Wpedantic)@@ -77,7 +77,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_PLUGINNO_RESOURCE_TARGET_PATH RESOURCE_PREFIX "/" OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${target}-qml"- QML_FILES ${SPUN_3D_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/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 +104,7 @@ 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)+ 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_compile_definitions(spun-diagnostics PRIVATE SPUN_DIAGNOSTICS)target_link_libraries(spun-diagnostics PRIVATE Qt6::Test)if(TARGET Qt6::Quick3D AND SPUN_ENABLE_3D)diff --git a/README.md b/README.mdindex 042c0f5..3f84552 100644--- a/README.md+++ b/README.md@@ -22,7 +22,7 @@<a href="#license">License</a></p>-Play local music or control Apple Music through Cider. Spun puts your album artwork on a spinning CD, vinyl record or cassette, with an interface inspired by Material Design 3. Optional 3D players add physical depth and lighting that follows Noctalia's wallpaper palette.+Play local music or control Apple Music through Cider. Spun puts your album artwork on a spinning CD, vinyl record, cassette or TP-7-inspired recorder, with an interface inspired by Material Design 3. Optional 3D players add physical depth and lighting that follows Noctalia's wallpaper palette.**Source-available · PolyForm Noncommercial 1.0.0.** Personal and other permitted noncommercial use is free. This is not an OSI-approved open-source license. [Read the license details](#license).@@ -68,18 +68,19 @@ Spun connects to the local API on port 10767. Basic playback controls use Linux'## Inside the player-### CD, vinyl and cassette+### CD, vinyl, cassette and TP-7-Choose a medium in **More → Preferences**. All three share playback controls, album details, lyrics and Mini mode.+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.-- **Vinyl:** a record with grooves, a gold tonearm and Relaxed, 33⅓ or 45 RPM rotation. Drag the needle to seek and play. Optional effects include crackle, hiss and groove skips.+- **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.+- **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 horizontal bar always seeks within the current song.-- **Reverse view:** double-click the medium or press **F** for album details and tracks. 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.+- **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.- **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.### Browse through Cider@@ -187,13 +188,13 @@ ctest --test-dir build --output-on-failureTests use temporary preferences and synthetic local API fixtures. Audio checks need a working user audio session, and API fixtures need permission to listen on loopback. Desktop-control tests use a private D-Bus session. Diagnostics are separate from the normal player.-For focused artwork, lighting, geometry and media checks:+For focused player, artwork, lighting, geometry and media checks:```bash./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 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 recorder and turntable controls, 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.diff --git a/qml/Main.qml b/qml/Main.qmlindex 842b555..764b1d7 100644--- a/qml/Main.qml+++ b/qml/Main.qml@@ -30,12 +30,14 @@ ApplicationWindow {onThreeDActiveChanged: { cancel3DPointer(); cancelSeekPreview(); scrubber.cancelScrub(); stopSwap(); Qt.callLater(updateMask) }readonly property var tonearm: armLoader.itemproperty var threeDPointer: null+ readonly property bool threeDHardwarePressed: !!(scene3D.item && scene3D.item.hardwareActive)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}}function controlAt3DPoint(point) {if(menuOpen || swapRunning)return null+ if(recorder && recorderView)return recorderView.controlAt(recorderView.mapFromItem(mediaSurface,point.x,point.y))let control=nullif(vinyl && tonearm && tonearm.canSeek) {const p=tonearm.mapFromItem(mediaSurface,point.x,point.y),tip=tonearm.pointerInput.tip@@ -51,22 +53,24 @@ ApplicationWindow {}return control}- function begin3DPointer(point, modifiers) {+ function begin3DPointer(point, modifiers, hitControl) {cancel3DPointer()- const control=controlAt3DPoint(point)+ const control=(recorder || vinyl) ? hitControl : hitControl || controlAt3DPoint(point)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() { const control=threeDPointer;threeDPointer=null;if(control)control.cancelPointer() }- readonly property bool bodyVisible: (player.showPlayerBody || threeDRequested) && !miniMode- readonly property real mediumScale: bodyVisible && !discFlipped ? .86 : 1+ function cancel3DPointer() { 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 : 1readonly property color cassetteShell: player.cassetteFinish === "cream" ? "#bab29c" : player.cassetteFinish === "clear" ? "#b06f8285" : root.surfaceproperty real lidOpen: 0property real packageOpacity: 0onBodyVisibleChanged: Qt.callLater(function() { stopSwap(); cancelSeekPreview(); updateMask() })+ readonly property bool recorder: player.medium === "tp7"+ readonly property var recorderView: recorderLoader.itemreadonly property bool cassette: player.medium === "cassette"onCassetteChanged: Qt.callLater(function() { stopSwap(); scrubber.cancelScrub(); updateMask() })readonly property bool vinyl: player.vinyl@@ -82,7 +86,7 @@ ApplicationWindow {if (crossfadeMenu.visible) { crossfadeMenu.service.refreshCrossfade(); crossfadeMenu.service.refreshAudioOptions() }if (qualityPopup.visible) root.ciderService.refreshAudioQuality()}- Connections { target: player; function onMediumChanged() { root.cancel3DPointer(); root.spinSpeed = 0; root.stopSwap(); Qt.callLater(root.updateMask) } function onSettingsChanged() { if (!player.vinylAlbumMode || !player.vinyl) root.listeningService.cancelAlbumPosition() } }+ Connections { target: player; function onMediumChanged() { root.cancel3DPointer(); root.cancelSeekPreview(); root.spinSpeed = 0; root.stopSwap(); Qt.callLater(root.updateMask) } function onSettingsChanged() { if (!player.vinylAlbumMode || !player.vinyl) root.listeningService.cancelAlbumPosition() } }Connections { target: root.listeningService; function onFeedback(message, error) { root.notifyAction(message, error) } }Connections { target: root.ciderService; function onRemoteSettingsChanged() { root.refreshOpenCiderDetails() } }Timer {@@ -127,7 +131,7 @@ ApplicationWindow {function stopSwap() { discSwap.stop(); resetSwap(); presentation.releaseOutgoing() }function presentDisc() {const albumKey = deckPlayer.count ? (useCider ? "cider:" : "local:") + (deckPlayer.albumKey || deckPlayer.title) : ""- presentation.present(deckPlayer.artwork, albumKey, animate && !discFlipped && visible && native.exposed)+ presentation.present(deckPlayer.artwork, albumKey, animate && !recorder && !discFlipped && visible && native.exposed)}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 }@@ -152,14 +156,11 @@ ApplicationWindow {return {rows: rows, total: total, current: current}}readonly property string recordKey: recordMap ? (useCider ? "cider:" : "local:") + recordMap.rows.map(row => (row.track.id || row.track.path) + ":" + row.duration).join("|") : ""- onRecordKeyChanged: scrubber.cancelScrub()+ onRecordKeyChanged: { cancelSeekPreview(); scrubber.cancelScrub() }readonly property real recordProgress: recordMap ? Math.max(0, Math.min(1, (recordMap.rows[recordMap.current].start + deckPlayer.position) / recordMap.total)) : progressreadonly property bool seekPreviewActive: !!activeSeekControl || scrubber.scrubbing || !!(tonearm && tonearm.dragging)readonly property real recordVisualProgress: {- if (activeSeekControl) {- const fraction=activeSeekControl.previewValue- return recordMap ? (recordMap.rows[recordMap.current].start + fraction*recordMap.rows[recordMap.current].duration)/recordMap.total : fraction- }+ if (activeSeekControl) return activeSeekControl.previewValueif (scrubber.scrubbing) return scrubber.previewFractionif (tonearm && tonearm.dragging) return tonearm.previewProgressif (tonearm && tonearm.landing) return tonearm.landingProgress@@ -179,6 +180,12 @@ ApplicationWindow {}return null}+ readonly property real seekDuration: recordMap ? recordMap.total : deckPlayer.duration+ function seekTimeline(fraction) {+ if (recordMap) return dropRecordNeedle(fraction)+ deckPlayer.seek(fraction * deckPlayer.duration)+ return true+ }function dropRecordNeedle(fraction) {const target = recordTarget(fraction)if (!target) return false@@ -506,7 +513,7 @@ ApplicationWindow {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: "M"; enabled: !root.editingText && !root.menuOpen; onActivated: root.toggleMute() }- Shortcut { sequence: "Escape"; onActivated: { if(root.threeDPointer) { 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: "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 } } }Shortcut { sequence: "F"; enabled: !root.editingText && !root.menuOpen; onActivated: root.flipDisc() }Shortcut { sequence: "F1"; enabled: !root.menuOpen; onActivated: root.helpOpen = !root.helpOpen }@@ -531,7 +538,7 @@ ApplicationWindow {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.cdDegreesPerSecond) : 0+ const target = root.deckPlayer.playing ? (root.vinyl ? root.vinylDegreesPerSecond : root.cassette ? 9 : root.recorder ? 36 : root.cdDegreesPerSecond) : 0root.spinSpeed += (target-root.spinSpeed)*Math.min(1,dt*2.2)if (!root.discFlipped) root.spinAngle = (root.spinAngle+root.spinSpeed*dt)%360const winding = root.cassette && root.activeSeekControl@@ -643,7 +650,7 @@ ApplicationWindow {PlayerBody {objectName: "playerBody"x: 45; y: 74; width: 440; height: 440- visible: root.bodyVisible && !root.discFlipped+ visible: root.bodyVisible && !root.recorder && !root.discFlippedmedium: player.medium; surface: root.surface}PlayerBody {@@ -677,7 +684,7 @@ ApplicationWindow {}// Shadow is circular, so the player keeps its silhouette on any wallpaper.Repeater {- model: root.cassette ? 0 : 7+ model: root.cassette || root.recorder ? 0 : 7Rectangle {required property int indexanchors.centerIn: parent@@ -695,7 +702,7 @@ ApplicationWindow {transform: Translate { x: root.outgoingOffset }sourceComponent: Item {Disc { cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl; anchors.fill: parent; artwork: presentation.outgoing; rotation: root.cassette ? 0 : root.outgoingAngle }- Disc { visible: !root.cassette; cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl; anchors.fill: parent; overlay: true }+ Disc { visible: !root.cassette && !root.recorder; cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl; anchors.fill: parent; overlay: true }Loader { anchors.fill: parent; active: root.cassette; sourceComponent: CassetteReels { app: root; outgoing: true } }}}@@ -719,12 +726,13 @@ ApplicationWindow {anchors.fill: parentDisc { cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl;id: face+ visible: !root.recorderobjectName: "discFace"anchors.fill: parentartwork: presentation.artworkrotation: root.cassette ? 0 : root.spinAngle}- Disc { visible: !root.cassette; cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl; anchors.fill: parent; overlay: true }+ Disc { visible: !root.cassette && !root.recorder; cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl; anchors.fill: parent; overlay: true }Loader {anchors.fill: parent; active: root.recordMap !== nullsourceComponent: Canvas {@@ -743,6 +751,7 @@ ApplicationWindow {}}}+ Loader { id: recorderLoader; objectName: "recorderLoader"; anchors.fill: parent; active: root.recorder; sourceComponent: Recorder { app: root } }Loader { objectName: "cassetteReelsLoader"; anchors.fill: parent; active: root.cassette; sourceComponent: CassetteReels { app: root } }}back: Item {@@ -1096,7 +1105,7 @@ ApplicationWindow {// The presenter has already installed the new outgoing image.// Stop the old sequence without releasing that new image.discSwap.stop(); root.resetSwap()- if (!root.animate || root.discFlipped || !root.visible || !native.exposed) { presentation.releaseOutgoing(); return }+ if (!root.animate || root.recorder || root.discFlipped || !root.visible || !native.exposed) { presentation.releaseOutgoing(); return }scrubber.cancelScrub(); root.outgoingAngle = root.spinAngle; root.outgoingCassetteLeftAngle = root.cassetteLeftAngle; root.outgoingCassetteRightAngle = root.cassetteRightAngleroot.swapOffset = 440; root.outgoingOffset = 0; root.outgoingOpacity = 1; root.incomingOpacity = 0root.packageOpacity = root.bodyVisible ? 1 : 0@@ -1127,7 +1136,7 @@ ApplicationWindow {ProgressRing {objectName: "progressRing"anchors.fill: parent- visible: !root.cassette && !(root.bodyVisible && root.discFlipped) && root.deckPlayer.count > 0+ visible: !root.cassette && !root.recorder && !(root.bodyVisible && root.discFlipped) && root.deckPlayer.count > 0progress: root.recordVisualProgressphase: root.wavePhaseamplitude: root.deckPlayer.playing ? 2.8 : 0@@ -1138,6 +1147,7 @@ ApplicationWindow {id: scrubberobjectName: "scrubber"preventStealing: true+ enabled: !root.recorder || root.discFlippedanchors.fill: parent// Reverse-side lyrics keep their hover input; the rim remains seekable.containmentMask: QtObject { function contains(point: point): bool { return !root.discFlipped || scrubber.onRim(point.x, point.y) } }@@ -1148,7 +1158,7 @@ ApplicationWindow {readonly property bool canSeek: !root.swapRunning && root.deckPlayer.duration > 0 && (!root.useCider || (root.ciderService.canSeek && !root.listeningService.busy))readonly property bool showPreview: canSeek && (scrubbing || (containsMouse && onRim(mouseX,mouseY)))cursorShape: canSeek && onRim(mouseX,mouseY) ? Qt.PointingHandCursor : Qt.ArrowCursor- function onRim(x,y) { let r=Math.hypot(x-220,y-220); return !root.cassette && !(root.bodyVisible && root.discFlipped) && r > 205 && r < 224 }+ function onRim(x,y) { let r=Math.hypot(x-220,y-220); return !root.cassette && !root.recorder && !(root.bodyVisible && root.discFlipped) && r > 205 && r < 224 }function updatePreview(x,y) {let a=Math.atan2(y-220,x-220)+Math.PI/2if (a < 0) a += 2*Math.PI@@ -1205,7 +1215,7 @@ ApplicationWindow {PlayerBody {objectName: "playerLid"x: 45; y: 74; width: 440; height: 440- visible: root.bodyVisible && !root.discFlipped && !root.threeDActive+ visible: root.bodyVisible && !root.recorder && !root.discFlipped && !root.threeDActivemedium: player.medium; surface: root.surface; part: 1opacity: 1 - .75*root.lidOpentransform: Scale { origin.x: 220; origin.y: root.cassette ? 112 : 26; yScale: 1 - .35*root.lidOpen }@@ -2046,20 +2056,21 @@ ApplicationWindow {width: parent.width; height: 48; spacing: 4Repeater {id: recordChoices- model: ["CD", "Vinyl", "Cassette"]+ model: ["CD", "Vinyl", "Cassette", "TP-7"]delegate: AbstractButton {id: recordChoicerequired property string modelDatarequired property int index- objectName: modelData.toLowerCase() + "StyleButton"- width: (preferenceItems.width - 8) / 3; height: SpunStyle.target- text: modelData; checkable: true; autoExclusive: true; checked: player.medium === modelData.toLowerCase(); hoverEnabled: true+ readonly property string mediumId: index===3 ? "tp7" : modelData.toLowerCase()+ objectName: mediumId + "StyleButton"+ width: (preferenceItems.width - 12) / 4; height: SpunStyle.target+ text: modelData; checkable: true; autoExclusive: true; checked: player.medium === mediumId; hoverEnabled: trueAccessible.name: modelData + " appearance"; Accessible.checked: checkedKeys.onLeftPressed: recordChoices.itemAt(Math.max(0,index-1)).forceActiveFocus(Qt.TabFocusReason)- Keys.onRightPressed: recordChoices.itemAt(Math.min(2,index+1)).forceActiveFocus(Qt.TabFocusReason)+ Keys.onRightPressed: recordChoices.itemAt(Math.min(3,index+1)).forceActiveFocus(Qt.TabFocusReason)Keys.onReturnPressed: clicked()Keys.onEnterPressed: clicked()- onClicked: player.medium = modelData.toLowerCase()+ onClicked: player.medium = mediumIdonActiveFocusChanged: if(activeFocus) preferenceScroll.reveal(this)background: Rectangle {radius: 20 * theme.radius; color: "transparent"@@ -2089,7 +2100,7 @@ ApplicationWindow {onToggled: player.threeD = checkedonActiveFocusChanged: if(activeFocus)preferenceScroll.reveal(this)}- PreferenceSwitch { objectName: "playerBodyToggle"; app: root; width: parent.width; visible: !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) }+ 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.widthRepeater {@@ -2137,7 +2148,7 @@ ApplicationWindow {required property string modelDatarequired property int indexobjectName: "vinylSpeed" + index- width: (preferenceItems.width - 8) / 3; height: 40+ width: (preferenceItems.width - 12) / 4; height: 40text: modelData; checkable: true; autoExclusive: true; tonal: checked; checked: player.vinylSpeed === [0,33,45][index]onClicked: player.vinylSpeed = [0,33,45][index]onActiveFocusChanged: if(activeFocus)preferenceScroll.reveal(this)diff --git a/qml/Player3D.qml b/qml/Player3D.qmlindex 307a5f5..36b9666 100644--- a/qml/Player3D.qml+++ b/qml/Player3D.qml@@ -8,13 +8,21 @@ View3D {required property Item surfaceItemobjectName: "player3DView"clip: true+ property real vinylYaw: 0+ property real vinylPitch: 0+ readonly property bool inspectable: app.recorder || app.vinyl+ 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() }+ property bool orbiting: falseproperty real pitchOffset: 0property real yawOffset: 0readonly property real progress: app.cassette ? app.cassetteVisualProgress : app.recordVisualProgressBehavior on pitchOffset { enabled: app.animate && !app.threeDGesture; NumberAnimation { duration: 140 } }Behavior on yawOffset { enabled: app.animate && !app.threeDGesture; NumberAnimation { duration: 140 } }function tilt(point) {- if(!app.animate || app.threeDGesture || app.menuOpen)return+ if(view.inspectable || !app.animate || app.threeDGesture || app.menuOpen)returnpitchOffset=(point.y/height-.5)*2yawOffset=(point.x/width-.5)*3}@@ -23,10 +31,10 @@ View3D {// reading wallpaper files or sampling the desktop on every frame.// A palette accent is a UI color, often pastel or dark. Preserve its hue// while giving the illumination enough brightness and chroma to be visible.- readonly property color lightingColor: Qt.hsva(Math.max(0,app.accent.hsvHue), Math.min(.55,app.accent.hsvSaturation*1.5), 1, 1)- property color keyTint: Qt.tint("#ffffff", Qt.alpha(lightingColor, .30))- property color fillTint: Qt.tint("#ffffff", Qt.alpha(lightingColor, .80))- property color ambientTint: Qt.tint("#45474a", Qt.alpha(lightingColor, .18))+ readonly property color lightingColor: Qt.hsva(Math.max(0,app.accent.hsvHue), Math.min(.65,app.accent.hsvSaturation*1.8), 1, 1)+ property color keyTint: Qt.tint("#ffffff", Qt.alpha(lightingColor, .28))+ property color fillTint: Qt.tint("#ffffff", Qt.alpha(lightingColor, .85))+ property color ambientTint: Qt.tint("#202329", Qt.alpha(lightingColor, .16))Behavior on keyTint { enabled: app.animate; ColorAnimation { duration: 450 } }Behavior on fillTint { enabled: app.animate; ColorAnimation { duration: 450 } }Behavior on ambientTint { enabled: app.animate; ColorAnimation { duration: 450 } }@@ -40,8 +48,26 @@ View3D {probeExposure: .55aoEnabled: true; aoStrength: 18; aoDistance: 12; aoSoftness: 50; aoSampleRate: 2}- PerspectiveCamera { id: sceneCamera; z: 710+(app.vinyl?0:app.lidOpen*65); clipNear: 10; clipFar: 1500; fieldOfView: 38 }- DirectionalLight { objectName: "threeDKeyLight"; color: view.keyTint; eulerRotation: Qt.vector3d(-30,-35,0); brightness: .85; ambientColor: view.ambientTint; castsShadow: true; shadowFactor: 35; shadowMapQuality: Light.ShadowMapQualityMedium; shadowMapFar: 1200 }+ readonly property vector3d vinylCamera: {+ if(!app.vinyl)return Qt.vector3d(0,0,930)+ // Fit the closed and raised cover throughout inspection. The camera is+ // stable during the hinge animation, and only recalculates on rotation.+ const rotation=assembly.eulerRotation, origin=assembly.position+ let points=[]+ for(const x of [-270,270])for(const y of [-204,204])for(const z of [-63,65])points.push(assembly.mapPositionToScene(Qt.vector3d(x,y,z)))+ for(const degrees of [0,24,48,72]) {+ const a=-degrees*Math.PI/180+ for(const x of [-263,263])for(const y of [0,-373])for(const z of [0,72])points.push(assembly.mapPositionToScene(Qt.vector3d(x,187+y*Math.cos(a)-z*Math.sin(a),7+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/(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))@@ -57,6 +83,9 @@ View3D {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 }Texture {id: cover; generateMipmaps: true; mipFilter: Texture.Linearproperty CoverTexture imageData: CoverTexture { objectName: "currentCoverTexture"; artwork: presentation.artwork }@@ -75,17 +104,23 @@ View3D {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: .98; roughnessMap: moldedGrain }+ 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: solidNodeproperty vector3d size: Qt.vector3d(20,20,10)property real rounding: 2property color tint: "#30363b"geometry: DeckGeometry { dimensions: solidNode.size; radius: solidNode.rounding }- property Material finish: PrincipledMaterial { baseColor: solidNode.tint; metalness: .12; roughness: .55; roughnessMap: moldedGrain }+ property Material finish: PrincipledMaterial { baseColor: solidNode.tint; metalness: 0; roughness: .55; roughnessMap: moldedGrain }materials: [finish]}component Ring: Model {@@ -98,20 +133,42 @@ View3D {property Material finish: rubbermaterials: [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- eulerRotation: Qt.vector3d(-24+view.pitchOffset,-7+view.yawOffset,0)+ 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 } }+ 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: lidPivotSolid {objectName: "threeDEnclosure"y: app.cassette?-4.5:0; z: -15size: 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: .1size: 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@@ -134,6 +191,7 @@ View3D {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: mediumobjectName: "threeDMedium"@@ -143,6 +201,8 @@ View3D {visible: !app.cassetteeulerRotation.z: -app.spinAngleRing { 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@@ -155,14 +215,19 @@ View3D {}}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.cassetteobjectName: "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 {@@ -176,19 +241,33 @@ View3D {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 }- Ring { castsShadows: false; radius: 60; hole: 1; depth: .8; z: 8; finish: PrincipledMaterial { baseColor: view.glassTint; alphaMode: PrincipledMaterial.Blend; opacity: .035; roughness: .2; cullMode: Material.NoCulling } }Node {objectName: "threeDHub"+reel.indexeulerRotation.z: -(reel.index?app.cassetteRightAngle:app.cassetteLeftAngle)- Ring { radius: 32; hole: 13; depth: 6; z: 2; finish: PrincipledMaterial { baseColor: "#c9c4b5"; roughness: .5 } }- Repeater3D {- model: 6- Solid { required property int index; x: Math.cos(index*Math.PI/3)*11.5; y: Math.sin(index*Math.PI/3)*11.5; z: 2; size: Qt.vector3d(8,5,6); rounding: 1; eulerRotation.z: index*60; tint: "#c9c4b5" }- }+ 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 }}}- Solid { objectName: "threeDTapeRibbon"; size: Qt.vector3d(280,2.5,3); y: -52; z: 14; rounding: .3; tint: "#352017" }Repeater3D {model: 2Node {@@ -198,12 +277,17 @@ View3D {Ring { radius: 3; hole: .5; depth: 8; finish: metal }}}- Solid { size: Qt.vector3d(33,16,7); y: -83; z: 15; rounding: 3; 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: 8Solid { 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,93,11); y: 9; z: 15; rounding: 2; tint: app.cassetteShell }+ 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: 4Node {@@ -236,18 +320,48 @@ View3D {rounding: app.cassette?12:194finish: 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: 2Model { 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.cassette; source: "#Cylinder"; z: 9; eulerRotation.x: 90; scale: app.vinyl?Qt.vector3d(.07,.16,.07):Qt.vector3d(.39,.055,.39); 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.tonearmobjectName: "threeDTonearm"x: 135.88; y: 103.2; z: 11Model { 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@@ -255,10 +369,15 @@ View3D {eulerRotation.x: app.tonearm?-6*(1-app.tonearm.lowered):0z: 12Model { 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: steel }+ 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: 2Model { 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 }@@ -281,21 +400,54 @@ View3D {materials: PrincipledMaterial { baseColor: app.accent; lighting: PrincipledMaterial.NoLighting; cullMode: Material.NoCulling }}}+ } }// 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) {- const p=mapFrom3DScene(assembly.mapPositionToScene(Qt.vector3d(x-265,294-y,.5)))+ function projectSurface(x,y) { return projectSurfaceDepth(x,y,app.recorder?16:.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)))return Qt.point(p.x,p.y)}- function unprojectSurface(x,y) {- const a=assembly.mapPositionFromScene(mapTo3DScene(Qt.vector3d(x,y,0)))- const b=assembly.mapPositionFromScene(mapTo3DScene(Qt.vector3d(x,y,1000)))- const t=(.5-a.z)/(b.z-a.z)+ function unprojectSurface(x,y) { return unprojectPlane(x,y,app.recorder?16:.5) }+ function unprojectPlane(x,y,depth) {+ const space=app.vinyl && vinylScene.item ? vinylScene.item.recordSpace : 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)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 recorderHit(x,y) {+ const hit=pick(x,y)+ if(!hit.objectHit)return {control:null,body:false,depth:16}+ 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}+ }+ function resetRecorderOrientation() { recorderYaw=0;recorderPitch=0 }+ function resetVinylOrientation() { vinylYaw=0;vinylPitch=0 }+ function projectVinylNeedle() { const p=mapFrom3DScene(vinylScene.item.needlePoint());return Qt.point(p.x,p.y) }+ function projectVinylControl(index) { const p=mapFrom3DScene(vinylScene.item.controlPoint(index));return Qt.point(p.x,p.y) }+ function vinylHit(x,y) {+ if(app.menuOpen || app.swapRunning)return {control:null,body:false,depth:.5,hardware:-1}+ const hit=pick(x,y)+ if(!hit.objectHit)return {control:null,body:false,depth:.5,hardware:-1}+ const index=hit.objectHit.vinylControl+ if(index>=0 && index<=3)return {control:null,body:true,depth:.5,hardware:index}+ // A back or underside hit must not operate controls through the housing.+ const normal=assembly.mapDirectionToScene(Qt.vector3d(0,0,1))+ if(index===30 && normal.z>.12 && app.tonearm && app.tonearm.canSeek)+ return {control:app.tonearm.pointerInput,body:true,depth:vinylScene.item.recordSpace.mapPositionFromScene(hit.scenePosition).z,hardware:-1}+ const point=unprojectSurface(x,y)+ const control=normal.z>.12 ? app.controlAt3DPoint(point) : null+ 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(lidPivot.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)}+ 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)}MouseArea {@@ -305,14 +457,26 @@ View3D {property bool hintDismissed: falseproperty point pressPointproperty bool windowDragAllowed: false+ property bool hoveredBody: false+ property real startYaw: 0+ property real startPitch: 0+ property real grabDepth: 16property string hint: ""function updateHint(x,y) {const point=view.unprojectSurface(x,y)- const target=view.app.controlAt3DPoint(point)+ const hit=view.app.vinyl ? view.vinylHit(x,y) : view.app.recorder ? view.recorderHit(x,y) : null+ const target=hit ? hit.control : view.app.controlAt3DPoint(point)+ hoveredBody=!!hit && hit.body+ 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]+ return+ }if(target!==hoveredControl)hintDismissed=falsehoveredControl=target- if(!target){hint="";return}- if(view.app.vinyl && view.app.tonearm && target===view.app.tonearm.pointerInput) {+ if(!target){hint=hoveredBody ? "Drag to rotate · double-click to reset" : "";return}+ if(view.app.recorder) { hint=target.hint || ""+ } else if(view.app.vinyl && view.app.tonearm && target===view.app.tonearm.pointerInput) {hint="Drag to seek · Shift for precision"} else {const p=view.app.pointerEvent(target,point,0)@@ -324,27 +488,49 @@ View3D {}}anchors.fill: parent; hoverEnabled: true; preventStealing: true; acceptedButtons: Qt.AllButtons- onPressed: mouse => { hintDismissed=true;pressPoint=Qt.point(mouse.x,mouse.y);if(mouse.button===Qt.LeftButton)view.app.begin3DPointer(view.unprojectSurface(mouse.x,mouse.y),mouse.modifiers);windowDragAllowed=mouse.button===Qt.LeftButton && !view.app.threeDPointer }+ 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+ grabDepth=hit ? hit.depth : .5+ if(mouse.button===Qt.LeftButton && hit && hit.hardware>=0) { 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+ windowDragAllowed=mouse.button===Qt.LeftButton && !view.app.threeDPointer && !view.orbiting+ }onPositionChanged: mouse => {if(pressed) {- view.app.move3DPointer(view.unprojectSurface(mouse.x,mouse.y),mouse.modifiers)+ if(view.app.vinyl && vinylScene.item && vinylScene.item.pressedControl>=0) {+ vinylScene.item.armed=view.vinylHit(mouse.x,mouse.y).hardware===vinylScene.item.pressedControl+ return+ }+ view.app.move3DPointer(view.unprojectPlane(mouse.x,mouse.y,grabDepth),mouse.modifiers)+ if(view.orbiting) {+ 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 {+ view.recorderYaw=(startYaw+(mouse.x-pressPoint.x)*.65)%360+ view.recorderPitch=Math.max(-65,Math.min(75,startPitch+(mouse.y-pressPoint.y)*.5))+ }+ }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: view.app.end3DPointer()- onCanceled: view.app.cancel3DPointer()+ onReleased: { 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 && !view.app.controlAt3DPoint(view.unprojectSurface(mouse.x,mouse.y)))view.app.flipDisc() }- onExited: { hoveredControl=null;hint="";hintDismissed=false;if(!pressed){view.pitchOffset=0;view.yawOffset=0} }+ 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.app.threeDGesture?Qt.ClosedHandCursor:hoveredControl?Qt.PointingHandCursor:Qt.ArrowCursor+ cursorShape: view.orbiting||view.app.threeDGesture?Qt.ClosedHandCursor:hoveredControl?Qt.PointingHandCursor:hoveredBody?Qt.OpenHandCursor:Qt.ArrowCursor}SpunToolTip {objectName: "threeDToolTip"parent: pointerx: Math.max(8,Math.min(view.width-width-8,pointer.mouseX-width/2))y: Math.max(8,pointer.mouseY-height-18)- visible: pointer.containsMouse && !!pointer.hoveredControl && !pointer.hintDismissed && !pointer.pressed && !view.app.menuOpen && !view.app.swapRunning && view.app.visible+ visible: pointer.containsMouse && (!!pointer.hoveredControl || pointer.hoveredBody) && !pointer.hintDismissed && !pointer.pressed && !view.app.menuOpen && !view.app.swapRunning && view.app.visibletext: pointer.hinttimeout: 2500onClosed: pointer.hintDismissed=truediff --git a/qml/Recorder.qml b/qml/Recorder.qmlnew file mode 100644index 0000000..80dc767--- /dev/null+++ b/qml/Recorder.qml@@ -0,0 +1,185 @@+import QtQuick+import Spun 1.0++Item {+ id: recorder+ required property var app+ objectName: "recorderFace"+ readonly property var controls: [previous, play, next, quieter, louder, rewind, forward, knob, details, queue, settings]+ readonly property var keyControls: [previous, play, next]+ readonly property var wheelInput: wheelPointer+ readonly property real wheelAngle: wheel.scrubbing ? wheel.baseAngle + (wheel.previewValue-wheel.baseValue)*360 : app.activeSeekControl ? app.trackVisualProgress*360 : app.spinAngle+ function controlAt(point) {+ for(const button of controls) {+ const p=button.mapFromItem(recorder,point.x,point.y)+ if(button.enabled && p.x>=0 && p.y>=0 && p.x<button.width && p.y<button.height)return button.pointerInput+ }+ const p=wheel.mapFromItem(recorder,point.x,point.y)+ return wheel.enabled && wheel.onWheel(p.x,p.y) ? wheelPointer : null+ }+ function cancelInput() { wheel.cancelSeek(); for(const button of controls)button.pointerInput.cancelPointer() }+ onVisibleChanged: if(!visible)cancelInput()+ Connections {+ target: recorder.app+ function onMenuOpenChanged() { if(recorder.app.menuOpen)recorder.cancelInput() }+ function onDiscFlippedChanged() { recorder.cancelInput() }+ function onCassetteTrackIdentityChanged() { recorder.cancelInput() }+ }+ RecorderSurface { anchors.fill: parent }+ RecorderSurface { objectName: "recorderWheelSurface"; anchors.fill: parent; part: 1; artwork: presentation.artwork; transform: Rotation { origin.x: 205; origin.y: 160; angle: recorder.wheelAngle } }+ RecorderSurface { anchors.fill: parent; part: 2 }+ RecorderSurface {+ anchors.fill: parent; part: 3+ transform: Rotation { origin.x: 70; origin.y: 162; axis.x: 1; axis.y: 0; axis.z: 0; angle: 7*(rewind.pressDepth-forward.pressDepth) }+ }+ Rectangle { x: 65; y: 69; width: 10; height: 91; radius: 4; color: "#25323d"; opacity: .18*Math.max(0,forward.pressDepth) }+ Rectangle { x: 65; y: 164; width: 10; height: 91; radius: 4; color: "#25323d"; opacity: .18*Math.max(0,rewind.pressDepth) }+ RecorderDisplay { x: 267; y: 30; width: 52; height: 29; app: recorder.app }+ ProgressRing {+ objectName: "recorderProgress"+ x: 83; y: 38; width: 244; height: 244+ visible: recorder.app.deckPlayer.count>0+ progress: recorder.app.trackVisualProgress; phase: recorder.app.wavePhase+ amplitude: recorder.app.deckPlayer.playing ? 1.1 : 0; accent: recorder.app.accent+ Behavior on amplitude { NumberAnimation { duration: SpunStyle.enter } }+ }+ component HardwareKey: Item {+ id: key+ property string caption+ property string glyphName+ property bool round: false+ property bool rocker: false+ property bool orange: false+ property bool isKnob: false+ property bool side: false+ property bool requiresTrack: true+ property alias pointerInput: input+ property bool held: false+ property bool armed: false+ property real initialY: 0+ property real initialVolume: 0+ property bool keyboardDown: false+ readonly property real pressDepth: Math.max(-.025,Math.min(1,keyTravel.value))+ SpunSpring {+ id: keyTravel+ targetValue: (key.held && key.armed) || key.keyboardDown ? 1 : 0+ epsilon: .005+ animation.spring: 4.5+ animation.damping: .3+ animation.mass: .7+ }+ Timer { id: keyboardRelease; interval: 90; onTriggered: key.keyboardDown=false }+ function keyboardActivate() { if(!enabled || isKnob)return;keyboardDown=true;keyboardRelease.restart();triggered() }+ signal triggered()+ enabled: (!requiresTrack || recorder.app.deckPlayer.count>0) && !recorder.app.discFlipped && !recorder.app.menuOpen+ activeFocusOnTab: true+ Accessible.role: isKnob ? Accessible.Slider : Accessible.Button+ Accessible.name: caption+ Accessible.onPressAction: keyboardActivate()+ Keys.onSpacePressed: keyboardActivate()+ Keys.onReturnPressed: keyboardActivate()+ Item {+ objectName: key.objectName+"Face"+ anchors.fill: parent+ transform: Translate { x: key.side ? -key.pressDepth : 0; y: key.side || key.rocker || key.isKnob ? 0 : 1.8*key.pressDepth }+ scale: key.side || key.rocker || key.isKnob ? 1 : 1-.008*key.pressDepth+ Rectangle {+ anchors.fill: parent; anchors.margins: key.round ? 3 : .7+ anchors.leftMargin: key.side ? 8 : key.round ? 4 : .7; anchors.rightMargin: key.side ? 8 : key.round ? 4 : .7+ radius: key.round ? width/2 : 2+ visible: !key.rocker && !key.isKnob+ border.color: key.activeFocus ? recorder.app.accent : "#7d858b"; border.width: key.activeFocus ? 2 : .45+ gradient: Gradient { GradientStop { position: 0; color: key.held ? "#b8bec4" : "#e3e7ea"; Behavior on color { ColorAnimation { duration: SpunStyle.feedback } } } GradientStop { position: .08; color: "#c9ced2" } GradientStop { position: .94; color: "#b9c0c6" } GradientStop { position: 1; color: "#98a2aa" } }+ }+ Glyph { anchors.horizontalCenter: parent.horizontalCenter; y: key.rocker ? (parent.height-height)/2 : key.round ? (parent.height-height)/2 : 12; width: key.rocker ? 11 : 15; height: width; name: key.glyphName; ink: key.orange ? "#d76d24" : "#414951"; visible: !key.isKnob && !key.side }+ }+ MouseArea {+ id: input+ objectName: key.objectName + "Pointer"+ property string hint: key.caption+ anchors.fill: parent; cursorShape: key.isKnob ? Qt.SizeVerCursor : Qt.PointingHandCursor+ preventStealing: true+ function beginPointer(mouse) { if(!key.enabled){mouse.accepted=false;return};key.forceActiveFocus();key.initialY=mouse.y;key.initialVolume=recorder.app.deckPlayer.volume;key.held=true;key.armed=true }+ function movePointer(mouse) {+ if(!key.held)return+ if(key.isKnob)recorder.app.deckPlayer.volume=Math.max(0,Math.min(1,key.initialVolume+(key.initialY-mouse.y)/150))+ else key.armed=mouse.x>=-4&&mouse.y>=-4&&mouse.x<=width+4&&mouse.y<=height+4+ }+ function endPointer() { const activate=key.held&&key.armed&&key.enabled&&!key.isKnob;cancelPointer();if(activate)key.triggered() }+ function cancelPointer() { key.held=false;key.armed=false;key.keyboardDown=false }+ onPressed: mouse => beginPointer(mouse)+ onPositionChanged: mouse => movePointer(mouse)+ onReleased: endPointer()+ onCanceled: cancelPointer()+ onWheel: wheel => { recorder.app.deckPlayer.volume=Math.max(0,Math.min(1,recorder.app.deckPlayer.volume+wheel.angleDelta.y/2400));wheel.accepted=true }+ }+ property bool hintDismissed: false+ HoverHandler { id: keyHover; onHoveredChanged: if(!hovered)key.hintDismissed=false }+ SpunToolTip {+ visible: keyHover.hovered && !key.held && !key.hintDismissed && !recorder.app.threeDActive && !recorder.app.menuOpen+ text: key.caption; timeout: 2500+ onClosed: key.hintDismissed=true+ }+ onEnabledChanged: if(!enabled)input.cancelPointer()+ Keys.onUpPressed: if(isKnob)recorder.app.deckPlayer.volume=Math.min(1,recorder.app.deckPlayer.volume+.05)+ Keys.onDownPressed: if(isKnob)recorder.app.deckPlayer.volume=Math.max(0,recorder.app.deckPlayer.volume-.05)+ }+ HardwareKey { id: previous; objectName: "recorderPrevious"; x: 86; y: 287; width: 61; height: 84; caption: "Previous track"; glyphName: "previous"; orange: true; enabled: !recorder.app.menuOpen && !recorder.app.discFlipped && (recorder.app.useCider ? recorder.app.ciderService.canPrevious : recorder.app.deckPlayer.count>0); onTriggered: recorder.app.deckPlayer.previous() }+ HardwareKey { id: play; objectName: "recorderPlay"; x: 148; y: 287; width: 61; height: 84; caption: recorder.app.deckPlayer.playing ? "Pause" : "Play"; glyphName: recorder.app.deckPlayer.playing ? "pause" : "play"; onTriggered: recorder.app.deckPlayer.toggle() }+ HardwareKey { id: next; objectName: "recorderNext"; x: 210; y: 287; width: 61; height: 84; caption: "Next track"; glyphName: "next"; enabled: !recorder.app.menuOpen && !recorder.app.discFlipped && (recorder.app.useCider ? recorder.app.ciderService.canNext : recorder.app.deckPlayer.count>0); onTriggered: recorder.app.deckPlayer.next() }+ HardwareKey { id: quieter; requiresTrack: false; objectName: "recorderQuieter"; x: 273; y: 253; width: 28; height: 26; round: true; caption: "Volume down"; glyphName: "minus"; onTriggered: recorder.app.deckPlayer.volume=Math.max(0,recorder.app.deckPlayer.volume-.05) }+ HardwareKey { id: louder; requiresTrack: false; objectName: "recorderLouder"; x: 295; y: 232; width: 28; height: 26; round: true; caption: "Volume up"; glyphName: "plus"; onTriggered: recorder.app.deckPlayer.volume=Math.min(1,recorder.app.deckPlayer.volume+.05) }+ HardwareKey { id: rewind; objectName: "recorderRewind"; x: 55; y: 164; width: 30; height: 91; rocker: true; caption: "Back 10 seconds"; glyphName: "previous"; enabled: wheel.enabled; onTriggered: recorder.app.deckPlayer.seek(Math.max(0,recorder.app.deckPlayer.position-10000)) }+ HardwareKey { id: forward; objectName: "recorderForward"; x: 55; y: 69; width: 30; height: 91; rocker: true; caption: "Forward 10 seconds"; glyphName: "next"; enabled: wheel.enabled; onTriggered: recorder.app.deckPlayer.seek(Math.min(recorder.app.deckPlayer.duration,recorder.app.deckPlayer.position+10000)) }+ HardwareKey { id: knob; requiresTrack: false; objectName: "recorderVolumeKnob"; x: 276; y: 373; width: 37; height: 33; isKnob: true; caption: "Volume · drag up or down" }+ HardwareKey { id: details; objectName: "recorderDetails"; x: 326; y: 82; width: 22; height: 38; side: true; caption: "Album details · F"; onTriggered: recorder.app.flipDisc() }+ HardwareKey { id: queue; requiresTrack: false; objectName: "recorderQueue"; x: 326; y: 133; width: 22; height: 24; side: true; round: true; caption: "Queue"; onTriggered: recorder.app.queueOpen=!recorder.app.queueOpen }+ HardwareKey { id: settings; requiresTrack: false; objectName: "recorderSettings"; x: 326; y: 173; width: 22; height: 24; side: true; round: true; caption: "Player menu"; onTriggered: recorder.app.openSettings() }+ Item {+ id: wheel; objectName: "recorderWheel"+ x: 83; y: 38; width: 244; height: 244+ enabled: recorder.app.deckPlayer.count>0 && recorder.app.deckPlayer.duration>0 && !recorder.app.discFlipped && !recorder.app.menuOpen && (!recorder.app.useCider || recorder.app.ciderService.canSeek)+ property bool scrubbing: false+ property real previewValue: 0+ property real lastFraction: 0+ property real baseAngle: 0+ property real baseValue: 0+ property string track: ""+ activeFocusOnTab: true+ Accessible.role: Accessible.Slider; Accessible.name: "Recorder wheel, playback position"+ function onWheel(x,y) { const r=Math.hypot(x-122,y-122);return r>32&&r<122 }+ function fraction(x,y) { let angle=Math.atan2(y-122,x-122)+Math.PI/2;if(angle<0)angle+=Math.PI*2;return angle/(Math.PI*2) }+ function cancelSeek() { scrubbing=false;if(recorder.app.activeSeekControl===wheel)recorder.app.activeSeekControl=null }+ onEnabledChanged: if(!enabled)cancelSeek()+ Component.onDestruction: if(recorder.app.activeSeekControl===wheel)recorder.app.activeSeekControl=null+ Keys.onLeftPressed: recorder.app.deckPlayer.seek(Math.max(0,recorder.app.deckPlayer.position-5000))+ Keys.onRightPressed: recorder.app.deckPlayer.seek(Math.min(recorder.app.deckPlayer.duration,recorder.app.deckPlayer.position+5000))+ Keys.onEscapePressed: cancelSeek()+ MouseArea {+ id: wheelPointer; objectName: "recorderWheelPointer"+ property string hint: "Drag wheel to seek · Shift for precision"+ anchors.fill: parent; preventStealing: true; cursorShape: wheel.scrubbing ? Qt.ClosedHandCursor : Qt.OpenHandCursor+ containmentMask: QtObject { function contains(point: point): bool { return wheel.onWheel(point.x,point.y) } }+ function beginPointer(mouse) {+ if(!wheel.enabled||!wheel.onWheel(mouse.x,mouse.y)){mouse.accepted=false;return}+ wheel.forceActiveFocus();wheel.track=recorder.app.cassetteTrackIdentity+ wheel.baseAngle=recorder.app.spinAngle;wheel.lastFraction=wheel.fraction(mouse.x,mouse.y)+ wheel.previewValue=(mouse.modifiers&Qt.ShiftModifier)?recorder.app.progress:wheel.lastFraction+ wheel.baseValue=wheel.previewValue;wheel.scrubbing=true;recorder.app.activeSeekControl=wheel+ }+ function movePointer(mouse) {+ if(!wheel.scrubbing)return+ const next=wheel.fraction(mouse.x,mouse.y);let delta=next-wheel.lastFraction+ if(delta>.5)delta-=1;else if(delta<-.5)delta+=1+ wheel.lastFraction=next;wheel.previewValue=Math.max(0,Math.min(1,wheel.previewValue+delta*((mouse.modifiers&Qt.ShiftModifier)?.1:1)))+ }+ function endPointer() { const valid=wheel.scrubbing&&wheel.enabled&&wheel.track===recorder.app.cassetteTrackIdentity;const fraction=wheel.previewValue;wheel.cancelSeek();if(valid)recorder.app.deckPlayer.seek(fraction*recorder.app.deckPlayer.duration) }+ function cancelPointer() { wheel.cancelSeek() }+ onPressed: mouse => beginPointer(mouse)+ onPositionChanged: mouse => movePointer(mouse)+ onReleased: endPointer()+ onCanceled: cancelPointer()+ onDoubleClicked: recorder.app.flipDisc()+ }+ }+}diff --git a/qml/Recorder3D.qml b/qml/Recorder3D.qmlnew file mode 100644index 0000000..20b15a5--- /dev/null+++ b/qml/Recorder3D.qml@@ -0,0 +1,197 @@+import QtQuick+import QtQuick3D+import Spun 1.0++Node {+ id: recorder+ required property var app+ required property Texture artworkTexture+ 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 }+ 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 }+ function surface(x,y,z) { return Qt.vector3d(x-205,205-y,z) }+ function controlScenePoint(index) {+ if(!controls || index<0 || index>=controls.controls.length)return Qt.vector3d(0,0,0)+ const key=controls.controls[index]+ return mapPositionToScene(surface(key.x+key.width/2-(index>=8?5:0),key.y+key.height/2,index>=7?-9:16))+ }+ component Plate: Model {+ id: plate+ pickable: true+ property int recorderControl: -1+ property vector3d size: Qt.vector3d(10,10,2)+ property real rounding: 2+ property Material finish: aluminum+ geometry: DeckGeometry { dimensions: plate.size; radius: plate.rounding }+ materials: [finish]+ }+ component Ring: Model {+ id: ring+ pickable: true+ property int recorderControl: -1+ property real radius: 10+ property real hole: .5+ property real depth: 2+ property Material finish: polished+ geometry: RecordGeometry { radius: ring.radius; hole: ring.hole; depth: ring.depth }+ materials: [finish]+ }+ // An open transport bay exposes the key guides when viewed from below.+ Plate { objectName: "threeDRecorderBody"; position: recorder.surface(207,153.5,-5); size: Qt.vector3d(244,267,34); rounding: 12 }+ Plate { position: recorder.surface(207,196,-26); size: Qt.vector3d(244,352,8); rounding: 12 }+ Plate { position: recorder.surface(301,329,-5); size: Qt.vector3d(56,86,34); rounding: 10 }+ Plate { position: recorder.surface(88,329,-5); size: Qt.vector3d(6,86,34); rounding: 3 }+ Plate { objectName: "threeDRecorderOrangeBack"; position: recorder.surface(207,196,-31.5); size: Qt.vector3d(240,348,3); rounding: 10; finish: orange }+ Plate { position: recorder.surface(207,196,12.15); size: Qt.vector3d(242,350,.6); rounding: 11; finish: black }+ Plate { position: recorder.surface(207,196,12.5); size: Qt.vector3d(240.8,348.8,.8); rounding: 10.4; finish: faceFinish }+ Plate { position: recorder.surface(116,12,-9); size: Qt.vector3d(8,24,15); rounding: 1.5; finish: polished }+ Ring { position: recorder.surface(205,160,13.15); radius: 114.5; depth: .6; finish: black }+ Node {+ objectName: "threeDRecorderWheel"+ position: recorder.surface(205,160,14.4)+ eulerRotation.z: -(recorder.controls ? recorder.controls.wheelAngle : recorder.app.spinAngle)+ Ring { objectName: "threeDRecorderWheelMesh"; recorderControl: 20; radius: 113; hole: 31; depth: 2; finish: wheelFinish }+ Ring { recorderControl: 20; radius: 113; hole: 112.5; depth: .22; z: .95; finish: polished }+ Plate { recorderControl: 20; y: 74; z: 1.06; size: Qt.vector3d(.32,73,.04); rounding: 0; finish: engraving }+ Plate { recorderControl: 20; y: -74; z: 1.06; size: Qt.vector3d(.32,73,.04); rounding: 0; finish: engraving }+ Ring { radius: 31; depth: 2.2; finish: black }+ Ring { radius: 30.9; hole: 30.35; depth: .22; z: 1.1 }+ Model {+ objectName: "threeDRecorderArtwork"+ z: 1.15+ geometry: RecordGeometry { radius: 26; hole: .5; depth: .06 }+ materials: PrincipledMaterial { baseColorMap: recorder.artworkTexture; roughness: .46; clearcoatAmount: .22; clearcoatRoughnessAmount: .2 }+ }+ Repeater3D {+ model: 3+ Node {+ required property int index+ x: Math.sin(index*Math.PI*2/3)*28.5; y: Math.cos(index*Math.PI*2/3)*28.5; z: 1.4+ Ring { radius: 1.15; hole: .25; depth: .35 }+ Plate { size: Qt.vector3d(1,.2,.06); z: .2; rounding: .08; finish: black }+ }+ }+ }+ Model {+ z: 12.95; source: "#Rectangle"; scale: Qt.vector3d(4.1,4.1,1)+ materials: PrincipledMaterial {+ baseColorMap: Texture { sourceItem: RecorderSurface { width: 410; height: 410; part: 2 } }+ alphaMode: PrincipledMaterial.Blend; lighting: PrincipledMaterial.NoLighting; depthDrawMode: Material.NeverDepthDraw+ }+ }+ Plate { position: recorder.surface(293,44.5,13); size: Qt.vector3d(55,32,.6); rounding: 4.7; finish: black }+ Plate { position: recorder.surface(293,44.5,13.26); size: Qt.vector3d(53,30,.5); rounding: 4; finish: polished }+ Model {+ objectName: "threeDRecorderDisplay"+ position: recorder.surface(293,44.5,13.55); source: "#Rectangle"; scale: Qt.vector3d(.52,.29,1)+ materials: PrincipledMaterial { baseColorMap: Texture { sourceItem: RecorderDisplay { app: recorder.app } } lighting: PrincipledMaterial.NoLighting }+ }+ Ring { position: recorder.surface(115,263,13.05); radius: 9; depth: .22; finish: PrincipledMaterial { baseColor: "#8c969d"; metalness: .65; roughness: .46 } }+ Plate { position: recorder.surface(178.5,329,13); size: Qt.vector3d(187,86,.8); rounding: 1.8; finish: black }+ Repeater3D {+ model: 3+ Node {+ required property int index+ readonly property var control: recorder.controls ? recorder.controls.keyControls[index] : null+ position: control ? recorder.surface(control.x+control.width/2,control.y+control.height/2,15-1.35*control.pressDepth) : Qt.vector3d(0,0,0)+ eulerRotation.x: control ? 1.2*control.pressDepth : 0+ Model {+ objectName: "threeDRecorderKeyGuide"+parent.index+ source: "#Cylinder"; z: -20; eulerRotation.x: 90; scale: Qt.vector3d(.18,.36,.18)+ materials: polished+ }+ Model { source: "#Cylinder"; z: -31; eulerRotation.x: 90; scale: Qt.vector3d(.23,.04,.23); materials: black }+ Plate { objectName: "threeDRecorderKey"+parent.index; recorderControl: parent.index; size: Qt.vector3d(parent.control?parent.control.width-1.4:60,parent.control?parent.control.height-1.4:83,3.8); rounding: 2 }+ Model {+ source: "#Rectangle"; y: 22; z: 1.94; scale: Qt.vector3d(.13,.13,1)+ materials: PrincipledMaterial { baseColorMap: Texture { sourceItem: Glyph { width: 48; height: 48; name: index===0?"previous":index===2?"next":recorder.app.deckPlayer.playing?"pause":"play"; ink: index===0?"#d76d24":"#252d34" } } alphaMode: PrincipledMaterial.Blend; roughness: .65 }+ }+ }+ }+ Plate { position: recorder.surface(298,255.5,13.01); eulerRotation.z: -46.3; size: Qt.vector3d(25,55,.18); rounding: 12.5; finish: polished }+ Plate { position: recorder.surface(298,255.5,13.12); eulerRotation.z: -46.3; size: Qt.vector3d(23.7,53.7,.18); rounding: 11.8 }+ Repeater3D {+ model: 2+ Node {+ required property int index+ readonly property var control: recorder.controls ? recorder.controls.controls[3+index] : null+ position: control ? recorder.surface(control.x+control.width/2,control.y+control.height/2,14.5-1.0*control.pressDepth) : Qt.vector3d(0,0,0)+ Plate { recorderControl: parent.index+3; size: Qt.vector3d(20,20,2.6); rounding: 10 }+ Ring { recorderControl: parent.index+3; radius: 10; hole: 9.65; depth: .25; z: 1.2 }+ Plate { recorderControl: parent.index+3; z: 1.35; size: Qt.vector3d(6,.4,.06); rounding: .1; finish: black }+ Plate { recorderControl: parent.index+3; visible: parent.index===1; z: 1.35; size: Qt.vector3d(.4,6,.06); rounding: .1; finish: black }+ }+ }+ Node {+ position: recorder.surface(70,162,-1)+ eulerRotation.x: recorder.controls ? 3*(recorder.controls.controls[5].pressDepth-recorder.controls.controls[6].pressDepth) : 0+ Plate { recorderControl: 6; y: 47.5; size: Qt.vector3d(10,91,28); rounding: 4; finish: polished }+ Plate { recorderControl: 5; y: -47.5; size: Qt.vector3d(10,91,28); rounding: 4; finish: polished }+ Plate { x: 3; size: Qt.vector3d(18,17,28); rounding: 8; finish: polished }+ Ring { x: 2; z: 14.2; radius: 3.3; hole: .7; depth: .5 }+ Plate { x: 10; z: -10; size: Qt.vector3d(15,6,8); rounding: 1 }+ }+ Repeater3D {+ model: 2+ Plate { required property int index; position: recorder.surface(294.8+index*14,324.5,13); size: Qt.vector3d(1.6,69,.12); rounding: .75; finish: engraving }+ }+ Plate { position: recorder.surface(301,314,13.02); size: Qt.vector3d(36,.25,.03); rounding: .1; finish: black }+ Model {+ objectName: "threeDRecorderKnob"+ 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 }+ }+ 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 }+ Model { pickable: true; property int recorderControl: 7; source: "#Cylinder"; position: recorder.surface(294.5,403,-9); scale: Qt.vector3d(.35,.009,.35); materials: polished }+ Model { pickable: true; property int recorderControl: 7; source: "#Cylinder"; position: recorder.surface(294.5,404.4,-9); scale: Qt.vector3d(.31,.006,.31); materials: polished }+ Model { pickable: true; property int recorderControl: 7; source: "#Cylinder"; position: recorder.surface(294.5,404.8,-9); scale: Qt.vector3d(.1,.006,.1); materials: black }+ // Side keys remain useful while inspecting the recorder from an angle.+ Repeater3D {+ model: 3+ Plate {+ required property int index+ readonly property var control: recorder.controls ? recorder.controls.controls[index+8] : null+ objectName: "threeDRecorderSide"+(index+8); recorderControl: index+8+ position: control ? recorder.surface(control.x+control.width/2-5-1.5*control.pressDepth,control.y+control.height/2,-9) : Qt.vector3d(0,0,0)+ size: Qt.vector3d(8,index===0?32:18,index===0?22:18); rounding: index===0?3:8.9+ }+ }+ // Three recessed jacks and a USB port in the upper edge.+ Repeater3D {+ model: 3+ Node {+ required property int index+ position: recorder.surface(178+index*29,19.5,-9)+ eulerRotation.x: 90+ Ring { radius: 4.2; hole: 3.1; depth: .8 }+ Ring { radius: 3.05; depth: .15; finish: black }+ }+ }+ Plate { position: recorder.surface(279,19.5,-9); size: Qt.vector3d(24,6,1); eulerRotation.x: 90; rounding: 2.8; finish: black }+ Repeater3D {+ model: 4+ Node {+ required property int index+ x: (index%2?1:-1)*106+2; y: index<2?174:-148; z: -33.3; eulerRotation.y: 180+ Ring { radius: 2.2; hole: .4; depth: .5 }+ Plate { z: .3; size: Qt.vector3d(2.1,.35,.08); rounding: .15; finish: black }+ }+ }+ Model {+ objectName: "threeDRecorderProgress"+ visible: recorder.app.deckPlayer.count>0+ position: recorder.surface(205,160,16.3); scale: Qt.vector3d(116/186,116/186,1)+ geometry: WaveGeometry { progress: recorder.app.trackVisualProgress; phase: recorder.app.wavePhase; amplitude: recorder.app.deckPlayer.playing?1.6:0 }+ materials: PrincipledMaterial { baseColor: recorder.app.accent; lighting: PrincipledMaterial.NoLighting; cullMode: Material.NoCulling }+ }+}diff --git a/qml/RecorderDisplay.qml b/qml/RecorderDisplay.qmlnew file mode 100644index 0000000..82f3264--- /dev/null+++ b/qml/RecorderDisplay.qml@@ -0,0 +1,26 @@+import QtQuick++Rectangle {+ id: display+ required property var app+ width: 52; height: 29; radius: 3+ color: "#0b1218"+ border.width: .6; border.color: "#48545b"+ readonly property bool hasTrack: app.deckPlayer.count > 0+ Text {+ x: 4; y: 3; width: parent.width-8; height: 12+ text: display.hasTrack ? app.time(app.trackVisualProgress * app.deckPlayer.duration) : "00:00"+ color: "#e0ebe7"; font.family: "monospace"; font.pixelSize: 9+ font.letterSpacing: .3; textFormat: Text.PlainText+ }+ Text {+ x: 4; y: 18; width: parent.width-12; height: 8+ text: display.hasTrack ? app.deckPlayer.title : "READY"+ textFormat: Text.PlainText; color: "#c5d4d1"; font.pixelSize: 6; elide: Text.ElideRight+ }+ Rectangle { x: parent.width-6; y: 20; width: 2; height: 2; radius: 1; color: app.deckPlayer.playing ? "#ea883e" : "#586e75" }+ Rectangle {+ x: 1; y: 1; width: parent.width-2; height: 9; radius: 2+ gradient: Gradient { GradientStop { position: 0; color: "#1ce0edf3" } GradientStop { position: 1; color: "transparent" } }+ }+}diff --git a/qml/SeekSlider.qml b/qml/SeekSlider.qmlindex 1572d1f..f1ba5da 100644--- a/qml/SeekSlider.qml+++ b/qml/SeekSlider.qml@@ -5,7 +5,7 @@ SpunSlider {id: controlrequired property var appproperty alias pointerInput: seekPointer- enabled: visible && !app.swapRunning && app.deckPlayer.duration > 0 && (!app.useCider || app.ciderService.canSeek)+ enabled: visible && !app.swapRunning && app.deckPlayer.duration > 0 && (!app.useCider || (app.ciderService.canSeek && !app.listeningService.busy))property bool scrubbing: falseproperty real previewValue: 0property real lastPointer: 0@@ -13,7 +13,7 @@ SpunSlider {property double lastMove: 0property string seekTrack: ""previewing: scrubbing- value: scrubbing ? previewValue : app.trackVisualProgress+ value: scrubbing ? previewValue : app.recordVisualProgressfunction cancelSeek() {scrubbing=false; windDirection=0if(app.activeSeekControl===control)app.activeSeekControl=null@@ -21,9 +21,9 @@ SpunSlider {onEnabledChanged: if(!enabled)cancelSeek()onVisibleChanged: if(!visible)cancelSeek()Component.onDestruction: if(app.activeSeekControl===control)app.activeSeekControl=null- valueText: app.time(value * app.deckPlayer.duration)- Accessible.name: "Playback position"- onMoved: if(!scrubbing)app.deckPlayer.seek(value * app.deckPlayer.duration)+ valueText: (app.recordMap ? "Album · " : "") + app.time(value * app.seekDuration)+ Accessible.name: app.recordMap ? "Album playback position" : "Playback position"+ onMoved: if(!scrubbing)app.seekTimeline(value)MouseArea {id: seekPointer; objectName: control.objectName + "Pointer"anchors.fill: parent; preventStealing: true; acceptedButtons: Qt.LeftButton@@ -32,8 +32,8 @@ SpunSlider {function beginPointer(mouse) {control.forceActiveFocus(Qt.MouseFocusReason)control.seekTrack=control.app.cassetteTrackIdentity- control.previewValue=(mouse.modifiers & Qt.ShiftModifier)?control.app.progress:fraction(mouse.x)- control.lastPointer=mouse.x;control.windDirection=Math.sign(control.previewValue-control.app.progress);control.lastMove=Date.now()+ control.previewValue=(mouse.modifiers & Qt.ShiftModifier)?control.app.recordProgress:fraction(mouse.x)+ control.lastPointer=mouse.x;control.windDirection=Math.sign(control.previewValue-control.app.recordProgress);control.lastMove=Date.now()control.scrubbing=true;control.app.activeSeekControl=controlif(control.app.cassette)tapeSound.transport()}@@ -49,7 +49,7 @@ SpunSlider {const valid=control.enabled && control.seekTrack===control.app.cassetteTrackIdentityconst position=control.previewValuecontrol.cancelSeek()- if(valid){control.app.deckPlayer.seek(position*control.app.deckPlayer.duration);if(control.app.cassette)tapeSound.transport()}+ if(valid){control.app.seekTimeline(position);if(control.app.cassette)tapeSound.transport()}}function cancelPointer() { control.cancelSeek() }onPressed: mouse => beginPointer(mouse)@@ -82,7 +82,7 @@ SpunSlider {Rectangle {anchors.verticalCenter: parent.verticalCenter; anchors.right: parent.rightwidth: 3; height: 3; radius: 1.5; color: control.app.accent- visible: control.app.progress < .95+ visible: control.value < .95}}}diff --git a/qml/Tonearm.qml b/qml/Tonearm.qmlindex 8c54617..a1f046c 100644--- a/qml/Tonearm.qml+++ b/qml/Tonearm.qml@@ -10,6 +10,11 @@ Item {readonly property bool engaged: visible && app.deckPlayer.count > 0 && ((app.deckPlayer.playing && !app.swapRunning) || landing || app.seekPreviewActive)readonly property bool canSeek: visible && app.deckPlayer.duration > 0 && (!app.useCider || (app.ciderService.canSeek && !app.listeningService.busy))property bool dragging: false+ readonly property real pivotX: app.threeDActive ? 455 : 378+ readonly property real pivotY: app.threeDActive ? 80 : 100+ readonly property real armLength: app.threeDActive ? 280 : 197+ readonly property real startAngle: app.threeDActive ? 20 : 6+ readonly property real angleRange: app.threeDActive ? 22 : 20property real dragAngle: -4property real rawAngle: -4property real lastPointerAngle: 0@@ -18,10 +23,10 @@ Item {property bool wasPlaying: falseproperty bool landing: falseproperty real landingProgress: 0- readonly property real previewProgress: Math.max(0, Math.min(1, (rawAngle - 6) / 20))+ readonly property real previewProgress: Math.max(0, Math.min(1, (rawAngle - startAngle) / angleRange))property real lowered: dragging ? .12 : engaged ? 1 : 0property real groove: Math.max(0, Math.min(1, app.recordVisualProgress))- property real armAngle: dragging ? dragAngle : engaged ? 6 + 20 * groove : -4+ property real armAngle: dragging ? dragAngle : engaged ? startAngle + angleRange * groove : -4Behavior on armAngle {enabled: arm.motion && !arm.app.seekPreviewActiveSpringAnimation { id: angleSpring; spring: 6; damping: .55; epsilon: .01 }@@ -33,7 +38,7 @@ Item {}function dropNeedle() {if (!dragging) return- const valid = canSeek && dragTrack === app.cassetteTrackIdentity && rawAngle >= 4 && rawAngle <= 28 && pointerDistance > 120 && pointerDistance < 290+ const valid = canSeek && dragTrack === app.cassetteTrackIdentity && rawAngle >= startAngle-2 && rawAngle <= startAngle+angleRange+2 && pointerDistance > armLength*.6 && pointerDistance < armLength*1.5const position = previewProgressif (!valid) { dragging = false; return }landingProgress = position; landing = true; landingTimeout.restart()@@ -192,7 +197,7 @@ Item {onActiveFocusChanged: if (!activeFocus) pointerFocus = falsereadonly property point tip: {const angle = arm.armAngle * Math.PI / 180- return Qt.point(378 - 197 * Math.sin(angle), 100 + 197 * Math.cos(angle))+ return Qt.point(arm.pivotX - arm.armLength * Math.sin(angle), arm.pivotY + arm.armLength * Math.cos(angle))}containmentMask: QtObject {function contains(point: point): bool { return Math.hypot(point.x - needleHit.tip.x, point.y - needleHit.tip.y) <= 27 }@@ -206,22 +211,22 @@ Item {pointerFocus = trueforceActiveFocus()arm.dragAngle = arm.armAngle; arm.rawAngle = arm.armAngle- arm.lastPointerAngle = Math.atan2(378 - mouse.x, mouse.y - 100) * 180 / Math.PI+ arm.lastPointerAngle = Math.atan2(arm.pivotX - mouse.x, mouse.y - arm.pivotY) * 180 / Math.PIarm.dragTrack = arm.app.cassetteTrackIdentity; arm.wasPlaying = arm.app.deckPlayer.playing- arm.pointerDistance = Math.hypot(mouse.x - 378, mouse.y - 100)+ arm.pointerDistance = Math.hypot(mouse.x - arm.pivotX, mouse.y - arm.pivotY)arm.dragging = true; arm.landing = false; landingTimeout.stop()if (arm.wasPlaying) arm.app.deckPlayer.pause()}function movePointer(mouse) {if (!arm.dragging) return- const dx = mouse.x - 378, dy = mouse.y - 100+ const dx = mouse.x - arm.pivotX, dy = mouse.y - arm.pivotYarm.pointerDistance = Math.hypot(dx, dy)const pointer = Math.atan2(-dx, dy) * 180 / Math.PIlet delta=pointer-arm.lastPointerAngleif(delta>180)delta-=360;else if(delta < -180)delta+=360arm.rawAngle += delta*((mouse.modifiers & Qt.ShiftModifier)?.1:1)arm.lastPointerAngle=pointer- arm.dragAngle = Math.max(-8, Math.min(38, arm.rawAngle))+ arm.dragAngle = Math.max(-8, Math.min(arm.startAngle+arm.angleRange+12, arm.rawAngle))}function endPointer() { hintDismissed = true; arm.dropNeedle() }function cancelPointer() { hintDismissed = true; arm.cancelDrag(true) }diff --git a/qml/Vinyl3D.qml b/qml/Vinyl3D.qmlnew file mode 100644index 0000000..c28238c--- /dev/null+++ b/qml/Vinyl3D.qml@@ -0,0 +1,255 @@+import QtQuick+import QtQuick3D+import Spun 1.0++Node {+ id: deck+ objectName: "vinylTurntable"+ required property var app+ required property Texture artworkTexture+ required property Texture outgoingTexture+ property alias recordSpace: recordSpace+ property alias lidNode: lid+ property bool coverOpen: true+ property int pressedControl: -1+ property bool armed: false+ readonly property real lidAngle: app.swapRunning ? 72 : coverOpen ? 68 : 0+ property real coverAngle: lidAngle+ Behavior on coverAngle { enabled: deck.app.animate; NumberAnimation { duration: 360; easing.type: Easing.InOutCubic } }+ function beginHardware(index) { pressedControl=index;armed=true }+ function cancelHardware() { pressedControl=-1;armed=false }+ function endHardware() {+ const index=pressedControl, activate=armed+ cancelHardware()+ if(!activate)return+ if(index===0)player.vinylSpeed=33+ else if(index===1)player.vinylSpeed=45+ else if(index===2 && app.deckPlayer.count>0)app.deckPlayer.toggle()+ else if(index===3)coverOpen=!coverOpen+ }+ function needlePoint() { return stylus.mapPositionToScene(Qt.vector3d(0,0,0)) }+ function controlPoint(index) {+ if(index<2)return mapPositionToScene(Qt.vector3d(-217+index*40,-200,-21))+ if(index===2)return cueCap.mapPositionToScene(Qt.vector3d(0,0,3.2))+ return lid.mapPositionToScene(Qt.vector3d(0,-180,70))+ }+ Texture { id: grain; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "bead-normal" } }+ Texture { id: molded; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "molded" } }+ Texture { id: brushed; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "brushed" } }+ Texture { id: knurl; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "knurled-normal" } }+ Texture { id: microGrooves; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "vinyl-normal" } }+ Texture { id: lacquer; generateMipmaps: true; mipFilter: Texture.Linear; textureData: SurfaceTexture { kind: "lacquer" } }+ 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: 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: 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: glassEdge; baseColor: "#9eacb0"; alphaMode: PrincipledMaterial.Blend; opacity: .3; roughness: .18; depthDrawMode: Material.NeverDepthDraw }+ component Plate: Model {+ id: plate+ property int vinylControl: -1+ property vector3d size: Qt.vector3d(20,20,4)+ property real rounding: 2+ property Material finish: enclosure+ pickable: true+ geometry: DeckGeometry { dimensions: plate.size; radius: plate.rounding }+ materials: [finish]+ }+ component Ring: Model {+ id: ring+ property int vinylControl: -1+ property real radius: 10+ property real hole: .2+ property real depth: 2+ property bool grooves: false+ property Material finish: armFinish+ pickable: true+ geometry: RecordGeometry { radius: ring.radius; hole: ring.hole; depth: ring.depth; grooves: ring.grooves }+ materials: [finish]+ }+ component Screw: Node {+ Ring { radius: 2.5; hole: .3; depth: 1.1; finish: steel }+ Plate { size: Qt.vector3d(3.4,.65,.25); z: .65; rounding: .2; finish: rubber }+ }+ Plate { objectName: "threeDEnclosure"; size: Qt.vector3d(535,398,42); z: -23; rounding: 3 }+ Plate { objectName: "threeDEnclosureSeam"; size: Qt.vector3d(533,396,1.1); z: -4.2; rounding: 2; finish: rubber }+ Plate { objectName: "threeDTopPlate"; size: Qt.vector3d(535,398,2.5); z: -1.2; rounding: 2; finish: topFinish }+ Plate { size: Qt.vector3d(511,378,4); z: -45; rounding: 5; finish: rubber }+ Repeater3D {+ model: 4+ Screw { required property int index; x: index%2?178:-178; y: index<2?124:-124; z: -47.5; eulerRotation.x: 180 }+ }+ Repeater3D {+ model: 12+ Plate { required property int index; x: -44+index*8; y: 60; z: -47.1; size: Qt.vector3d(3,52,.4); rounding: 1.5; finish: enclosure }+ }+ Model { objectName: "threeDFrontRibs"; geometry: TurntableDetailGeometry { fascia: true } x: 4; y: -199.5; z: -23; eulerRotation.x: 90; materials: armFinish }+ Repeater3D {+ model: 4+ Node {+ required property int index+ x: index%2?214:-214; y: index<2?148:-148; z: -52+ Ring { radius: 28; depth: 14; finish: rubber }+ Ring { radius: 25.5; depth: 3; z: 6; finish: armFinish }+ Ring { radius: 27.8; hole: 26.5; depth: .8; z: -3; finish: armFinish }+ Ring { radius: 25; depth: 2.5; z: -8; finish: rubber }+ }+ }+ Repeater3D {+ model: 2+ Node {+ id: speedKey+ required property int index+ readonly property bool selected: player.vinylSpeed===(index?45:33)+ readonly property real pressure: Math.max(0,travel.value)+ property SpunSpring travel: SpunSpring { targetValue: deck.pressedControl===speedKey.index && deck.armed?1:0; epsilon: .005 }+ x: -217+index*40; y: -199.5; z: -20; eulerRotation.x: 90+ Ring { radius: 12.5; depth: .8; finish: rubber }+ Plate { objectName: "vinylSpeedKey"+speedKey.index; vinylControl: speedKey.index; size: Qt.vector3d(22,22,2.5); rounding: 11; z: 1.5-speedKey.pressure; finish: armFinish }+ Ring { radius: 1.2; depth: .1; z: 2.85-speedKey.pressure; finish: PrincipledMaterial { baseColor: speedKey.selected?deck.app.accent:"#59616a"; lighting: PrincipledMaterial.NoLighting } }+ Model { source: "#Rectangle"; y: -17; z: 1; scale: Qt.vector3d(.23,.085,1); materials: PrincipledMaterial {+ lighting: PrincipledMaterial.NoLighting; alphaMode: PrincipledMaterial.Blend; baseColorMap: Texture { sourceItem: Text { width: 92; height: 34; text: speedKey.index?"45":"33⅓"; font.pixelSize: 26; font.family: "sans-serif"; color: "#b7bfc2"; horizontalAlignment: Text.AlignHCenter } }+ } }+ }+ }+ // Local record coordinates retain the same artwork and seek ring contract.+ Node {+ id: recordSpace+ x: -50; y: 0; z: 16+ Ring { radius: 155; depth: 3; z: -15; finish: rubber }+ Ring { objectName: "threeDPlatter"; radius: 182.5; depth: 15; z: -7; finish: accentMetal }+ Ring { objectName: "threeDPlatterLip"; radius: 182.5; hole: 181.5; depth: .7; z: .6; finish: steel }+ Ring { radius: 180.5; depth: 2; z: 1.1; finish: rubber }+ Node {+ objectName: "threeDMedium"+ x: deck.app.swapOffset*.86; opacity: deck.app.incomingOpacity+ eulerRotation.z: -deck.app.spinAngle+ Ring { objectName: "threeDRecord"; radius: 176; hole: 3.5; depth: 2.8; grooves: true; z: 4; finish: discFinish }+ Ring { objectName: "threeDRunout"; radius: 78; hole: 62.6; depth: .07; z: 5.47; finish: runoutFinish }+ Ring { radius: 175.7; hole: 174; depth: .06; z: 5.46; finish: runoutFinish }+ Repeater3D {+ objectName: "threeDTrackBands"+ model: deck.app.recordMap ? deck.app.recordMap.rows.length-1 : 0+ Ring {+ required property int index+ readonly property real angle: (20+22*deck.app.recordMap.rows[index+1].start/deck.app.recordMap.total)*Math.PI/180+ radius: Math.hypot(202.1-240.8*Math.sin(angle),120.4-240.8*Math.cos(angle))+ hole: radius-.65; depth: .06; z: 5.46; finish: runoutFinish+ }+ }+ Ring { objectName: "threeDRecordLabel"; radius: 62; hole: 3.5; depth: .25; z: 5.6; finish: paper }+ Ring { radius: 62.6; hole: 61.8; depth: .3; z: 5.55; finish: discFinish }+ }+ Node {+ objectName: "threeDOutgoingMedium"+ visible: deck.app.outgoingOpacity>0; x: deck.app.outgoingOffset*.86; opacity: deck.app.outgoingOpacity+ eulerRotation.z: -deck.app.outgoingAngle+ Ring { radius: 176; hole: 3.5; depth: 2.8; z: 4; grooves: true; finish: discFinish }+ Ring { radius: 62; hole: 3.5; depth: .25; z: 5.6; finish: PrincipledMaterial { baseColorMap: deck.outgoingTexture; roughness: .92 } }+ }+ Ring { radius: 5.5; hole: 3; depth: .8; z: 6; finish: steel }+ Model { source: "#Cylinder"; z: 10; eulerRotation.x: 90; scale: Qt.vector3d(.055,.1,.055); materials: steel }+ Model { source: "#Cone"; z: 16; eulerRotation.x: 90; scale: Qt.vector3d(.055,.04,.055); materials: steel }+ Model {+ visible: deck.app.deckPlayer.count>0+ geometry: WaveGeometry { progress: deck.app.recordVisualProgress; phase: deck.app.wavePhase; amplitude: deck.app.deckPlayer.playing?2.4:0 }+ materials: PrincipledMaterial { baseColor: deck.app.accent; lighting: PrincipledMaterial.NoLighting; cullMode: Material.NoCulling }+ }+ Node {+ objectName: "threeDTonearm"+ x: 202.1; y: 120.4; z: -2+ Ring { radius: 32; depth: 8; z: -8; finish: armFinish }+ Ring { objectName: "threeDBearingCollar"; radius: 22; depth: 8; z: 0; finish: armFinish }+ Ring { radius: 19; hole: 16; depth: 1; z: 4.6; finish: steel }+ Plate { objectName: "threeDBearingHousing"; size: Qt.vector3d(34,30,26); z: 20; rounding: 9; finish: armFinish }+ Repeater3D { model: 2; Node { required property int index; x: index?18:-18; z: 22; eulerRotation.y: 90; Ring { radius: 6; depth: 1.5; finish: armFinish } Screw { z: 1 } } }+ Node {+ id: armPivot+ z: 24+ eulerRotation.z: deck.app.tonearm ? -deck.app.tonearm.armAngle : 4+ eulerRotation.x: deck.app.tonearm ? -5*(1-deck.app.tonearm.lowered) : 0+ Model { objectName: "threeDArmTube"; pickable: true; property int vinylControl: 30; source: "#Cylinder"; y: -105; scale: Qt.vector3d(.065,2.1,.065); materials: armFinish }+ Model { source: "#Cylinder"; y: 25; scale: Qt.vector3d(.07,.5,.07); materials: steel }+ Model { objectName: "threeDCounterweight"; source: "#Cylinder"; y: 33; scale: Qt.vector3d(.31,.26,.31); materials: PrincipledMaterial { baseColor: "#282e34"; metalness: .8; roughness: .4; normalMap: knurl; normalStrength: .25 } }+ Ring { radius: 15.8; hole: 14.6; depth: 1; y: 46.5; eulerRotation.x: 90; finish: armFinish }+ Model { source: "#Cylinder"; y: 18; scale: Qt.vector3d(.27,.045,.27); materials: rubber }+ Repeater3D { model: 12; Plate { required property int index; x: Math.sin(index*Math.PI/6)*13.6; z: Math.cos(index*Math.PI/6)*13.6; y: 18; size: Qt.vector3d(.45,2,.5); rounding: .1; eulerRotation.y: index*30; finish: steel } }+ Model { source: "#Cylinder"; y: -206; scale: Qt.vector3d(.10,.1,.10); materials: PrincipledMaterial { baseColor: "#41484d"; metalness: .9; roughness: .34; normalMap: knurl; normalStrength: .4 } }+ Node {+ y: -223; z: -1+ Model { objectName: "threeDHeadshell"; property int vinylControl: 30; pickable: true; geometry: TurntableDetailGeometry {} materials: armFinish }+ Plate { vinylControl: 30; y: 12; size: Qt.vector3d(22,6,2); rounding: 1.2; finish: armFinish }+ Plate { vinylControl: 30; y: -15; size: Qt.vector3d(22,12,2); rounding: 1.4; finish: armFinish }+ Repeater3D { model: 2; Plate { required property int index; vinylControl: 30; x: index?10:-10; size: Qt.vector3d(2,20,2); rounding: .6; finish: armFinish } }+ Screw { x: -6.5; y: -13; z: 1.8 } Screw { x: 6.5; y: -13; z: 1.8 }+ Plate { objectName: "threeDFingerLift"; vinylControl: 30; x: 17; y: -5; z: 3; size: Qt.vector3d(17,3,2); rounding: 1; eulerRotation.y: -18; finish: armFinish }+ Plate { vinylControl: 30; x: 24; y: -5; z: 5; size: Qt.vector3d(3,3,5); rounding: 1; finish: armFinish }+ Repeater3D {+ model: 4+ Node {+ required property int index+ x: -4.5+index*3; y: 4; z: -4+ Model { source: "#Cylinder"; scale: Qt.vector3d(.013,.09,.013); eulerRotation.x: -28; materials: PrincipledMaterial { baseColor: ["#743f38","#d6d2bb","#3e6571","#456951"][index]; roughness: .72 } }+ Ring { y: 4; z: -2; radius: 1.1; depth: 2; eulerRotation.x: 90; finish: steel }+ }+ }+ Plate { objectName: "threeDCartridge"; vinylControl: 30; y: -10; z: -6; size: Qt.vector3d(15,23,10); rounding: 1.3; finish: rubber }+ Plate { vinylControl: 30; y: -16; z: -10; size: Qt.vector3d(16,11,7); rounding: 1; finish: PrincipledMaterial { baseColor: "#d4cbb5"; roughness: .62 } }+ Plate { y: -17.8; z: -13.5; size: Qt.vector3d(1,8,1); rounding: .3; eulerRotation.x: 12; finish: steel }+ Model { id: stylus; objectName: "threeDStylus"; source: "#Cone"; y: -17.8; z: -15.5; eulerRotation.x: -90; scale: Qt.vector3d(.012,.027,.012); materials: steel }+ }+ }+ }+ }+ // The cue lever shares playback state with the needle and transport bar.+ Node {+ id: cue; x: 199; y: 104; z: 8+ Ring { radius: 8; depth: 12; finish: armFinish }+ Node {+ z: 6; eulerRotation.x: tilt.value+ property SpunSpring tilt: SpunSpring { targetValue: (deck.app.deckPlayer.playing?-24:22)+(deck.pressedControl===2&&deck.armed?7:0); epsilon: .01 }+ Plate { vinylControl: 2; size: Qt.vector3d(5,5,24); z: 12; rounding: 1; finish: armFinish }+ Plate { id: cueCap; objectName: "vinylCueLever"; vinylControl: 2; size: Qt.vector3d(10,9,6); z: 24; rounding: 3; finish: rubber }+ }+ }+ Node { x: 162; y: 70; z: 8; Ring { radius: 5; depth: 16; finish: armFinish } Plate { size: Qt.vector3d(14,4,4); z: 9; rounding: 1; finish: rubber } }+ Node { x: 204; y: 143; z: 6; Ring { radius: 9; depth: 7; finish: accentMetal } Ring { radius: 6.5; depth: 1; z: 4; finish: armFinish } }+ Repeater3D {+ model: 2+ Node {+ required property int index+ x: index?194:-194; y: 187; z: 7+ Plate { size: Qt.vector3d(35,22,9); rounding: 2; finish: rubber }+ Model { source: "#Cylinder"; eulerRotation.z: 90; scale: Qt.vector3d(.09,.29,.09); materials: steel }+ Plate { size: Qt.vector3d(32,4,31); y: 6; z: 10; rounding: 2; finish: armFinish }+ }+ }+ Node {+ id: lid+ objectName: "vinylDustCover"+ y: 187; z: 7; eulerRotation.x: -deck.coverAngle+ Model { property int vinylControl: 3; pickable: true; objectName: "threeDLid"; y: -185; z: 70; source: "#Cube"; scale: Qt.vector3d(5.24,3.74,.016); materials: glass; castsShadows: false; receivesShadows: false }+ Model { property int vinylControl: 3; pickable: true; x: -261; y: -185; z: 35; source: "#Cube"; scale: Qt.vector3d(.7,3.71,.016); eulerRotation.y: 90; materials: glass; castsShadows: false; receivesShadows: false }+ Model { property int vinylControl: 3; pickable: true; x: 261; y: -185; z: 35; source: "#Cube"; scale: Qt.vector3d(.7,3.71,.016); eulerRotation.y: -90; materials: glass; castsShadows: false; receivesShadows: false }+ Model { property int vinylControl: 3; pickable: true; y: -371; z: 35; source: "#Cube"; scale: Qt.vector3d(5.21,.7,.016); eulerRotation.x: 90; materials: glass; castsShadows: false; receivesShadows: false }+ Repeater3D { model: 2; Plate { vinylControl: 3; required property int index; x: index?261:-261; y: -185; z: 70; size: Qt.vector3d(1.2,369,1.2); rounding: .5; finish: glassEdge; castsShadows: false } }+ Plate { vinylControl: 3; y: -371; z: 70; size: Qt.vector3d(511,1.5,1.5); rounding: .7; finish: glassEdge; castsShadows: false }+ Plate { vinylControl: 3; y: -372; z: 7; size: Qt.vector3d(31,4,5); rounding: 2; finish: glassEdge; castsShadows: false }+ }+ // Rear connections are modeled as sockets, without vendor marks or radio claims.+ Node {+ y: 200; z: -23; eulerRotation.x: -90+ Plate { size: Qt.vector3d(218,29,2); rounding: 4; finish: rubber }+ Repeater3D { model: 2; Node { required property int index; x: -70+index*28; Ring { radius: 7; hole: 3; depth: 3; finish: steel } Ring { radius: 5.6; hole: 3; depth: 3.2; finish: PrincipledMaterial { baseColor: index?"#cbc9b9":"#a34236"; roughness: .6 } } } }+ Ring { x: 68; radius: 7; hole: 3.5; depth: 2; finish: armFinish }+ Screw { x: -98; z: 1.5 } Screw { x: 98; z: 1.5 }+ }+}diff --git a/scripts/test-3d.sh b/scripts/test-3d.shindex af77715..c80d95f 100755--- a/scripts/test-3d.sh+++ b/scripts/test-3d.sh@@ -14,14 +14,14 @@ if [[ $renderer == cpu ]]; thenexport QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=rhi QSG_RHI_BACKEND=opengl QSG_RENDER_LOOP=basicexport LIBGL_ALWAYS_SOFTWARE=1 __GLX_VENDOR_LIBRARY_NAME=mesa LP_NUM_THREADS=2export QT_QPA_PLATFORMTHEME=- suites=(artwork 3d-lighting media-ui)+ suites=(turntable recorder artwork 3d-lighting media-ui)echo 'Running focused offscreen CPU checks. Native lifecycle tests require SPUN_TEST_RENDERER=native.'elif [[ $renderer == native ]]; thenif [[ ${QT_QUICK_BACKEND:-} == software || ${QT_QPA_PLATFORM:-wayland} == offscreen || ( -z ${WAYLAND_DISPLAY:-} && -z ${DISPLAY:-} ) ]]; thenecho 'Native lifecycle tests require a separate Wayland or X11 test session.' >&2exit 2fi- suites=(artwork 3d-lighting 3d-ui 3d-library media-ui)+ suites=(turntable recorder artwork 3d-lighting 3d-ui 3d-library media-ui)elseecho 'SPUN_TEST_RENDERER must be cpu or native.' >&2exit 2@@ -37,5 +37,5 @@ QT_QPA_PLATFORM=offscreen QT_QPA_PLATFORMTHEME= "$build_dir/spun-geometry-test"for suite in "${suites[@]}"; dosuite_env=()if [[ $renderer == cpu && $suite == media-ui ]]; then suite_env=(env QT_QUICK_BACKEND=software QSG_RENDER_LOOP=basic); fi- timeout "${SPUN_TEST_TIMEOUT:-240}s" nice -n 10 "${suite_env[@]}" "$build_dir/spun" "--test-$suite" --capture-dir "$report_dir/$suite" 2>&1 | tee "$report_dir/$suite.log"+ timeout "${SPUN_TEST_TIMEOUT:-360}s" nice -n 10 "${suite_env[@]}" "$build_dir/spun" "--test-$suite" --capture-dir "$report_dir/$suite" 2>&1 | tee "$report_dir/$suite.log"donediff --git a/src/artworktest.cpp b/src/artworktest.cppindex 5744023..63b25bc 100644--- a/src/artworktest.cpp+++ b/src/artworktest.cpp@@ -2,6 +2,7 @@#include "player.h"#include "cider.h"#include "disc.h"+#include "recorder.h"#include <QQmlContext>#include <QQuickWindow>#include <QQuickItem>@@ -67,6 +68,7 @@ int exerciseArtwork(Player &player,QQuickWindow *window,const QString &temp,consconst 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;+ 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_3Dauto *view=window->findChild<QObject*>("player3DView");@@ -85,7 +87,7 @@ int exerciseArtwork(Player &player,QQuickWindow *window,const QString &temp,cons#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")}) {+ for(bool threeD:modes)for(const QString &medium:{QString("cd"),QString("vinyl"),QString("cassette"),QString("tp7")}) {context=medium+(threeD?" 3D":" 2D");player.setMedium(medium);player.setThreeD(threeD);QTest::qWait(80);window->setProperty("useCider",false);player.setCover(QUrl::fromLocalFile(temp+"/art-green.png"));check(wait([&]{return !player.artworkLoading();})&&inspect(Qt::green,threeD),"local artwork reaches the active medium");@@ -114,7 +116,7 @@ int exerciseArtwork(Player &player,QQuickWindow *window,const QString &temp,consconst bool tape=player.medium()=="cassette";QVariant projected;QMetaObject::invokeMethod(view,"projectSurface",Q_RETURN_ARG(QVariant,projected),- Q_ARG(QVariant,tape?128.:player.medium()=="cd"?345.:285.),Q_ARG(QVariant,tape?203.:294.));+ 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();if(frame.isNull())return false;@@ -132,7 +134,7 @@ int exerciseArtwork(Player &player,QQuickWindow *window,const QString &temp,consif(!captures.isEmpty()){QDir().mkpath(captures);frame.save(captures+"/render-"+name+".png");}return total>0&&matches>total*.7;};- for(const QString &medium:{QString("vinyl"),QString("cd"),QString("cassette")}) {+ for(const QString &medium:{QString("vinyl"),QString("cd"),QString("cassette"),QString("tp7")}) {context=medium+" rendered artwork";player.setThreeD(false);player.setMedium(medium);player.setMotion(false);publish("render-start",temp+"/art-red.png","First render album");@@ -150,7 +152,7 @@ int exerciseArtwork(Player &player,QQuickWindow *window,const QString &temp,conscheck(originalView&&originalView==window->findChild<QObject*>("player3DView"),"artwork refresh preserves the active 3D scene");player.setMotion(false);}- for(const QString &origin:{QString("cd"),QString("cassette")}) {+ for(const QString &origin:{QString("cd"),QString("cassette"),QString("tp7")}) {context=origin+" to vinyl";player.setMedium(origin);publish("switch-start",temp+"/art-red.png");check(inspect(Qt::red,true),"cover loads before switching medium");@@ -205,7 +207,7 @@ int exerciseArtwork(Player &player,QQuickWindow *window,const QString &temp,cons{"name",id},{"albumName","Album"},{"artistName","Remote artist"},{"playParams",QJsonObject{{"id","library-"+id},{"catalogId",id}}},{"artwork",QJsonObject{{"url",cover}}}};};- for(bool threeD:modes)for(const QString &medium:{QString("cd"),QString("vinyl"),QString("cassette")}) {+ for(bool threeD:modes)for(const QString &medium:{QString("cd"),QString("vinyl"),QString("cassette"),QString("tp7")}) {context=medium+(threeD?" paired 3D":" paired 2D");player.setMedium(medium);player.setThreeD(threeD);QTest::qWait(60);apiCurrent=current("album-a",base+"/slow");paired.track("album-a",QUrl(base+"/slow"),"Album A");check(inspect(Qt::red,threeD),"paired artwork uses the API's matching catalog identity");diff --git a/src/deckgeometry.cpp b/src/deckgeometry.cppindex 1025b5c..00bea34 100644--- a/src/deckgeometry.cpp+++ b/src/deckgeometry.cpp@@ -24,10 +24,15 @@ void DeckGeometry::rebuild() {return QVector3D((corner==0||corner==3?w-r:-w+r)+(r-inset)*n.x(),(corner<2?h-r:-h+r)+(r-inset)*n.y(),z);};- const auto add=[&](QVector3D a,QVector3D b,QVector3D c,QVector3D na,QVector3D nb,QVector3D nc){+ const auto add=[&](QVector3D a,QVector3D b,QVector3D c,QVector3D na,QVector3D nb,QVector3D nc,QVector2D ta=QVector2D(-1,-1),QVector2D tb={},QVector2D tc={}){if(QVector3D::crossProduct(b-a,c-a).lengthSquared()<1e-12f)return;const std::array<QVector3D,3> points={a,b,c},normals={na,nb,nc};- for(int i=0;i<3;++i){const auto v=points[i],n=normals[i];const Vertex out{v.x(),v.y(),v.z(),n.x(),n.y(),n.z(),.5f+v.x()/(2*w),.5f-v.y()/(2*h)};vertices.append(reinterpret_cast<const char*>(&out),sizeof(out));}+ const std::array<QVector2D,3> coordinates={ta,tb,tc};+ for(int i=0;i<3;++i){+ const auto v=points[i],n=normals[i];+ const auto uv=ta.x()<0?QVector2D(.5f+v.x()/(2*w),.5f-v.y()/(2*h)):coordinates[i];+ const Vertex out{v.x(),v.y(),v.z(),n.x(),n.y(),n.z(),uv.x(),uv.y()};vertices.append(reinterpret_cast<const char*>(&out),sizeof(out));+ }};// Quarter-circle edge profiles give highlights an actual rounded surface.struct Edge {float inset,z,radial,vertical;};@@ -46,7 +51,11 @@ void DeckGeometry::rebuild() {const auto a=point(i,lo.inset,lo.z),b=point(j,lo.inset,lo.z),c=point(j,hi.inset,hi.z),e=point(i,hi.inset,hi.z);const auto na=outward(i)*lo.radial+QVector3D(0,0,lo.vertical),nb=outward(j)*lo.radial+QVector3D(0,0,lo.vertical);const auto nc=outward(j)*hi.radial+QVector3D(0,0,hi.vertical),ne=outward(i)*hi.radial+QVector3D(0,0,hi.vertical);- add(a,b,c,na,nb,nc);add(a,c,e,na,nc,ne);+ // Side and bevel textures need height in V. A planar top UV collapses+ // vertical faces and makes the normal-map tangent basis undefined.+ const float u0=float(i)/perimeter,u1=float(i+1)/perimeter;+ const QVector2D ta(u0,.5f+a.z()/(2*d)),tb(u1,.5f+b.z()/(2*d)),tc(u1,.5f+c.z()/(2*d)),te(u0,.5f+e.z()/(2*d));+ add(a,b,c,na,nb,nc,ta,tb,tc);add(a,c,e,na,nc,ne,ta,tc,te);}}clear();setStride(sizeof(Vertex));setVertexData(vertices);setPrimitiveType(QQuick3DGeometry::PrimitiveType::Triangles);diff --git a/src/geometrytest.cpp b/src/geometrytest.cppindex 1eee659..82afa28 100644--- a/src/geometrytest.cpp+++ b/src/geometrytest.cpp@@ -3,10 +3,26 @@#include <QTest>#include <QPointer>#include <cmath>+#include <map>+#include <array>class GeometryTest : public QObject {Q_OBJECTprivate slots:+ void turntableDetails() {+ for(bool fascia:{false,true}) {+ TurntableDetailGeometry mesh;mesh.setProperty("fascia",fascia);+ const auto data=mesh.vertexData();QVERIFY(!data.isEmpty());QVERIFY(data.size()<300000);+ const auto *v=reinterpret_cast<const float*>(data.constData());+ for(int i=0;i<data.size()/int(sizeof(float));i+=8) {+ for(int k=0;k<8;++k)QVERIFY(std::isfinite(v[i+k]));+ QVERIFY(std::abs(QVector3D(v[i+3],v[i+4],v[i+5]).length()-1)<.001);+ QVERIFY(v[i+2]>=mesh.boundsMin().z()-.001f&&v[i+2]<=mesh.boundsMax().z()+.001f);+ if(!fascia)for(int row=-1;row<=1;++row)for(int col=-1;col<=1;++col)+ QVERIFY(std::hypot(v[i]-col*6,v[i+1]-row*6)>1.79);+ }+ }+ }void recordTopology_data() {QTest::addColumn<float>("hole");QTest::addColumn<bool>("grooves");QTest::newRow("CD")<<15.f<<false;QTest::newRow("vinyl")<<3.5f<<true;QTest::newRow("tape-pack")<<31.f<<false;@@ -32,6 +48,59 @@ private slots:QCOMPARE(body.boundsMax()-body.boundsMin(),QVector3D(12,21,11));QVERIFY(body.vertexData().size()>0);}+ void narrowRingsRetainValidChamfers() {+ for(float thickness:{.05f,.25f,3.5f}) {+ RecordGeometry ring;ring.setProperty("radius",3.2f);ring.setProperty("hole",3.f);ring.setProperty("depth",thickness);+ const auto bytes=ring.vertexData();const auto *v=reinterpret_cast<const float*>(bytes.constData());+ bool hasChamfer=false;+ for(int i=0;i<bytes.size()/int(sizeof(float));i+=24) {+ 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-14f);+ for(int k=0;k<24;k+=8) {+ const float radius=std::hypot(v[i+k],v[i+k+1]);+ QVERIFY(radius>=2.999f&&radius<=3.201f);+ QVERIFY(std::abs(v[i+k+2])<=thickness/2+.001f);+ const QVector3D normal(v[i+k+3],v[i+k+4],v[i+k+5]);+ QVERIFY(std::abs(normal.length()-1)<.001f);+ hasChamfer=hasChamfer||(normal.z()>.1f&&normal.z()<.99f);+ }+ }+ QVERIFY(hasChamfer);+ }+ }+ void reelHasOpenShaftAndThreeThroughWindows() {+ ReelGeometry reel;const auto bytes=reel.vertexData();const auto *v=reinterpret_cast<const float*>(bytes.constData());+ const auto covered=[&](QVector2D p) {+ for(int i=0;i<bytes.size()/int(sizeof(float));i+=24) {+ if(v[i+5]<.9f)continue;+ const QVector2D a(v[i],v[i+1]),b(v[i+8],v[i+9]),c(v[i+16],v[i+17]);+ const auto cross=[](QVector2D a,QVector2D b){return a.x()*b.y()-a.y()*b.x();};+ if(cross(b-a,p-a)>=0&&cross(c-b,p-b)>=0&&cross(a-c,p-c)>=0)return true;+ }+ return false;+ };+ QVERIFY(!covered({0,0}));+ for(int i=0;i<3;++i) {+ const float angle=i*2*float(M_PI)/3;+ QVERIFY(!covered({20*std::cos(angle),20*std::sin(angle)}));+ QVERIFY(covered({20*std::cos(angle+float(M_PI)/3),20*std::sin(angle+float(M_PI)/3)}));+ }+ using Point=std::array<int,3>;using Edge=std::array<Point,2>;+ std::map<Edge,int> edges;+ for(int i=0;i<bytes.size()/int(sizeof(float));i+=24) {+ std::array<Point,3> points;+ for(int k=0;k<3;++k) {+ for(int axis=0;axis<3;++axis) {+ const float value=v[i+k*8+axis];QVERIFY(std::isfinite(value));+ QVERIFY(value>=reel.boundsMin()[axis]-.001f&&value<=reel.boundsMax()[axis]+.001f);+ points[k][axis]=qRound(value*1000);+ }+ QVERIFY(std::abs(QVector3D(v[i+k*8+3],v[i+k*8+4],v[i+k*8+5]).length()-1)<.001f);+ }+ for(int k=0;k<3;++k){Edge edge={points[k],points[(k+1)%3]};if(edge[1]<edge[0])std::swap(edge[0],edge[1]);++edges[edge];}+ }+ for(const auto &[edge,count]:edges){Q_UNUSED(edge);QCOMPARE(count,2);}+ }void thinMachinedPartsStayInsideBounds() {for(const auto size:{QVector3D(4,.7,.3),QVector3D(428,428,28),QVector3D(12,21,11)}){DeckGeometry body;body.setProperty("dimensions",size);body.setProperty("radius",2.f);@@ -42,11 +111,37 @@ private slots:}}}+ void texturedHardwareHasNoCollapsedUvTriangles() {+ DeckGeometry deck;deck.setProperty("dimensions",QVector3D(535,398,42));deck.setProperty("radius",3.f);+ TurntableDetailGeometry headshell,fascia;fascia.setProperty("fascia",true);+ for(auto *geometry:QList<QQuick3DGeometry*>{&deck,&headshell,&fascia}) {+ const auto bytes=geometry->vertexData();const auto *v=reinterpret_cast<const float*>(bytes.constData());+ for(int i=0;i<bytes.size()/int(sizeof(float));i+=24) {+ const double du1=v[i+14]-v[i+6],dv1=v[i+15]-v[i+7],du2=v[i+22]-v[i+6],dv2=v[i+23]-v[i+7];+ QVERIFY2(std::abs(du1*dv2-du2*dv1)>1e-12,"Normal mapped triangles must have a finite tangent basis");+ }+ }+ }+ void cylindricalWallsHaveAxialTextureCoordinates() {+ RecordGeometry ring;ring.setProperty("depth",12.f);ring.setProperty("radius",40.f);+ const auto bytes=ring.vertexData();const auto *v=reinterpret_cast<const float*>(bytes.constData());+ int sides=0;+ for(int i=0;i<bytes.size()/int(sizeof(float));i+=24) {+ if(std::abs(v[i+5])>.1f)continue;+ ++sides;+ const float low=qMin(v[i+7],qMin(v[i+15],v[i+23])),high=qMax(v[i+7],qMax(v[i+15],v[i+23]));+ QVERIFY(high-low>.9f);+ const float uLow=qMin(v[i+6],qMin(v[i+14],v[i+22])),uHigh=qMax(v[i+6],qMax(v[i+14],v[i+22]));+ QVERIFY(uHigh-uLow<.1f);+ }+ QVERIFY(sides>40);+ }void materialMapsAreBoundedAndRepeatable() {QByteArray previous;- for(const QString kind:{QString("brushed"),QString("molded"),QString("vinyl"),QString("disc"),QString("turned"),QString("metal-normal")}){+ 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")}){SurfaceTexture first,second;first.setProperty("kind",kind);second.setProperty("kind",kind);- QCOMPARE(first.size(),QSize(256,256));QCOMPARE(first.textureData().size(),256*256*4);+ 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);QCOMPARE(first.textureData(),second.textureData());QVERIFY(first.textureData()!=previous);previous=first.textureData();}@@ -81,6 +176,19 @@ private slots:QCOMPARE(probe.size(),QSize(512,256));QCOMPARE(probe.textureData().size(),512*256*4);QVERIFY(probe.textureData()!=neutral);const auto blue=probe.textureData();probe.setProperty("tint",QColor("#e8ac80"));QVERIFY(probe.textureData()!=blue);}+ void studioProbeRetainsHdrAndSeamlessEdges() {+ StudioTexture probe;QCOMPARE(probe.format(),QQuick3DTextureData::RGBE8);+ const auto bytes=probe.textureData();const auto *p=reinterpret_cast<const unsigned char*>(bytes.constData());+ double minimum=10,maximum=0;+ const auto component=[&](int pixel,int channel){return std::ldexp(double(p[pixel*4+channel])/256,int(p[pixel*4+3])-128);};+ for(int i=0;i<512*256;++i)for(int channel=0;channel<3;++channel) {+ const double value=component(i,channel);QVERIFY(std::isfinite(value)&&value>=0&&value<4);+ minimum=qMin(minimum,value);maximum=qMax(maximum,value);+ }+ QVERIFY(maximum>2);QVERIFY(minimum<.1);+ for(int y=0;y<256;++y)for(int channel=0;channel<3;++channel)+ QVERIFY(std::abs(component(y*512,channel)-component(y*512+511,channel))<.015);+ }void waveIsFiniteAtEndpoints() {for(bool linear:{false,true})for(float progress:{0.f,.25f,1.f}){WaveGeometry wave;wave.setProperty("linear",linear);wave.setProperty("progress",progress);wave.setProperty("amplitude",2.4f);diff --git a/src/main.cpp b/src/main.cppindex 6207cf2..45611ab 100644--- a/src/main.cpp+++ b/src/main.cpp@@ -14,11 +14,14 @@#include "mediauitest.h"#include "artworktest.h"#include "threedtest.h"+#include "recordertest.h"+#include "turntabletest.h"#include "testinput.h"#endif#include "lyrics.h"#include "artwork.h"#include "disc.h"+#include "recorder.h"#include "playerbody.h"#include "symbol.h"#include "mpris.h"@@ -125,6 +128,7 @@ public:if (!window) return;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 targetHeight = window->property("layoutHeight").toInt();const qreal scale=qBound(.5,window->property("uiScale").toDouble(),1.5);@@ -149,13 +153,13 @@ public:}if (mini && window->property("menuOpen").toBool()) { setMask(QRegion(0,0,targetWidth,targetHeight));return; }if (mini) {- QRegion region=cassette?QRegion(18,60,264,176):QRegion(6,6,288,288,QRegion::Ellipse);+ QRegion region=recorder?QRegion(38,15,205,267):cassette?QRegion(18,60,264,176):QRegion(6,6,288,288,QRegion::Ellipse);if(cassette)region|=QRegion(50,240,200,26);if (window->property("backgroundBlur").toBool()) {QPainterPath backdrop; backdrop.addRoundedRect(QRectF(0,0,300,targetHeight),21,21);region=QRegion(backdrop.toFillPolygon().toPolygon());}- else if(!cassette)region-=window->property("vinyl").toBool()?QRegion(146,146,8,8,QRegion::Ellipse):QRegion(136,136,28,28,QRegion::Ellipse);+ else if(!cassette&&!recorder)region-=window->property("vinyl").toBool()?QRegion(146,146,8,8,QRegion::Ellipse):QRegion(136,136,28,28,QRegion::Ellipse);region |= QRegion(50,268,200,targetHeight-270);if (auto *notice=window->findChild<QQuickItem *>("actionNotice"); notice && notice->isVisible())region |= itemRegion(notice);@@ -174,6 +178,7 @@ public:if(body) {QPainterPath housing;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);region=QRegion(housing.toFillPolygon().toPolygon());@@ -181,7 +186,7 @@ public:if(window->property("swapRunning").toBool())region|=QRegion(45,74,440,440);}if(window->property("threeDActive").toBool())region=QRegion(12,62,506,460);- if(!cassette && !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(!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"))@@ -1516,7 +1521,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-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 == "--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"|| 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");@@ -1552,6 +1557,8 @@ int main(int argc, char **argv) {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-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"});parser.addOption({"test-import-ui", "Run isolated folder import UI checks"});parser.addOption({"smoke-live", "Run isolated checks on the live desktop"});@@ -1565,7 +1572,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-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-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();@@ -1614,12 +1621,15 @@ int main(int argc, char **argv) {#ifdef SPUN_WITH_3DqmlRegisterType<DeckGeometry>("Spun",1,0,"DeckGeometry");qmlRegisterType<RecordGeometry>("Spun",1,0,"RecordGeometry");+ qmlRegisterType<ReelGeometry>("Spun",1,0,"ReelGeometry");+ qmlRegisterType<TurntableDetailGeometry>("Spun",1,0,"TurntableDetailGeometry");qmlRegisterType<CoverTexture>("Spun",1,0,"CoverTexture");qmlRegisterType<SurfaceTexture>("Spun",1,0,"SurfaceTexture");qmlRegisterType<StudioTexture>("Spun",1,0,"StudioTexture");qmlRegisterType<WaveGeometry>("Spun",1,0,"WaveGeometry");#endifqmlRegisterType<PlayerBody>("Spun",1,0,"PlayerBody");+ qmlRegisterType<RecorderSurface>("Spun",1,0,"RecorderSurface");qmlRegisterType<Disc>("Spun", 1, 0, "Disc");qmlRegisterType<ArtworkView>("Spun", 1, 0, "ArtworkView");qmlRegisterType<ProgressRing>("Spun", 1, 0, "ProgressRing");@@ -1649,7 +1659,7 @@ 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"}.contains(benchmarkMedium)) return 2;+ if (!QStringList{"cd","vinyl","cassette","tp7"}.contains(benchmarkMedium)) return 2;player.setMedium(benchmarkMedium);}QList<double> frameIntervals;@@ -2070,6 +2080,8 @@ int main(int argc, char **argv) {std::cout << "RESULT " << failures << " failures" << std::endl;app.exit(failures ? 1 : 0);});+ 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"))); });else if (parser.isSet("test-3d-lighting")) QTimer::singleShot(650, &app, [&] { app.exit(exerciseThreeDLighting(player,window,temp.path(),parser.value("capture-dir"))); });else if (parser.isSet("test-3d-ui")) QTimer::singleShot(650, &app, [&] { app.exit(exerciseThreeD(player,window,temp.path(),parser.value("capture-dir"))); });diff --git a/src/mediageometry.cpp b/src/mediageometry.cppindex 1241d31..518a98e 100644--- a/src/mediageometry.cpp+++ b/src/mediageometry.cpp@@ -8,8 +8,12 @@namespace {struct Vertex { float x,y,z,nx,ny,nz,u,v; };-void triangle(QByteArray &data,QVector3D a,QVector3D b,QVector3D c,float radius,bool smoothRadial=false) {+void triangle(QByteArray &data,QVector3D a,QVector3D b,QVector3D c,float radius,bool smoothRadial=false,float wallDepth=0) {const auto n=QVector3D::crossProduct(b-a,c-a).normalized();+ const bool cylindrical=wallDepth>0&&std::abs(n.z())<.95f;+ const auto longitude=[](QVector3D p){return .5f+std::atan2(p.y(),p.x())/(2*float(M_PI));};+ const float minimum=cylindrical?qMin(longitude(a),qMin(longitude(b),longitude(c))):0;+ const float maximum=cylindrical?qMax(longitude(a),qMax(longitude(b),longitude(c))):0;for(const auto &p:{a,b,c}){auto normal=n;if(smoothRadial && std::hypot(p.x(),p.y())>.001f) {@@ -18,7 +22,17 @@ void triangle(QByteArray &data,QVector3D a,QVector3D b,QVector3D c,float radius,const auto xy=QVector3D(p.x(),p.y(),0).normalized()*radial*direction;normal=QVector3D(xy.x(),xy.y(),n.z()).normalized();}- const Vertex v{p.x(),p.y(),p.z(),normal.x(),normal.y(),normal.z(),.5f+p.x()/(radius*2),.5f-p.y()/(radius*2)};data.append(reinterpret_cast<const char*>(&v),sizeof(v));}+ float u=.5f+p.x()/(radius*2),v=.5f-p.y()/(radius*2);+ if(!smoothRadial&&std::abs(n.z())<qMax(std::abs(n.x()),std::abs(n.y()))) {+ u=.5f+(std::abs(n.x())>std::abs(n.y())?p.y():p.x())/(radius*2);+ v=.5f-p.z()/(radius*2);+ }+ if(cylindrical) {+ u=longitude(p);+ if(maximum-minimum>.5f&&u<.5f)u+=1;+ v=.5f+p.z()/wallDepth;+ }+ const Vertex vertex{p.x(),p.y(),p.z(),normal.x(),normal.y(),normal.z(),u,v};data.append(reinterpret_cast<const char*>(&vertex),sizeof(vertex));}}void upload(QQuick3DGeometry *geometry,const QByteArray &data,QVector3D low,QVector3D high) {geometry->clear();geometry->setStride(sizeof(Vertex));geometry->setVertexData(data);geometry->setPrimitiveType(QQuick3DGeometry::PrimitiveType::Triangles);@@ -31,19 +45,102 @@ void upload(QQuick3DGeometry *geometry,const QByteArray &data,QVector3D low,QVecRecordGeometry::RecordGeometry(QQuick3DObject *parent):QQuick3DGeometry(parent){connect(this,&RecordGeometry::shapeChanged,this,&RecordGeometry::rebuild);rebuild();}void RecordGeometry::rebuild() {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=128;+ QByteArray data;const int radial=m_grooves?80:1,segments=qBound(24,int(std::ceil(radius*1.1f)),128);constexpr float grooveHeight=.012f;- data.reserve((radial+3)*segments*6*sizeof(Vertex));- const auto point=[](float r,int i,float z){const float a=i*2*float(M_PI)/128;return QVector3D(r*std::cos(a),r*std::sin(a),z);};- const auto quad=[&](QVector3D a,QVector3D b,QVector3D c,QVector3D d){triangle(data,a,b,c,radius,true);triangle(data,a,c,d,radius,true);};+ data.reserve((radial+5)*segments*6*sizeof(Vertex));+ const float bevel=qMin(.35f,qMin(depth*.2f,(radius-hole)*.2f));+ const float inner=hole+bevel,outer=radius-bevel;+ const auto point=[segments](float r,int i,float z){const float a=i*2*float(M_PI)/segments;return QVector3D(r*std::cos(a),r*std::sin(a),z);};+ const auto quad=[&](QVector3D a,QVector3D b,QVector3D c,QVector3D d){triangle(data,a,b,c,radius,true,depth);triangle(data,a,c,d,radius,true,depth);};for(int i=0;i<segments;++i){- for(int j=0;j<radial;++j){const float a=hole+(radius-hole)*j/radial,b=hole+(radius-hole)*(j+1)/radial;const float za=depth/2+(m_grooves&&j%2?grooveHeight:0),zb=depth/2+(m_grooves&&(j+1)%2?grooveHeight:0);quad(point(a,i,za),point(b,i,zb),point(b,i+1,zb),point(a,i+1,za));}+ for(int j=0;j<radial;++j){const float a=inner+(outer-inner)*j/radial,b=inner+(outer-inner)*(j+1)/radial;const float za=depth/2+(m_grooves&&j%2?grooveHeight:0),zb=depth/2+(m_grooves&&(j+1)%2?grooveHeight:0);quad(point(a,i,za),point(b,i,zb),point(b,i+1,zb),point(a,i+1,za));}quad(point(hole,i,-depth/2),point(hole,i+1,-depth/2),point(radius,i+1,-depth/2),point(radius,i,-depth/2));- quad(point(radius,i,-depth/2),point(radius,i+1,-depth/2),point(radius,i+1,depth/2),point(radius,i,depth/2));- quad(point(hole,i,depth/2),point(hole,i+1,depth/2),point(hole,i+1,-depth/2),point(hole,i,-depth/2));+ quad(point(radius,i,-depth/2),point(radius,i+1,-depth/2),point(radius,i+1,depth/2-bevel),point(radius,i,depth/2-bevel));+ quad(point(radius,i,depth/2-bevel),point(radius,i+1,depth/2-bevel),point(outer,i+1,depth/2),point(outer,i,depth/2));+ quad(point(inner,i,depth/2),point(inner,i+1,depth/2),point(hole,i+1,depth/2-bevel),point(hole,i,depth/2-bevel));+ quad(point(hole,i,depth/2-bevel),point(hole,i+1,depth/2-bevel),point(hole,i+1,-depth/2),point(hole,i,-depth/2));}upload(this,data,{-radius,-radius,-depth/2},{radius,radius,depth/2+grooveHeight});}+TurntableDetailGeometry::TurntableDetailGeometry(QQuick3DObject *parent):QQuick3DGeometry(parent) {+ connect(this,&TurntableDetailGeometry::shapeChanged,this,&TurntableDetailGeometry::rebuild);rebuild();+}+void TurntableDetailGeometry::rebuild() {+ 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) {+ // One mesh for the machined diagonal ribs, with closed side walls.+ for(int i=0;i<34;++i) {+ const float x=i*7.f;+ const QVector3D a(x,-17,0),b(x+2.6f,-17,0),c(x+25.6f,17,0),d(x+23,17,0),z(0,0,1.2f);+ quad(a+z,b+z,c+z,d+z);quad(d,c,b,a);+ quad(a,b,b+z,a+z);quad(b,c,c+z,b+z);quad(c,d,d+z,c+z);quad(d,a,a+z,d+z);+ }+ upload(this,data,{0,-17,0},{257,17,1.2f});+ } else {+ // Nine bored holes continue through the aluminum headshell web.+ constexpr int segments=32;+ for(int row=0;row<3;++row)for(int col=0;col<3;++col) {+ const QVector3D center((col-1)*6.f,(row-1)*6.f,0);+ const auto point=[&](int i,bool outer,float z) {+ const float a=i*2*float(M_PI)/segments,c=std::cos(a),s=std::sin(a);+ const float r=outer?3.f/qMax(std::abs(c),std::abs(s)):1.8f;+ return center+QVector3D(r*c,r*s,z);+ };+ for(int i=0;i<segments;++i) {+ quad(point(i,false,1),point(i,true,1),point(i+1,true,1),point(i+1,false,1));+ quad(point(i,false,-1),point(i+1,false,-1),point(i+1,true,-1),point(i,true,-1));+ quad(point(i,false,1),point(i+1,false,1),point(i+1,false,-1),point(i,false,-1));+ if(col==0||col==2||row==0||row==2) {+ const auto a=point(i,true,0),b=point(i+1,true,0);+ if((std::abs(a.x())>8.99f&&std::abs(b.x())>8.99f)||(std::abs(a.y())>8.99f&&std::abs(b.y())>8.99f))+ quad(point(i,true,-1),point(i+1,true,-1),point(i+1,true,1),point(i,true,1));+ }+ }+ }+ upload(this,data,{-9,-9,-1},{9,9,1});+ }+}+ReelGeometry::ReelGeometry(QQuick3DObject *parent):QQuick3DGeometry(parent) {+ constexpr int segments=120;+ constexpr float inner=16.5f,outer=24,edge=31.7f,z=3;+ QByteArray data;+ const auto point=[](float radius,int i,float height) {+ const float angle=i*2*float(M_PI)/segments;+ return QVector3D(radius*std::cos(angle),radius*std::sin(angle),height);+ };+ const auto shaft=[](int i) {+ const float angle=i*2*float(M_PI)/segments;+ return 13.f-4.f*std::pow(qMax(0.f,std::cos(angle*6)),8.f);+ };+ const auto cutout=[](int i){return ((i+segments+6)%40)<12;};+ const auto quad=[&](QVector3D a,QVector3D b,QVector3D c,QVector3D d) {+ triangle(data,a,b,c,32);triangle(data,a,c,d,32);+ };+ // The openings continue through the web and have their own inner walls.+ // Both rotating reels share this mesh, including the six shaft teeth.+ for(int i=0;i<segments;++i) {+ const int j=i+1;+ const float starts[]={shaft(i),inner,outer},ends[]={shaft(j),inner,outer};+ const float outside[]={inner,outer,edge};+ for(int band=0;band<3;++band) {+ if(band==1&&cutout(i))continue;+ quad(point(starts[band],i,z),point(outside[band],i,z),point(outside[band],j,z),point(ends[band],j,z));+ quad(point(starts[band],i,-z),point(ends[band],j,-z),point(outside[band],j,-z),point(outside[band],i,-z));+ }+ quad(point(shaft(i),i,z),point(shaft(j),j,z),point(shaft(j),j,-z),point(shaft(i),i,-z));+ quad(point(edge,i,-z),point(edge,j,-z),point(32,j,-2.6),point(32,i,-2.6));+ quad(point(32,i,-2.6),point(32,j,-2.6),point(32,j,2.6),point(32,i,2.6));+ quad(point(32,i,2.6),point(32,j,2.6),point(edge,j,z),point(edge,i,z));+ if(!cutout(i))continue;+ quad(point(inner,i,-z),point(inner,j,-z),point(inner,j,z),point(inner,i,z));+ quad(point(outer,i,z),point(outer,j,z),point(outer,j,-z),point(outer,i,-z));+ if(!cutout(i-1))quad(point(inner,i,z),point(outer,i,z),point(outer,i,-z),point(inner,i,-z));+ if(!cutout(j))quad(point(inner,j,-z),point(outer,j,-z),point(outer,j,z),point(inner,j,z));+ }+ upload(this,data,{-32,-32,-z},{32,32,z});+}+CoverTexture::CoverTexture(QObject *parent):QObject(parent){connect(this,&CoverTexture::artworkChanged,this,&CoverTexture::rebuild);rebuild();}void CoverTexture::rebuild(){QImage image=m_artwork.isNull()?Disc::placeholderArt(512):m_artwork;@@ -86,13 +183,34 @@ StudioTexture::StudioTexture(QQuick3DObject *parent):QQuick3DTextureData(parent)connect(this,&StudioTexture::tintChanged,this,&StudioTexture::rebuild);rebuild();}void StudioTexture::rebuild() {- QImage image(512,256,QImage::Format_RGBA8888);image.fill(QColor("#303239"));- QPainter p(&image);- QLinearGradient gradient(0,0,0,256);gradient.setColorAt(0,QColor("#888c92"));gradient.setColorAt(.5,QColor("#454850"));gradient.setColorAt(1,QColor("#181a1e"));p.fillRect(image.rect(),gradient);- for(const QRect rect:{QRect(60,38,60,125),QRect(325,62,120,65)}) { QRadialGradient light(rect.center(),rect.width());light.setColorAt(0,QColor("#ffffff"));light.setColorAt(1,QColor(200,206,215,0));p.fillRect(rect,light); }- QColor tint=m_tint.isValid()?m_tint:QColor(Qt::white);- QColor bounce=QColor::fromHsvF(qMax(0.,tint.hsvHueF()),qMin(.55,tint.hsvSaturationF()*1.5),1,.35);p.fillRect(image.rect(),bounce);- p.end();setSize(image.size());setFormat(RGBA8);setHasTransparency(false);setTextureData(QByteArray(reinterpret_cast<const char*>(image.constBits()),image.sizeInBytes()));+ // 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;+ QByteArray pixels(width*height*4,Qt::Uninitialized);+ 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;+ 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;+ 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();+ int exponent=0;const double largest=qMax(r,qMax(g,b));+ const double scale=std::frexp(largest,&exponent)*256/largest;+ 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);}SurfaceTexture::SurfaceTexture(QQuick3DObject *parent):QQuick3DTextureData(parent) {@@ -101,14 +219,36 @@ SurfaceTexture::SurfaceTexture(QQuick3DObject *parent):QQuick3DTextureData(parenvoid SurfaceTexture::rebuild() {// Small deterministic material maps, generated once per material rather// than every frame. Geometry supplies the silhouette and physical grooves.- QImage image(256,256,QImage::Format_RGBA8888);+ const int size=(m_kind=="vinyl-normal"||m_kind=="lacquer")?1024:m_kind=="powder"?512:256;+ QImage image(size,size,QImage::Format_RGBA8888);const auto noise=[](unsigned x,unsigned y){unsigned n=x*374761393u+y*668265263u;n=(n^(n>>13))*1274126177u;return int((n^(n>>16))&255);};- for(int y=0;y<256;++y)for(int x=0;x<256;++x) {+ for(int y=0;y<size;++y)for(int x=0;x<size;++x) {QColor color;- if(m_kind=="disc") {+ if(m_kind=="vinyl-normal") {+ 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") {+ 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;+ color=QColor(value,value,value);+ } else if(m_kind=="powder") {+ const int value=205+noise(x,y)/12+noise(x/8,y/8)/32;+ color=QColor(value,value,value);+ } else if(m_kind=="disc") {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") {+ 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") {const float slope=(noise(0,(y+1)%256)-noise(0,(y+255)%256))/1024.f;const auto n=QVector3D(0,slope,1).normalized();@@ -116,8 +256,9 @@ void SurfaceTexture::rebuild() {} else {int value=0;if(m_kind=="brushed")value=205+noise(0,y)/12+noise(x,y)/64;- else if(m_kind=="turned")value=175+noise(0,y)/5+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;else value=222+noise(x,y)/32;color=QColor(value,value,value);}diff --git a/src/mediageometry.h b/src/mediageometry.hindex 4db6a9c..f4be588 100644--- a/src/mediageometry.h+++ b/src/mediageometry.h@@ -18,6 +18,24 @@ private:float m_radius=176,m_hole=3,m_depth=2;bool m_grooves=false;};+class ReelGeometry : public QQuick3DGeometry {+ Q_OBJECT+public:+ explicit ReelGeometry(QQuick3DObject *parent=nullptr);+};++class TurntableDetailGeometry : public QQuick3DGeometry {+ Q_OBJECT+ Q_PROPERTY(bool fascia MEMBER m_fascia NOTIFY shapeChanged)+public:+ explicit TurntableDetailGeometry(QQuick3DObject *parent=nullptr);+signals:+ void shapeChanged();+private:+ void rebuild();+ bool m_fascia=false;+};+class CoverTexture : public QObject {Q_OBJECTQ_PROPERTY(QQuick3DTextureData *texture READ texture NOTIFY textureChanged)diff --git a/src/mediauitest.cpp b/src/mediauitest.cppindex e08c4dd..69d68f3 100644--- a/src/mediauitest.cpp+++ b/src/mediauitest.cpp@@ -59,8 +59,8 @@ int exerciseMediaUi(Player &player, QQuickWindow *window, const QString &temp, cQTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,point);check(!previewArm->property("landing").toBool(),"new seek preview supersedes a pending needle landing");const double trackFraction=horizontal->property("previewValue").toDouble();- check(std::abs(window->property("recordVisualProgress").toDouble()-trackFraction/3)<.01,"horizontal preview maps the current song into the album timeline");- check(std::abs(previewArm->property("armAngle").toDouble()-(6+20*trackFraction/3))<.3,"paused album tonearm follows the horizontal preview immediately");+ check(std::abs(window->property("recordVisualProgress").toDouble()-trackFraction)<.01,"horizontal preview matches the whole album timeline");+ check(std::abs(previewArm->property("armAngle").toDouble()-(6+20*trackFraction))<.3,"paused album tonearm follows the horizontal preview immediately");QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,point);const auto ringStart=albumRim->mapToScene(QPointF(436,220)).toPoint(),ringEnd=albumRim->mapToScene(QPointF(220,436)).toPoint();QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,ringStart);diff --git a/src/player.cpp b/src/player.cppindex a93f579..5cf6489 100644--- a/src/player.cpp+++ b/src/player.cpp@@ -40,7 +40,7 @@ Player::Player(const QString &settingsPath, QObject *parent)m_repeat = qBound(0, m_settings.value("repeat", 0).toInt(), 2);m_light = m_settings.value("light", false).toBool();m_medium=m_settings.value("medium",m_settings.value("vinyl",false).toBool()?"vinyl":"cd").toString();- if(!QStringList{"cd","vinyl","cassette"}.contains(m_medium))m_medium="cd";+ if(!QStringList{"cd","vinyl","cassette","tp7"}.contains(m_medium))m_medium="cd";m_threeD=m_settings.value("threeD",false).toBool();m_cd500Rpm=m_settings.value("cd500Rpm",false).toBool();m_vinylSpeed=m_settings.value("vinylSpeed",33).toInt();@@ -473,7 +473,7 @@ void Player::setMiniMode(bool value) { if (m_miniMode == value) return; m_miniMovoid Player::setBackgroundBlur(bool value) { if (m_backgroundBlur == value) return; m_backgroundBlur = value; emit backgroundBlurChanged(); save(); }void Player::setVinyl(bool value) { setMedium(value?"vinyl":"cd"); }void Player::setMedium(const QString &value) {- if(m_medium==value || !QStringList{"cd","vinyl","cassette"}.contains(value))return;+ if(m_medium==value || !QStringList{"cd","vinyl","cassette","tp7"}.contains(value))return;const bool wasVinyl=vinyl();m_medium=value;emit mediumChanged();if(wasVinyl!=vinyl())emit vinylChanged();save();}void Player::setShowPlayerBody(bool value) { if(value==m_showPlayerBody)return;m_showPlayerBody=value;emit settingsChanged();save(); }diff --git a/src/recorder.cpp b/src/recorder.cppnew file mode 100644index 0000000..363b3f5--- /dev/null+++ b/src/recorder.cpp@@ -0,0 +1,71 @@+#include "recorder.h"+#include <QPainter>+#include <QPainterPath>+#include <QLinearGradient>+#include <QConicalGradient>+#include <QRandomGenerator>+#include <cmath>++void RecorderSurface::paint(QPainter *p) {+ p->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);+ p->scale(width()/410.,height()/410.);+ const QPointF center(205,160);+ const auto metal=[&](QRectF rect,double radius){+ p->setPen(Qt::NoPen);p->setBrush(QColor("#747a80"));p->drawRoundedRect(rect.translated(0,.8),radius,radius);+ QLinearGradient bevel(rect.topLeft(),rect.bottomRight());+ bevel.setColorAt(0,QColor("#fafbfc"));bevel.setColorAt(.25,QColor("#ccd0d3"));bevel.setColorAt(.72,QColor("#747b81"));bevel.setColorAt(1,QColor("#e2e5e7"));+ p->setBrush(bevel);p->drawRoundedRect(rect,radius,radius);+ QLinearGradient face(rect.topLeft(),rect.bottomRight());face.setColorAt(0,QColor("#d5d8db"));face.setColorAt(.42,QColor("#c9cccf"));face.setColorAt(1,QColor("#b7bcc1"));+ p->setBrush(face);p->drawRoundedRect(rect.adjusted(1,1,-1,-1.3),qMax(0.,radius-1),qMax(0.,radius-1));+ };+ const auto grain=[&](const QPainterPath &clip,unsigned seed,int count){+ p->save();p->setClipPath(clip);QRandomGenerator random(seed);const auto bounds=clip.boundingRect();+ for(int i=0;i<count;++i){const int v=random.bounded(2)?255:65;p->setPen(QColor(v,v,v,random.bounded(3,12)));p->drawPoint(QPointF(bounds.left()+random.generateDouble()*bounds.width(),bounds.top()+random.generateDouble()*bounds.height()));}p->restore();+ };+ if(m_part==1) {+ QConicalGradient g(center,40);g.setColorAt(0,QColor("#c7ccd0"));g.setColorAt(.22,QColor("#dadee1"));g.setColorAt(.49,QColor("#c2c7cc"));g.setColorAt(.75,QColor("#d4d8dc"));g.setColorAt(1,QColor("#c7ccd0"));+ p->setPen(QPen(QColor("#edf0f2"),.7));p->setBrush(g);p->drawEllipse(center,113,113);+ QPainterPath path;path.addEllipse(center,112,112);grain(path,721,7000);+ p->setPen(QPen(QColor(64,73,80,75),.35));p->drawLine(QPointF(205,49),QPointF(205,123));p->drawLine(QPointF(205,197),QPointF(205,271));+ p->setPen(QPen(QColor("#eef1f3"),.6));p->setBrush(QColor("#252b31"));p->drawEllipse(center,31,31);+ p->setPen(QPen(QColor("#9eabb4"),.45));p->setBrush(Qt::NoBrush);p->drawEllipse(center,30.25,30.25);+ if(!m_artwork.isNull()) {+ p->save();QPainterPath art;art.addEllipse(center,26,26);p->setClipPath(art);p->drawImage(QRectF(179,134,52,52),m_artwork);p->restore();+ }+ for(int i=0;i<3;++i){const double a=i*2*std::acos(-1.)/3;const QPointF at=center+QPointF(28.5*std::sin(a),-28.5*std::cos(a));p->setPen(QPen(QColor("#e0e4e8"),.5));p->setBrush(QColor("#5c636a"));p->drawEllipse(at,1.15,1.15);p->setPen(QPen(QColor("#252c32"),.4));p->drawLine(at+QPointF(-.5,.5),at+QPointF(.5,-.5));}+ return;+ }+ if(m_part==2) {+ p->setPen(QColor("#41484f"));QFont font("sans-serif");font.setPixelSize(17);font.setWeight(QFont::Light);p->setFont(font);p->drawText(QRectF(100,32,80,25),Qt::AlignLeft|Qt::AlignVCenter,"TP-7");+ p->setPen(Qt::NoPen);p->setBrush(QColor("#e97626"));p->drawRoundedRect(QRectF(315,82,6,6),.4,.4);+ p->setBrush(QColor("#515b62"));p->drawEllipse(QPointF(169,44),1.15,1.15);p->setBrush(QColor("#9fa5ab"));p->drawEllipse(QPointF(206,44),1.15,1.15);+ return;+ }+ if(m_part==3) {+ metal(QRectF(65,69,10,186),4);metal(QRectF(65,154,18,17),8);+ p->setPen(QPen(QColor("#edf1f3"),.6));p->setBrush(QColor("#78828b"));p->drawEllipse(QPointF(72,162.5),3.3,3.3);+ p->setPen(QPen(QColor("#323a42"),.55));p->drawLine(QPointF(70.6,163.8),QPointF(73.4,161.1));+ return;+ }+ for(int i=8;i>0;--i){p->setPen(Qt::NoPen);p->setBrush(QColor(0,0,0,4));p->drawRoundedRect(QRectF(85-i/2.,24-i/3.,244+i,352+i),12,12);}+ p->setBrush(QColor("#da7024"));p->drawRoundedRect(QRectF(86.5,22,244,352),11,11);+ metal(QRectF(85,20,244,352),12);+ QPainterPath path;path.addRoundedRect(QRectF(87,22,240,347),10,10);grain(path,7201,13000);+ p->setPen(QPen(QColor("#828b93"),.6));p->setBrush(QColor("#313940"));p->drawEllipse(center,114.5,114.5);+ p->setPen(QPen(QColor("#eff3f5"),.6));p->setBrush(QColor("#0a1117"));p->drawRoundedRect(QRectF(267,30,52,29),4,4);+ metal(QRectF(112,0,8,21),1.5);+ p->setPen(Qt::NoPen);p->setBrush(QColor("#a0a8ae"));p->drawEllipse(QPointF(115,263),9,9);+ p->setBrush(QColor("#20262b"));p->drawRoundedRect(QRectF(85,286,187,86),1.8,1.8);+ p->save();p->translate(298,255.5);p->rotate(46.3);+ p->setPen(QPen(QColor("#eef1f3"),.6));p->setBrush(QColor("#aeb6bc"));p->drawRoundedRect(QRectF(-12.5,-27.5,25,55),12.5,12.5);p->restore();+ // The adapter has a cylindrical silhouette, a diamond knurl and a retaining collar.+ metal(QRectF(279,369,31,6),1.5);metal(QRectF(277,375,35,29),3.5);+ QLinearGradient cylinder(277,0,312,0);cylinder.setColorAt(0,QColor("#7d858c"));cylinder.setColorAt(.25,QColor("#e0e5e8"));cylinder.setColorAt(.7,QColor("#a6b0b7"));cylinder.setColorAt(1,QColor("#626e77"));+ p->setPen(Qt::NoPen);p->setBrush(cylinder);p->drawRoundedRect(QRectF(277.5,375.5,34,28),3,3);+ p->save();p->setClipRect(QRectF(278.5,377,32,24));+ for(double x=251;x<340;x+=4.6){p->setPen(QPen(QColor("#73818c"),.65));p->drawLine(QPointF(x,377),QPointF(x+24,401));p->setPen(QPen(QColor("#e7ecef"),.65));p->drawLine(QPointF(x,377),QPointF(x-24,401));}p->restore();+ p->setPen(QPen(QColor("#ecf0f2"),.65));p->drawLine(QPointF(280,376.5),QPointF(309,376.5));+ p->setPen(QPen(QColor("#67757f"),.65));p->drawLine(QPointF(280,402.2),QPointF(309,402.2));+ for(int x:{294,308}){p->setPen(Qt::NoPen);p->setBrush(QColor("#646c73"));p->drawRoundedRect(QRectF(x,290,1.6,69),.8,.8);p->setPen(QPen(QColor("#e7ecef"),.5));p->drawLine(QPointF(x+1.9,291),QPointF(x+1.9,358));}+ p->setPen(QPen(QColor("#79828a"),.4));p->drawLine(QPointF(283,314),QPointF(319,314));+}diff --git a/src/recorder.h b/src/recorder.hnew file mode 100644index 0000000..b0bc138--- /dev/null+++ b/src/recorder.h@@ -0,0 +1,20 @@+#pragma once+#include <QQuickPaintedItem>+#include <QImage>++// Static machined surfaces; transport motion stays on the scene graph transform.+class RecorderSurface : public QQuickPaintedItem {+ Q_OBJECT+ Q_PROPERTY(int part MEMBER m_part NOTIFY changed)+ Q_PROPERTY(QImage artwork MEMBER m_artwork NOTIFY changed)+public:+ explicit RecorderSurface(QQuickItem *parent=nullptr):QQuickPaintedItem(parent) {+ setAntialiasing(true); connect(this,&RecorderSurface::changed,this,[this]{update();});+ }+ void paint(QPainter *painter) override;+signals:+ void changed();+private:+ int m_part=0;+ QImage m_artwork;+};diff --git a/src/recordertest.cpp b/src/recordertest.cppnew file mode 100644index 0000000..a86aa82--- /dev/null+++ b/src/recordertest.cpp@@ -0,0 +1,205 @@+#include "recordertest.h"+#include "player.h"+#include "cider.h"+#include "disc.h"+#include <QQmlContext>+#include <QQuickWindow>+#include <QQuickItem>+#include <QQuickItemGrabResult>+#include <QTest>+#include <QDir>+#include <QFile>+#include <QPointer>+#include <functional>+#include <iostream>+#include <cmath>++// Same public playback contract as Cider. No requests reach a desktop account.+class RecorderRemote : public Cider {+ Q_OBJECT+ Q_PROPERTY(int count READ fixtureCount NOTIFY trackChanged)+ Q_PROPERTY(bool canSeek READ yes NOTIFY trackChanged)+ Q_PROPERTY(bool canPrevious READ yes NOTIFY trackChanged)+ Q_PROPERTY(bool canNext READ yes NOTIFY trackChanged)+ Q_PROPERTY(bool playing MEMBER running NOTIFY playingChanged)+ Q_PROPERTY(qint64 position MEMBER at NOTIFY positionChanged)+ Q_PROPERTY(qint64 duration READ length NOTIFY trackChanged)+ Q_PROPERTY(double volume MEMBER level NOTIFY volumeChanged)+ Q_PROPERTY(QString trackKey READ identity NOTIFY trackChanged)+public:+ RecorderRemote():Cider(false){}+ bool yes() const { return true; }+ int fixtureCount() const { return 3; }+ qint64 length() const { return 32000; }+ QString identity() const { return QString::number(index); }+ Q_INVOKABLE void toggle() { running=!running;emit playingChanged(); }+ Q_INVOKABLE void next() { ++index;at=0;emit trackChanged();emit positionChanged(); }+ Q_INVOKABLE void previous() { --index;at=0;emit trackChanged();emit positionChanged(); }+ Q_INVOKABLE void seek(qint64 value) { at=qBound<qint64>(0,value,length());emit positionChanged(); }+ bool running=false;+ qint64 at=0;+ double level=.5;+ int index=0;+};++int exerciseRecorder(Player &player,QQuickWindow *window,const QString &temp,const QString &captures) {+ int checks=0,failures=0;QString context;+ const bool pressureOnly=qEnvironmentVariableIsSet("SPUN_TEST_PRESSURE_ONLY");+ 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()<3500)QTest::qWait(20);return f();};+ std::function<QQuickItem*(QQuickItem*,const QString&)> find=[&](QQuickItem *parent,const QString &name)->QQuickItem*{if(parent->objectName()==name)return parent;for(auto *child:parent->childItems())if(auto *p=find(child,name))return p;return nullptr;};+ const auto item=[&](const QString &name){return find(window->contentItem(),name);};+ const auto invoke=[&](const char *name){QMetaObject::invokeMethod(window,name);QTest::qWait(100);};+ auto *typography=qmlContext(window)->contextProperty("typography").value<QObject*>();+ const auto point=[&](QQuickItem *control,QPointF p){+ if(!control)return QPoint(-999,-999);+ if(!window->property("threeDActive").toBool())return control->mapToScene(p).toPoint();+ auto *surface=item("mediaSurface"),*view=item("player3DView");if(!surface||!view)return QPoint(-999,-999);+ const auto local=control->mapToItem(surface,p);QVariant result;+ if(control->objectName()=="recorderVolumeKnob")QMetaObject::invokeMethod(view,"projectSurfaceDepth",Q_RETURN_ARG(QVariant,result),Q_ARG(QVariant,local.x()),Q_ARG(QVariant,local.y()),Q_ARG(QVariant,-9.));+ else QMetaObject::invokeMethod(view,"projectSurface",Q_RETURN_ARG(QVariant,result),Q_ARG(QVariant,local.x()),Q_ARG(QVariant,local.y()));+ return view->mapToScene(result.toPointF()).toPoint();+ };+ 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");}};+ 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;+ player.select(0,false);player.setMedium("tp7");+ {Player restored(temp+"/player.ini");check(restored.medium()=="tp7","appearance persists across relaunch");}+ RecorderRemote 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)continue;+ player.setThreeD(threeD);check(until([&]{return window->property("threeDActive").toBool()==threeD;}),"requested renderer loads");+ if(!pressureOnly)for(bool cider:{false,true})for(double scale:{.85,1.,1.5}) {+ context=QString("TP-7 %1 %2 %3").arg(threeD?"3D":"2D",cider?"Cider":"Local").arg(scale);+ window->setProperty("useCider",cider);typography->setProperty("uiScale",scale);QTest::qWait(160);+ player.pause();player.select(0,false);remote.running=false;remote.index=0;remote.seek(0);emit remote.playingChanged();+ auto position=[&]{return cider?remote.at:player.position();};auto duration=[&]{return cider?remote.length():player.duration();};+ auto seek=[&](qint64 at){if(cider)remote.seek(at);else player.seek(at);QTest::qWait(35);};+ click("recorderPlay");check(until([&]{return cider?remote.running:player.playing();}),"hardware play starts playback");+ click("recorderPlay");check(!(cider?remote.running:player.playing()),"hardware pause stops playback");+ auto *playButton=item("recorderPlay");+ const QPoint playCenter=point(playButton,QPointF(playButton->width()/2,playButton->height()/2));+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,playCenter);+ check(!(cider?remote.running:player.playing()),"press waits for release before activating");+ check(std::abs(playButton->property("pressDepth").toDouble()-1.)<.001,"reduced motion applies the pressed state immediately");+ move(point(playButton,QPointF(-40,playButton->height()/2)));+ QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,point(playButton,QPointF(-40,playButton->height()/2)));+ check(!(cider?remote.running:player.playing())&&!playButton->property("held").toBool(),"dragging off a key cancels its action and pressed state");+ check(std::abs(playButton->property("pressDepth").toDouble())<.001,"reduced motion clears pressure without a spring");+ playButton->forceActiveFocus();QTest::keyClick(window,Qt::Key_Return);+ check(until([&]{return cider?remote.running:player.playing();}),"Enter activates the focused transport key");+ QTest::keyClick(window,Qt::Key_Space);QTest::qWait(60);+ check(!(cider?remote.running:player.playing()),"Space toggles playback once");+ click("recorderNext");check(until([&]{return (cider?remote.index:player.currentIndex())==1;}),"hardware next changes track");+ player.pause();seek(0);click("recorderPrevious");check(until([&]{return (cider?remote.index:player.currentIndex())==0;}),"hardware previous changes track");player.pause();+ const double volume=cider?remote.level:player.volume();click("recorderLouder");check(std::abs((cider?remote.level:player.volume())-qMin(1.,volume+.05))<.001,"plus raises volume");click("recorderQuieter");check(std::abs((cider?remote.level:player.volume())-volume)<.001,"minus lowers volume");+ if(cider){remote.level=1.;emit remote.volumeChanged();}else player.setVolume(1.);+ click("recorderLouder");check((cider?remote.level:player.volume())==1.,"volume cannot exceed its maximum");+ if(cider){remote.level=0.;emit remote.volumeChanged();}else player.setVolume(0.);+ click("recorderQuieter");check((cider?remote.level:player.volume())==0.,"volume cannot fall below zero");+ seek(0);click("recorderForward");check(until([&]{return std::abs(position()-10000)<600;}),"rocker seeks forward ten seconds");click("recorderRewind");check(until([&]{return position()<600;}),"rocker seeks back ten seconds");+ auto *wheel=item("recorderWheel");if(!check(wheel!=nullptr,"wheel control exists"))continue;+ const auto quarter=point(wheel,QPointF(232,122)),threeQuarter=point(wheel,QPointF(12,122));+ QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,quarter);check(until([&]{return std::abs(position()-duration()*.25)<600;}),"wheel click seeks to a quarter");+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,quarter);+ for(int step=1;step<=16;++step){const double a=(.5+step/16.)*std::acos(-1.);move(point(wheel,QPointF(122+110*std::sin(a),122-110*std::cos(a))));}+ check(std::abs(window->property("trackVisualProgress").toDouble()-.75)<.025,"wheel and progress share the drag preview");+ QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,threeQuarter);check(until([&]{return std::abs(position()-duration()*.75)<700;}),"wheel drag commits three quarters");+ check(!window->property("threeDGesture").toBool(),"release clears the gesture");+ seek(duration()/2);QTest::mousePress(window,Qt::LeftButton,Qt::ShiftModifier,quarter);move(point(wheel,QPointF(122,232)),Qt::ShiftModifier);QTest::mouseRelease(window,Qt::LeftButton,Qt::ShiftModifier,point(wheel,QPointF(122,232)));+ check(until([&]{return std::abs(position()-duration()*.525)<700;}),"Shift provides precision seeking");+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,quarter);invoke("cancel3DPointer");invoke("cancelSeekPreview");QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,quarter);check(!window->property("seekPreviewActive").toBool(),"cancelling clears the shared preview");+ auto *knob=item("recorderVolumeKnob");const double before=cider?remote.level:player.volume();+ const QPoint bottom=point(knob,QPointF(18,18)),top=point(knob,QPointF(18,-12));QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,bottom);move(top);QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,top);+ check((cider?remote.level:player.volume())>before+.12,"knob drag raises volume");+ if(cider){remote.level=.5;emit remote.volumeChanged();}else player.setVolume(0);+ player.setHorizontalSeek(true);QTest::qWait(60);auto *horizontal=item("horizontalSeek");+ if(check(horizontal&&horizontal->isVisible(),"horizontal seek remains available")){+ const auto h=horizontal->mapToScene(QPointF(horizontal->width()*.4,18)).toPoint();QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,h);+ check(window->property("activeSeekControl").value<QObject*>()!=nullptr&&std::abs(item("recorderProgress")->property("progress").toDouble()-window->property("trackVisualProgress").toDouble())<.0001,"horizontal drag updates the recorder progress");QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,h);+ }+ player.setHorizontalSeek(false);+ }+ typography->setProperty("uiScale",1.);window->setProperty("useCider",false);player.pause();QTest::qWait(100);capture(threeD?"tp7-3d":"tp7-2d");+ if(threeD&&!pressureOnly) {+ auto *view=item("player3DView");+ const auto bodyPoint=[&]{QVariant p;QMetaObject::invokeMethod(view,"projectSurface",Q_RETURN_ARG(QVariant,p),Q_ARG(QVariant,200.),Q_ARG(QVariant,130.));return view->mapToScene(p.toPointF()).toPoint();};+ const QPoint start=bodyPoint();QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,start);move(start+QPoint(185,65));+ check(view->property("orbiting").toBool()&&std::abs(view->property("recorderYaw").toDouble())>80&&std::abs(view->property("recorderPitch").toDouble())>20,"body drag rotates horizontally and vertically");+ QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,start+QPoint(185,65));+ check(!window->property("discFlipped").toBool(),"physical rotation does not open the F reverse view");+ view->setProperty("recorderYaw",180.);view->setProperty("recorderPitch",0.);QTest::qWait(150);capture("tp7-3d-back");+ auto *playKey=item("recorderPlay");const auto hidden=point(playKey,QPointF(playKey->width()/2,playKey->height()/2));+ QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,hidden);check(!player.playing(),"front buttons cannot activate through the back");+ QMetaObject::invokeMethod(view,"resetRecorderOrientation");QTest::qWait(100);click("recorderPlay");check(until([&]{return player.playing();}),"front controls work after returning from rotation");player.pause();+ }+ if(threeD) {+ auto *view=item("player3DView");+ for(const auto &angle:QList<QPair<double,double>>{{0.,-45.},{38.,42.}}) {+ view->setProperty("recorderYaw",angle.first);view->setProperty("recorderPitch",angle.second);QTest::qWait(120);+ click("recorderPlay");check(until([&]{return player.playing();}),"transport remains actionable at an inspection angle");player.pause();+ capture(angle.second<0?"tp7-3d-key-mechanism":"tp7-3d-top-detail");+ }+ QMetaObject::invokeMethod(view,"resetRecorderOrientation");+ }+ if(!pressureOnly)for(bool cider:{false,true}) {+ window->setProperty("useCider",cider);QTest::qWait(80);+ // Side controls use their actual physical depth, not the front plane.+ const auto sideClick=[&](const char *name,int index){+ if(!threeD){click(name);return;}+ auto *view=item("player3DView");view->setProperty("recorderYaw",-75.);QTest::qWait(120);QVariant result;+ QMetaObject::invokeMethod(view,"projectRecorderControl",Q_RETURN_ARG(QVariant,result),Q_ARG(QVariant,index));+ QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,view->mapToScene(result.toPointF()).toPoint());QTest::qWait(100);+ };+ sideClick("recorderQueue",9);check(window->property("queueOpen").toBool(),"side key opens the queue");window->setProperty("queueOpen",false);QTest::qWait(100);+ sideClick("recorderSettings",10);check(window->property("menuOpen").toBool(),"side key opens settings");QTest::keyClick(window,Qt::Key_Escape);QTest::qWait(160);+ sideClick("recorderDetails",8);check(window->property("discFlipped").toBool(),"side key opens album details");if(window->property("discFlipped").toBool())invoke("flipDisc");+ if(threeD){auto *view=item("player3DView");if(view)QMetaObject::invokeMethod(view,"resetRecorderOrientation");}+ }+ window->setProperty("useCider",false);+ player.setMotion(true);player.pause();+ context=threeD?"TP-7 3D pressure":"TP-7 2D pressure";+ for(const auto &entry:QList<QPair<QString,int>>{{"recorderPlay",1},{"recorderQuieter",3},{"recorderForward",6},{"recorderQueue",9}}) {+ 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);+ 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.+ until([&]{return key->property("pressDepth").toDouble()>.9;});+ 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");+ 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");+ }+ player.setMotion(false);+ if(threeD)QMetaObject::invokeMethod(item("player3DView"),"resetRecorderOrientation");+ if(pressureOnly)continue;+ invoke("flipDisc");check(window->property("discFlipped").toBool()&&!window->property("threeDActive").toBool(),"reverse opens album details");capture(threeD?"tp7-3d-reverse":"tp7-2d-reverse");invoke("flipDisc");+ player.setMiniMode(true);QTest::qWait(150);check(!window->property("threeDActive").toBool()&&item("recorderFace"),"Mini uses the compact recorder");click("recorderPlay");check(until([&]{return player.playing();}),"Mini hardware controls remain actionable");player.pause();capture(threeD?"tp7-mini-from3d":"tp7-mini");player.setMiniMode(false);QTest::qWait(160);+ for(const QString &medium:QStringList{"cd","vinyl","cassette","tp7"}){player.setMedium(medium);QTest::qWait(60);check(player.medium()==medium,"all appearances can be selected");}+ player.setMotion(true);player.play();QTest::qWait(120);const double angle=window->property("spinAngle").toDouble();check(until([&]{return window->property("spinAngle").toDouble()!=angle;}),"wheel rotates during playback");player.setMotion(false);const double still=window->property("spinAngle").toDouble();QTest::qWait(100);check(window->property("spinAngle").toDouble()==still,"reduced motion freezes the wheel");player.pause();+ }+ player.clear();player.setMedium("tp7");+ for(bool threeD:{false,true}) {+ if(threeD&&!supports)continue;+ player.setThreeD(threeD);QTest::qWait(150);context=threeD?"TP-7 3D empty library":"TP-7 2D empty library";+ for(const char *name:{"recorderPlay","recorderPrevious","recorderNext","recorderForward","recorderRewind","recorderDetails"})+ check(item(name)&&!item(name)->isEnabled(),qPrintable(QString(name)+" is disabled without a track"));+ player.setVolume(.5);click("recorderLouder");check(std::abs(player.volume()-.55)<.001,"volume stays available without a track");+ if(threeD){auto *view=item("player3DView");view->setProperty("recorderYaw",-75.);QTest::qWait(100);QVariant p;QMetaObject::invokeMethod(view,"projectRecorderControl",Q_RETURN_ARG(QVariant,p),Q_ARG(QVariant,10));QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,view->mapToScene(p.toPointF()).toPoint());}+ else click("recorderSettings");+ check(until([&]{return window->property("menuOpen").toBool();}),"player menu stays available without a track");QTest::keyClick(window,Qt::Key_Escape);QTest::qWait(100);+ }+ window->setProperty("useCider",false);window->setProperty("ciderService",original);player.setThreeD(false);player.setMedium("cd");+ std::cout<<"RECORDER RESULT "<<checks<<" checks, "<<failures<<" failures"<<std::endl;return failures?1:0;+}+#include "recordertest.moc"diff --git a/src/recordertest.h b/src/recordertest.hnew file mode 100644index 0000000..b9198df--- /dev/null+++ b/src/recordertest.h@@ -0,0 +1,5 @@+#pragma once+#include <QString>+class Player;+class QQuickWindow;+int exerciseRecorder(Player &player,QQuickWindow *window,const QString &temp,const QString &captures);diff --git a/src/threedtest.cpp b/src/threedtest.cppindex 875b2b5..cb6eceb 100644--- a/src/threedtest.cpp+++ b/src/threedtest.cpp@@ -13,6 +13,7 @@#include <QFile>#include <QSaveFile>#include <QWheelEvent>+#include <QVector2D>#ifdef SPUN_WITH_3D#include <QQuick3DGeometry>#endif@@ -134,7 +135,7 @@ int exerciseThreeD(Player &player,QQuickWindow *window,const QString &temp,constplayer.setVinylAlbumMode(album);player.select(0,false);player.seek(0);QTest::qWait(180);auto *arm=item("vinylTonearm");auto *needle=item("needleHandle");if(!check(arm&&needle,"tonearm exists"))continue;- const auto from=project(arm,needle->property("tip").toPointF());const double angle=16*std::acos(-1.)/180.;const auto to=project(arm,QPointF(378-197*std::sin(angle),100+197*std::cos(angle)));+ const auto from=project(arm,needle->property("tip").toPointF());const double angle=(arm->property("startAngle").toDouble()+arm->property("angleRange").toDouble()*.5)*std::acos(-1.)/180.;const auto to=project(arm,QPointF(arm->property("pivotX").toDouble()-arm->property("armLength").toDouble()*std::sin(angle),arm->property("pivotY").toDouble()+arm->property("armLength").toDouble()*std::cos(angle)));auto *bands=window->findChild<QObject*>("threeDTrackBands");check(bands&&bands->property("count").toInt()==(album?2:0),"album track boundaries appear only in record mode");drag(from,to);check(until([&]{return player.playing()&&player.currentIndex()==(album?1:0)&&std::abs(player.position()-16000)<1800;}),"needle maps song or album position correctly");player.pause();@@ -229,7 +230,7 @@ int exerciseThreeDLighting(Player &player,QQuickWindow *window,const QString &teplayer.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"}) {+ for(const auto &medium:QStringList{"cd","vinyl","cassette","tp7"}) {player.setMedium(medium);QTest::qWait(200);double coolBalance=0;for(const auto &accent:QStringList{"#82bed5","#e4a17f","#d9bafa","#916ba8"}) {auto css=original;css.replace("#e6b599",accent.toUtf8());@@ -243,9 +244,9 @@ int exerciseThreeDLighting(Player &player,QQuickWindow *window,const QString &teauto *view=findItem(window->contentItem(),"player3DView");QVariant projected;// Sample the physical medium, away from artwork labels, controls,// accent-colored progress indicators and the tonearm.- const QPointF surfacePoint=medium=="cassette"?QPointF(320,369):QPointF(150,349);+ const QPointF surfacePoint=medium=="cassette"?QPointF(320,369):medium=="tp7"?QPointF(240,325):QPointF(150,349);if(!view)return 2;- if(lightPalette)check(view->property("caseTint").value<QColor>().lightnessF()>.75,"light Noctalia palette updates the physical enclosure material");+ 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(!check(!frame.isNull(),"lighting test captures rendered pixels"))return 2;@@ -259,6 +260,43 @@ int exerciseThreeDLighting(Player &player,QQuickWindow *window,const QString &teif(accent=="#e4a17f")check(balance-coolBalance>8,"changing cool to warm visibly changes the material pixels");if(!captures.isEmpty()){QDir().mkpath(captures);frame.save(captures+"/"+medium+"-"+accent.mid(1)+".png");}}+ if(medium=="cassette") {+ for(double fraction:{0.,.5,1.}) {+ player.seek(qRound64(player.duration()*fraction));QTest::qWait(80);+ for(int side:{0,1}) {+ auto *feed=window->findChild<QObject*>(QString("threeDTapeFeed%1").arg(side));+ if(!check(feed!=nullptr,"cassette tape has a physical feed span"))continue;+ const auto start=feed->property("start").value<QVector2D>(),end=feed->property("end").value<QVector2D>();+ const auto radial=start-QVector2D(side?78.6f:-78.6f,13);+ const auto direction=(end-start).normalized();+ const auto guide=end-QVector2D(side?143.f:-143.f,-48);+ check(radial.length()>33&&radial.length()<60&&std::abs(QVector2D::dotProduct(radial,direction))<.02,+ "tape leaves the changing pack tangentially without crossing the reel");+ check(std::abs(guide.length()-10)<.01&&std::abs(QVector2D::dotProduct(guide,direction))<.02,+ "tape meets the guide roller at its surface");+ }+ }+ 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");+ if(!captures.isEmpty())frame.save(captures+"/cassette-"+finish+".png");+ }+ }+ if(medium=="cd"||medium=="cassette") {+ for(double fraction:{0.,.5,1.}) {+ window->setProperty("lidOpen",fraction);QTest::qWait(150);+ auto *view=findItem(window->contentItem(),"player3DView");QVariant projected;+ if(!view)return 2;+ QMetaObject::invokeMethod(view,"lidBounds",Q_RETURN_ARG(QVariant,projected));+ 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");+ if(!captures.isEmpty())frame.save(captures+"/"+medium+QString("-lid-%1.png").arg(fraction*100));+ }+ window->setProperty("lidOpen",0);+ }}player.setMedium("vinyl");player.setHorizontalSeek(true);player.pause();player.seek(4000);QTest::qWait(180);auto *bar=findItem(window->contentItem(),"horizontalSeek");@@ -270,7 +308,7 @@ int exerciseThreeDLighting(Player &player,QQuickWindow *window,const QString &tereturn std::abs(window->property("recordVisualProgress").toDouble()-fraction)<.015&& std::abs(view->property("progress").toDouble()-fraction)<.015&& std::abs(bar->property("value").toDouble()-fraction)<.015- && std::abs(arm->property("armAngle").toDouble()-(6+20*fraction))<.35;+ && std::abs(arm->property("armAngle").toDouble()-(arm->property("startAngle").toDouble()+arm->property("angleRange").toDouble()*fraction))<.35;};const QPoint start=bar->mapToScene(QPointF(bar->width()*.25,bar->height()/2)).toPoint();QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,start);diff --git a/src/turntabletest.cpp b/src/turntabletest.cppnew file mode 100644index 0000000..69e6ab9--- /dev/null+++ b/src/turntabletest.cpp@@ -0,0 +1,184 @@+#include "turntabletest.h"+#include "player.h"+#include "cider.h"+#include "listening.h"+#include "disc.h"+#include <QQmlContext>+#include <QQuickItem>+#include <QQuickWindow>+#include <QTest>+#include <QDir>+#include <QFile>+#include <functional>+#include <iostream>+#include <cmath>+#include <taglib/fileref.h>+#include <taglib/tag.h>++class TurntableRemote : public Cider {+ Q_OBJECT+ Q_PROPERTY(int count READ count NOTIFY trackChanged)+ Q_PROPERTY(bool canSeek READ canSeek NOTIFY trackChanged)+ Q_PROPERTY(bool playing MEMBER running NOTIFY playingChanged)+ Q_PROPERTY(qint64 position MEMBER at NOTIFY positionChanged)+ Q_PROPERTY(qint64 duration READ length NOTIFY trackChanged)+ Q_PROPERTY(QString trackKey READ key NOTIFY trackChanged)+ Q_PROPERTY(QVariantMap discDetails READ album NOTIFY discDetailsChanged)+ Q_PROPERTY(bool discLoading READ albumLoading NOTIFY discDetailsChanged)+ Q_PROPERTY(QString discError READ albumError NOTIFY discDetailsChanged)+public:+ TurntableRemote():Cider(false){}+ int count() const {return 1;} bool canSeek() const {return true;}+ qint64 length() const {return albumFixture?QList<qint64>{32000,48000,24000}[selected]:32000;}+ QString key() const {return QString("turntable-fixture-%1").arg(selected);}+ bool albumLoading() const {return false;} QString albumError() const {return {};}+ QVariantMap album() const {+ if(!albumFixture)return {};+ QVariantList tracks;+ for(int i=0;i<3;++i)tracks.append(QVariantMap{{"id",QString::number(101+i)},{"duration",QList<int>{32000,48000,24000}[i]},{"playable",true},{"title",QString("Track %1").arg(i+1)}});+ return {{"tracks",tracks},{"albumId","100"},{"currentId",QString::number(101+selected)}};+ }+ void select(int index,qint64 position=0) {selected=index;at=position;emit trackChanged();emit discDetailsChanged();emit positionChanged();}+ Q_INVOKABLE void play(){running=true;emit playingChanged();}+ Q_INVOKABLE void pause(){running=false;emit playingChanged();}+ Q_INVOKABLE void toggle(){running=!running;emit playingChanged();}+ Q_INVOKABLE void seek(qint64 value){at=qBound<qint64>(0,value,length());emit positionChanged();}+ bool running=false,albumFixture=false;int selected=0;qint64 at=0;+};+// Delayed album changes reproduce remote metadata arriving before the seek tick.+class TurntableListening : public Listening {+ Q_OBJECT+ Q_PROPERTY(bool busy MEMBER pending NOTIFY changed)+public:+ explicit TurntableListening(TurntableRemote *source):Listening(source),remote(source){}+ Q_INVOKABLE void cancelAlbumPosition(){++generation;pending=false;emit changed();}+ Q_INVOKABLE bool playAlbumPosition(const QString &id,const QVariantList &tracks,int index,qint64 position) {+ if(id!="100"||index<0||index>=tracks.size())return false;+ pending=true;emit changed();const auto token=++generation;+ QTimer::singleShot(40,this,[=,this]{if(token!=generation)return;remote->select(index);+ QTimer::singleShot(40,this,[=,this]{if(token!=generation)return;remote->seek(position);remote->play();pending=false;emit changed();});});+ return true;+ }+ TurntableRemote *remote;bool pending=false;int generation=0;+};+int exerciseTurntable(Player &player,QQuickWindow *window,const QString &temp,const QString &captures) {+ int checks=0,failures=0;+ const auto check=[&](bool ok,const char *name){++checks;if(!ok)++failures;std::cout<<(ok?"PASS ":"FAIL ")<<name<<std::endl;return ok;};+ const auto until=[](const std::function<bool()> &f){QElapsedTimer t;t.start();while(!f()&&t.elapsed()<3500)QTest::qWait(20);return f();};+ std::function<QQuickItem*(QQuickItem*,const QString&)> find=[&](QQuickItem *p,const QString &n)->QQuickItem*{if(p->objectName()==n)return p;for(auto *child:p->childItems())if(auto *v=find(child,n))return v;return nullptr;};+ const auto item=[&](QString name){return find(window->contentItem(),name);};+ const auto object=[&](const char *name){return window->findChild<QObject*>(name);};+ const auto invoke=[&](QObject *o,const char *name){return QMetaObject::invokeMethod(o,name);};+ auto *typography=qmlContext(window)->contextProperty("typography").value<QObject*>();+ player.setVolume(0);player.setMotion(false);player.setThreeD(false);player.setMiniMode(false);player.setMedium("vinyl");player.setVinylAlbumMode(false);player.clear();window->setProperty("useCider",false);+ QList<QUrl> files;+ for(int i=0;i<3;++i){const QString path=temp+QString("/record-%1.flac").arg(i);QFile::copy(QStringLiteral(SPUN_SOURCE_DIR "/assets/First-Light.flac"),path);TagLib::FileRef tag(QFile::encodeName(path).constData());tag.tag()->setAlbum("Turntable fixture");tag.tag()->setTrack(i+1);tag.save();files.append(QUrl::fromLocalFile(path));}+ player.addUrls(files,false);+ check(until([&]{return !player.busy()&&player.count()==3;}),"album fixtures import");+ player.setThreeD(true);+ if(!check(until([&]{return !player.busy()&&player.count()==3&&window->property("threeDActive").toBool();}),"turntable and isolated album load"))return 2;+ player.select(0,false);QTest::qWait(300);+ auto *view=item("player3DView");+ const auto hardware=[&](int index){QVariant r;QMetaObject::invokeMethod(view,"projectVinylControl",Q_RETURN_ARG(QVariant,r),Q_ARG(QVariant,index));return view->mapToScene(r.toPointF()).toPoint();};+ 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");};+ capture("vinyl-front");+ if(qEnvironmentVariableIsSet("SPUN_TEST_VISUAL_ONLY")) {+ window->setColor(QColor("#25272c"));+ capture("vinyl-front-solid");+ for(const auto &pose:QList<QPair<double,double>>{{35.,0.},{-40.,10.},{180.,0.}}) {+ view->setProperty("vinylYaw",pose.first);view->setProperty("vinylPitch",pose.second);+ capture(QString("vinyl-solid-%1").arg(pose.first));+ }+ return failures;+ }+ TurntableRemote remote;const auto original=window->property("ciderService");window->setProperty("ciderService",QVariant::fromValue(static_cast<QObject*>(&remote)));+ if(!qEnvironmentVariableIsSet("SPUN_TEST_ALBUM_ONLY"))for(bool cider:{false,true})for(double zoom:{.85,1.,1.5}) {+ window->setProperty("useCider",cider);typography->setProperty("uiScale",zoom);player.setHorizontalSeek(true);QTest::qWait(150);+ player.pause();remote.pause();+ clickHardware(0);check(player.vinylSpeed()==33,"33 button selects 33 and one third RPM");+ clickHardware(1);check(player.vinylSpeed()==45,"45 button selects 45 RPM");+ clickHardware(2);check(until([&]{return cider?remote.running:player.playing();}),"cue lever lowers needle and plays");+ clickHardware(2);check(!(cider?remote.running:player.playing()),"cue lever lifts needle and pauses");+ player.setVinylSpeed(33);QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,hardware(1));check(player.vinylSpeed()==33,"speed change waits for release");check(object("vinylSpeedKey1")&&object("vinylSpeedKey1")->property("z").toDouble()<1.,"speed key depresses into its housing");move(QPoint(10,10));QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,QPoint(10,10));check(player.vinylSpeed()==33,"dragging off a speed button cancels activation");+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,hardware(1));QTest::keyClick(window,Qt::Key_Escape);QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,hardware(1));check(player.vinylSpeed()==33&&!window->property("threeDHardwarePressed").toBool(),"Escape cancels hardware pressure and activation");+ auto *rim=item("scrubber");+ const auto start=projected(rim,{436,220});QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,start);+ for(int n=1;n<=12;++n){const double a=(.5+n/12.)*M_PI;move(projected(rim,{220+216*std::sin(a),220-216*std::cos(a)}));}+ check(std::abs(window->property("recordVisualProgress").toDouble()-.75)<.025,"ring drag previews three quarters");+ QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,projected(rim,{4,220}));+ check(until([&]{return std::abs((cider?remote.at:player.position())-(cider?remote.length():player.duration())*.75)<900;}),"ring drag commits the same playback position");+ auto *arm=item("vinylTonearm"),*needle=item("needleHandle");+ const auto tip=projected(arm,needle->property("tip").toPointF());QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,tip);+ check(arm->property("dragging").toBool(),"modeled needle can be grabbed");+ const double a=(arm->property("startAngle").toDouble()+arm->property("angleRange").toDouble()*.5)*M_PI/180;+ const auto mid=projected(arm,{arm->property("pivotX").toDouble()-arm->property("armLength").toDouble()*std::sin(a),arm->property("pivotY").toDouble()+arm->property("armLength").toDouble()*std::cos(a)});+ for(int n=1;n<=8;++n)move(tip+(mid-tip)*n/8);+ check(std::abs(window->property("recordVisualProgress").toDouble()-.5)<.025,"needle and ring share the same preview");+ QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,mid);+ check(until([&]{return (cider?remote.running:player.playing())&&std::abs((cider?remote.at:player.position())-16000)<1100;}),"needle drop seeks and plays");player.pause();remote.pause();+ auto *slider=item("horizontalSeek");const auto p=slider->mapToScene({slider->width()*.35,18}).toPoint();QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,p);+ check(window->property("seekPreviewActive").toBool()&&std::abs(arm->property("groove").toDouble()-window->property("recordVisualProgress").toDouble())<.001,"horizontal seek also moves the tonearm");QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,p);+ }+ TurntableListening listening(&remote);const auto originalListening=window->property("listeningService");+ window->setProperty("listeningService",QVariant::fromValue(static_cast<QObject*>(&listening)));+ remote.albumFixture=true;remote.select(0);player.setVinylAlbumMode(true);typography->setProperty("uiScale",1.);+ for(bool threeD:{false,true}) {+ player.setThreeD(threeD);QTest::qWait(250);view=item("player3DView");+ for(bool cider:{false,true}) {+ window->setProperty("useCider",cider);player.setHorizontalSeek(true);QTest::qWait(80);+ auto *slider=item("horizontalSeek"),*rim=item("scrubber"),*arm=item("vinylTonearm");+ const auto synced=[&]{return std::abs(slider->property("value").toDouble()-window->property("recordVisualProgress").toDouble())<.001 && std::abs(arm->property("groove").toDouble()-slider->property("value").toDouble())<.001;};+ for(int index:{0,1,2,0}) {+ if(cider)remote.select(index,2000);else {player.select(index,false);player.seek(2000);}+ QTest::qWait(80);+ const double expected=cider?(QList<double>{0,32000,80000}[index]+remote.at)/104000.:(index*32000.+player.position())/96000.;+ if(!check(synced()&&std::abs(slider->property("value").toDouble()-expected)<.01,"song changes keep both bars and the needle on one album timeline"))+ std::cout<<"timeline cider="<<cider<<" index="<<index<<" expected="<<expected<<" horizontal="<<slider->property("value").toDouble()<<" ring="<<window->property("recordVisualProgress").toDouble()<<" needle="<<arm->property("groove").toDouble()<<" duration="<<window->property("seekDuration").toDouble()<<std::endl;+ }+ const auto p=slider->mapToScene({slider->width()*.9,18}).toPoint();+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,p);const double target=slider->property("previewValue").toDouble();+ check(synced(),"horizontal album drag synchronizes ring and needle");+ QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,p);+ check(until([&]{return synced()&&std::abs(window->property("recordProgress").toDouble()-target)<.02;}),"horizontal album seek reaches the selected album position");+ player.pause();remote.pause();+ const auto ringPoint=[&](QPointF point){return threeD?projected(rim,point):rim->mapToScene(point).toPoint();};+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,ringPoint({436,220}));+ for(int i=1;i<=8;++i){const double a=(.5+i*.08)*M_PI;move(ringPoint({220+216*std::sin(a),220-216*std::cos(a)}));check(synced(),"album ring drag keeps the horizontal bar and needle synchronized");}+ const double ringTarget=rim->property("previewFraction").toDouble();+ QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,ringPoint({220+216*std::sin(1.14*M_PI),220-216*std::cos(1.14*M_PI)}));+ check(until([&]{return synced()&&std::abs(window->property("recordProgress").toDouble()-ringTarget)<.02;}),"ring album seek stays synchronized after delayed track updates");+ player.pause();remote.pause();+ }+ }+ player.setVinylAlbumMode(false);window->setProperty("listeningService",originalListening);+ if(qEnvironmentVariableIsSet("SPUN_TEST_ALBUM_ONLY")) {+ window->setProperty("useCider",false);window->setProperty("ciderService",original);+ std::cout<<"ALBUM RESULT "<<checks<<" checks, "<<failures<<" failures"<<std::endl;return failures?1:0;+ }+ window->setProperty("useCider",false);window->setProperty("ciderService",original);typography->setProperty("uiScale",1.);player.setHorizontalSeek(false);player.pause();+ for(bool running:{false,true}) {+ if(running)player.play();else player.pause();QTest::qWait(90);+ QVariant p;QMetaObject::invokeMethod(view,"projectVinylNeedle",Q_RETURN_ARG(QVariant,p));const auto tip=view->mapToScene(p.toPointF()).toPoint();+ QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,tip);+ check(item("vinylTonearm")->property("dragging").toBool(),"visible raised or lowered stylus is directly draggable");+ invoke(window,"cancel3DPointer");QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,tip);player.pause();+ }+ auto *arm=item("vinylTonearm");const double inner=(arm->property("startAngle").toDouble()+arm->property("angleRange").toDouble())*M_PI/180;+ const double radius=std::hypot((arm->property("pivotX").toDouble()-220-arm->property("armLength").toDouble()*std::sin(inner))*.86,(arm->property("pivotY").toDouble()-220+arm->property("armLength").toDouble()*std::cos(inner))*.86);+ check(radius>63&&radius<79,"innermost groove keeps the stylus outside the paper label");+ player.setVinylAlbumMode(true);QTest::qWait(150);check(object("threeDTrackBands")&&object("threeDTrackBands")->property("count").toInt()==2,"album mode retains track bands");player.setVinylAlbumMode(false);+ for(const auto &pose:QList<QPair<double,double>>{{35.,0.},{-40.,10.},{180.,0.}}){view->setProperty("vinylYaw",pose.first);view->setProperty("vinylPitch",pose.second);QTest::qWait(150);capture(QString("vinyl-angle-%1").arg(pose.first));}+ invoke(view,"resetVinylOrientation");QTest::qWait(100);+ clickHardware(3);auto *cover=object("vinylDustCover");check(cover&&std::abs(cover->property("eulerRotation").value<QVector3D>().x())<.01,"dust cover closes");capture("vinyl-closed");+ clickHardware(3);check(cover&&object("vinylTurntable")->property("coverOpen").toBool()&&cover->property("eulerRotation").value<QVector3D>().x()<-60,"dust cover opens");+ const auto from=projected(item("scrubber"),{450,410});QTest::mousePress(window,Qt::LeftButton,Qt::NoModifier,from);move(from+QPoint(90,-35));QTest::mouseRelease(window,Qt::LeftButton,Qt::NoModifier,from+QPoint(90,-35));check(std::abs(view->property("vinylYaw").toDouble())>10,"housing drag rotates the whole turntable");check(!window->property("discFlipped").toBool(),"inspection remains separate from F reverse");invoke(view,"resetVinylOrientation");+ player.setMotion(true);player.play();const double spin=window->property("spinAngle").toDouble();check(until([&]{return window->property("spinAngle").toDouble()!=spin;}),"record spins during playback");player.setMotion(false);player.pause();+ for(int i=0;i<6;++i){player.setMedium(i%2?"tp7":"cd");QTest::qWait(40);player.setMedium("vinyl");QTest::qWait(80);check(object("threeDRecord")&&object("vinylDustCover"),"turntable survives medium changes");}+ invoke(window,"flipDisc");check(window->property("discFlipped").toBool(),"F reverse opens album details");invoke(window,"flipDisc");player.setMiniMode(true);check(!window->property("threeDActive").toBool(),"Mini falls back to 2D");player.setMiniMode(false);check(until([&]{return window->property("threeDActive").toBool();}),"return from Mini restores turntable");+ capture("vinyl-final");+ std::cout<<"TURNTABLE RESULT "<<checks<<" checks, "<<failures<<" failures"<<std::endl;return failures?1:0;+}+#include "turntabletest.moc"diff --git a/src/turntabletest.h b/src/turntabletest.hnew file mode 100644index 0000000..0ab7459--- /dev/null+++ b/src/turntabletest.h@@ -0,0 +1,5 @@+#pragma once+#include <QString>+class Player;+class QQuickWindow;+int exerciseTurntable(Player &player,QQuickWindow *window,const QString &temp,const QString &captures);