Skip to content

Commit

Permalink
scrolling qml waveformdisplay working
Browse files Browse the repository at this point in the history
WIP

PreRoll hack

Matrix based on viewport and rect (#7)

* bundle on macos

* use Skin.WaveformDisplay for both decks

* add shaders to mixxx target

* call update from frameSwapped, test with only waveformrendererendoftrack

* avoid error with colorChanged signals

* fix typo in comment

* example cleanup

* keep track of size and viewport to update matrices in waveformwidgetrenderer

* force continuous drawing of end of track, log framerate, use rgbamaterial instead of endoftrack material

* use setViewport instead of resize, protect nullptr

* call setViewport, setRect, setDevicePixelRatio

* replace resize with setViewport, setRect, setDevicePixelRatio

* set matrix with correct offset, minor fixes related with material changes

---------

Co-authored-by: m0dB <m0dB@mixxx.org>

move everything back to declarative style

progress with marks
  • Loading branch information
m0dB authored and acolombier committed Oct 19, 2024
1 parent 1e57aae commit 9afd06a
Show file tree
Hide file tree
Showing 60 changed files with 2,673 additions and 148 deletions.
357 changes: 357 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

31 changes: 30 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,7 @@ if(QT6)
# below that takes care of the correct object order in the resulting binary
# According to https://doc.qt.io/qt-6/qt-finalize-target.html it is importand for
# builds with Qt < 3.21
qt_add_executable(mixxx WIN32 src/main.cpp MANUAL_FINALIZATION)
qt_add_executable(mixxx WIN32 MACOSX_BUNDLE src/main.cpp MANUAL_FINALIZATION)
else()
find_package(Qt5 COMPONENTS Core) # For Qt Core cmake functions
# This is the first package form the environment, if this fails give hints how to install the environment
Expand Down Expand Up @@ -2766,6 +2766,7 @@ if(QML)
res/qml/Mixxx/Controls/WaveformOverviewHotcueMarker.qml
res/qml/Mixxx/Controls/WaveformOverviewMarker.qml
res/qml/Mixxx/Controls/WaveformOverview.qml
res/qml/Mixxx/Controls/WaveformDisplay.qml
)
target_link_libraries(mixxx-qml-lib PRIVATE mixxx-qml-mixxxcontrolsplugin)

Expand All @@ -2788,6 +2789,24 @@ if(QML)
src/qml/qmlvisibleeffectsmodel.cpp
src/qml/qmlchainpresetmodel.cpp
src/qml/qmlwaveformoverview.cpp
src/qml/qmlwaveformdisplay.cpp
src/qml/qmlwaveformrenderer.cpp
src/waveform/renderers/waveformdisplayrange.cpp

src/waveform/renderers/allshader/digitsrenderer.cpp
src/waveform/renderers/allshader/waveformrenderbeat.cpp
src/waveform/renderers/allshader/waveformrenderer.cpp
src/waveform/renderers/allshader/waveformrendererendoftrack.cpp
# FIXME depends on rendergraph/openglnode.h
# src/waveform/renderers/allshader/waveformrendererslipmode.cpp
# src/waveform/renderers/allshader/waveformrendererfiltered.cpp
# src/waveform/renderers/allshader/waveformrendererhsv.cpp
src/waveform/renderers/allshader/waveformrendererpreroll.cpp
src/waveform/renderers/allshader/waveformrendererrgb.cpp
src/waveform/renderers/allshader/waveformrenderersignalbase.cpp
# src/waveform/renderers/allshader/waveformrenderersimple.cpp
src/waveform/renderers/allshader/waveformrendermark.cpp
src/waveform/renderers/allshader/waveformrendermarkrange.cpp
# The following sources need to be in this target to get QML_ELEMENT properly interpreted
src/control/controlmodel.cpp
src/control/controlsortfiltermodel.cpp
Expand Down Expand Up @@ -3480,6 +3499,8 @@ if (STEM)
if(QML)
target_compile_definitions(mixxx-qml-lib PUBLIC __STEM__)
target_sources(mixxx-qml-lib PRIVATE
# FIXME depends on rendergraph/openglnode.h
# src/waveform/renderers/allshader/waveformrendererstem.cpp
src/qml/qmlstemsmodel.cpp
)
endif()
Expand Down Expand Up @@ -3814,6 +3835,14 @@ add_subdirectory(src/rendergraph/opengl)
add_subdirectory(res/shaders/rendergraph)
target_link_libraries(mixxx-lib PUBLIC rendergraph_gl)
target_compile_definitions(mixxx-lib PRIVATE rendergraph=rendergraph_gl)
target_compile_definitions(mixxx-lib PRIVATE __RENDERGRAPH_OPENGL__)
target_compile_definitions(mixxx-lib PRIVATE allshader=allshader_gl)
if(QML)
add_subdirectory(src/rendergraph/scenegraph)
target_link_libraries(mixxx-qml-lib PRIVATE rendergraph_sg)
target_compile_definitions(mixxx-qml-lib PRIVATE rendergraph=rendergraph_sg)
target_compile_definitions(mixxx-qml-lib PRIVATE allshader=allshader_sg)
endif()

