// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \example audio-visualizer-qml
    \title Qt 3D: Audio Visualizer Example
    \ingroup qt3d-examples-qml
    \brief Demonstrates combining Qt 3D rendering and Qt Quick 2 elements.

    \image audio-visualizer-qml-example.png

    \e Audio Visualizer demonstrates how to implement an application that combines the use of
    Qt 3D rendering with Qt Quick 2D elements. The example uses media player to play music and it
    visualizes the magnitude of the music as animated bars.

    \include examples-run.qdocinc

    \section1 Qt Quick 2D Implementation

    The Qt Quick Implementation in \c {audio-visualizer-qml/main.qml} of the example uses
    \c{MediaPlayer} to play audio content.

    \snippet audio-visualizer-qml/main.qml 0

    The player is controlled with the \c{playButton} and c\{stopButton}. Based on the clicked
    buttons the \c{state} of the \c{mainview} changes.

    The 3D content is rendered using the \c{Scene3D} type. The state of the Audio Visualizer is
    maintained in the \c{mainview}. It's passed on to the \c{visualizer} as it's needed for the bar
    animations.

    \snippet audio-visualizer-qml/main.qml 1

    \section1 Qt 3D Implementation

    The 3D elements of the example are created in
    \c {audio-visualizer-qml/Visualizer.qml}. The camera is set to a fixed position
    to show the visualized bars from a correct angle.

    \snippet audio-visualizer-qml/Visualizer.qml 0

    A \c{NodeInstantiator} is used to create the bars that visualize the magnitude of the music.

    \snippet audio-visualizer-qml/Visualizer.qml 1

    The \c{visualizer} also contains an \c{Entity} to show the progress. This element has a curve
    shaped mesh and it's rotated on a level to show the progress based on the duration of the played
    track.

    \snippet audio-visualizer-qml/Visualizer.qml 2

    In \c {audio-visualizer-qml/BarEntity.qml} there are animations for rotating the
    bars and changing the bar color. The bars are rotated on a level following a ring form. At the
    same time the color of the bars is animated.

    \snippet audio-visualizer-qml/BarEntity.qml 0

    \snippet audio-visualizer-qml/BarEntity.qml 1

    The magnitude of each bar is read from a separate .raw file that is based on the track being
    played. As the bars rotate around the ring the height is scaled to highlight currently played
    position. After a full round of rotation, a new value is fetched for the bar.

*/