# WavPack audio file support
find_package(wavpack)
Expand Down
7 changes: 7 additions & 0 deletions res/qml/Mixxx/Controls/WaveformDisplay.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Mixxx 1.0 as Mixxx

Mixxx.WaveformDisplay {
id: root

player: Mixxx.PlayerManager.getPlayer(root.group)
}
238 changes: 238 additions & 0 deletions res/qml/WaveformDisplay.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
import "." as Skin
import Mixxx 1.0 as Mixxx
import Mixxx.Controls 1.0 as MixxxControls
import QtQuick 2.12
import "Theme"

Item {
id: root

required property string group

enum MouseStatus {
Normal,
Bending,
Scratching
}

MixxxControls.WaveformDisplay {
anchors.fill: parent
group: root.group

Mixxx.WaveformRendererEndOfTrack {
color: 'blue'
}

Mixxx.WaveformRendererPreroll {
color: 'red'
}

// // Mixxx.WaveformRendererMarkRange {
// // // <!-- Loop -->
// // Mixxx.WaveformMarkRange {
// // startControl: "loop_start_position"
// // endControl: "loop_end_position"
// // enabledControl: "loop_enabled"
// // color: 'LoopColor'
// // opacity: 0.7
// // disabledColor: '#FFFFFF'
// // disabledOpacity: 0.6
// // }
// // // <!-- Intro -->
// // Mixxx.WaveformMarkRange {
// // startControl: "intro_start_position"
// // endControl: "intro_end_position"
// // // visibilityControl: '[Skin],show_intro_outro_cues'
// // color: 'IntroOutroColor'
// // opacity: 0.6
// // durationTextColor: '#ffffff'
// // durationTextLocation: 'after'
// // }
// // // <!-- Outro -->
// // Mixxx.WaveformMarkRange {
// // startControl: "outro_start_position"
// // endControl: "outro_end_position"
// // // visibilityControl: '[Skin],show_intro_outro_cues'
// // color: 'IntroOutroColor'
// // opacity: 0.6
// // durationTextColor: '#ffffff'
// // durationTextLocation: 'before'
// // }
// // }

Mixxx.WaveformRendererRGB {
axesColor: 'yellow'
lowColor: 'red'
midColor: 'green'
highColor: 'blue'
}

Mixxx.WaveformRendererBeat {
color: 'green'
}

Mixxx.WaveformRendererMark {
playMarkerColor: 'cyan'
playMarkerBackground: 'orange'
defaultMark: Mixxx.WaveformMark {
align: "bottom|right"
color: "#FF0000"
textColor: "#FFFFFF"
text: " %1 "
}
Mixxx.WaveformMark {
control: "cue_point"
text: 'C'
align: 'top|right'
color: 'red'
textColor: '#FFFFFF'
}
Mixxx.WaveformMark {
control: "loop_start_position"
text: '&#8635;'
align: 'top|left'
color: 'green'
textColor: '#FFFFFF'
}
Mixxx.WaveformMark {
control: "loop_end_position"
// visibilityControl: '<Variable name="'
// <!--Text>OUT</Text-->
align: 'bottom|right'
color: 'green'
textColor: '#FFFFFF'
// visibilityControl: '<Variable name="'
}
Mixxx.WaveformMark {
control: "intro_start_position"
// visibilityControl: '[Skin],show_intro_outro_cues'
align: 'top|right'
color: 'blue'
textColor: '#FFFFFF'
}
Mixxx.WaveformMark {
control: "intro_end_position"
// visibilityControl: '[Skin],show_intro_outro_cues'
text: '&#9698;'
align: 'top|left'
color: 'blue'
textColor: '#FFFFFF'
}
Mixxx.WaveformMark {
control: "outro_start_position"
// visibilityControl: '[Skin],show_intro_outro_cues'
text: '&#9699;'
align: 'top|right'
color: 'blue'
textColor: '#FFFFFF'
}
Mixxx.WaveformMark {
control: "outro_end_position"
// visibilityControl: '[Skin],show_intro_outro_cues'
align: 'top|left'
color: 'blue'
textColor: '#FFFFFF'
}
}
}

Mixxx.ControlProxy {
id: scratchPositionEnableControl

group: root.group
key: "scratch_position_enable"
}

Mixxx.ControlProxy {
id: scratchPositionControl

group: root.group
key: "scratch_position"
}

Mixxx.ControlProxy {
id: wheelControl

group: root.group
key: "wheel"
}

Mixxx.ControlProxy {
id: rateRatioControl

group: root.group
key: "rate_ratio"
}

Mixxx.ControlProxy {
id: zoomControl

group: root.group
key: "waveform_zoom"
}
readonly property real effectiveZoomFactor: (1 / rateRatioControl.value) * (100 / zoomControl.value)

MouseArea {
property int mouseStatus: WaveformDisplay.MouseStatus.Normal
property point mouseAnchor: Qt.point(0, 0)

anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressed: {
mouseAnchor = Qt.point(mouse.x, mouse.y);
if (mouse.button == Qt.LeftButton) {
if (mouseStatus == WaveformDisplay.MouseStatus.Bending)
wheelControl.parameter = 0.5;

mouseStatus = WaveformDisplay.MouseStatus.Scratching;
scratchPositionEnableControl.value = 1;
// TODO: Calculate position properly
scratchPositionControl.value = -mouse.x * 2 * zoomControl.value;
console.log(mouse.x);
} else {
if (mouseStatus == WaveformDisplay.MouseStatus.Scratching)
scratchPositionEnableControl.value = 0;

wheelControl.parameter = 0.5;
mouseStatus = WaveformDisplay.MouseStatus.Bending;
}
}
onPositionChanged: {
switch (mouseStatus) {
case WaveformDisplay.MouseStatus.Bending: {
const diff = mouse.x - mouseAnchor.x;
// Start at the middle of [0.0, 1.0], and emit values based on how far
// the mouse has traveled horizontally. Note, for legacy (MIDI) reasons,
// this is tuned to 127.
const v = 0.5 + (diff / 1270);
// clamp to [0.0, 1.0]
wheelControl.parameter = Mixxx.MathUtils.clamp(v, 0, 1);
break;
};
case WaveformDisplay.MouseStatus.Scratching:
// TODO: Calculate position properly
scratchPositionControl.value = -mouse.x * zoomControl.value * 2 * 10;
break;
}
}
onReleased: {
switch (mouseStatus) {
case WaveformDisplay.MouseStatus.Bending:
wheelControl.parameter = 0.5;
break;
case WaveformDisplay.MouseStatus.Scratching:
scratchPositionEnableControl.value = 0;
break;
}
mouseStatus = WaveformDisplay.MouseStatus.Normal;
}

onWheel: {
if (wheel.angleDelta.y < 0 && zoomControl.value > 1) {
zoomControl.value -= 1;
} else if (wheel.angleDelta.y > 0 && zoomControl.value < 10.0) {
zoomControl.value += 1;
}
}
}
}
43 changes: 29 additions & 14 deletions res/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -111,32 +111,47 @@ ApplicationWindow {
}
}

WaveformRow {
// WaveformRow {
// id: deck1waveform

// group: "[Channel1]"
// width: root.width
// height: 60
// visible: !root.maximizeLibrary

// FadeBehavior on visible {
// fadeTarget: deck1waveform
// }
// }

Skin.WaveformDisplay {
id: deck1waveform

group: "[Channel1]"
width: root.width
height: 60
visible: !root.maximizeLibrary

FadeBehavior on visible {
fadeTarget: deck1waveform
}
group: "[Channel1]"
}

WaveformRow {
Skin.WaveformDisplay {
id: deck2waveform

group: "[Channel2]"
width: root.width
height: 60
visible: !root.maximizeLibrary

FadeBehavior on visible {
fadeTarget: deck2waveform
}
group: "[Channel2]"
}

// WaveformRow {
// id: deck2waveform
//
// group: "[Channel2]"
// width: root.width
// height: 60
// visible: !root.maximizeLibrary
//
// FadeBehavior on visible {
// fadeTarget: deck2waveform
// }
// }
WaveformRow {
id: deck4waveform

Expand Down
12 changes: 12 additions & 0 deletions res/shaders/rendergraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ qt6_add_shaders(rendergraph_sg "shaders-qsb"
${shaders}
)

if(TARGET mixxx)
qt6_add_shaders(mixxx "shaders-qsb"
BATCHABLE
PRECOMPILE
OPTIMIZED
PREFIX
/shaders/rendergraph
FILES
${shaders}
)
endif()

if(USE_QSHADER_FOR_GL)
message(STATUS "Adding qsb shaders to rendergraph_gl")
qt6_add_shaders(rendergraph_gl "shaders-qsb"
Expand Down
Loading

0 comments on commit 9afd06a

Please sign in to comment.