diff options
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/audioengine/audioengine.cpp | 2 | ||||
-rw-r--r-- | src/imports/multimedia/Video.qml | 12 | ||||
-rw-r--r-- | src/imports/multimedia/multimedia.cpp | 5 | ||||
-rw-r--r-- | src/imports/multimedia/plugins.qmltypes | 23 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativeaudio.cpp | 24 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativemultimediaglobal.cpp | 53 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativemultimediaglobal_p.h | 12 |
7 files changed, 121 insertions, 10 deletions
diff --git a/src/imports/audioengine/audioengine.cpp b/src/imports/audioengine/audioengine.cpp index 8eb2dea33..a132af49a 100644 --- a/src/imports/audioengine/audioengine.cpp +++ b/src/imports/audioengine/audioengine.cpp @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE class QAudioEngineDeclarativeModule : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QAudioEngineDeclarativeModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } diff --git a/src/imports/multimedia/Video.qml b/src/imports/multimedia/Video.qml index 2188d17b9..b3fee7495 100644 --- a/src/imports/multimedia/Video.qml +++ b/src/imports/multimedia/Video.qml @@ -360,7 +360,17 @@ Item { /*! \qmlproperty real Video::volume - This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume). + This property holds the audio volume. + + The volume is scaled linearly from \c 0.0 (silence) to \c 1.0 (full volume). Values outside + this range will be clamped. + + The default volume is \c 1.0. + + UI volume controls should usually be scaled nonlinearly. For example, using a logarithmic + scale will produce linear changes in perceived loudness, which is what a user would normally + expect from a volume control. See \l {QtMultimedia::QtMultimedia::convertVolume()}{QtMultimedia.convertVolume()} + for more details. */ property alias volume: player.volume diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp index 872b2ae61..b7ab473c7 100644 --- a/src/imports/multimedia/multimedia.cpp +++ b/src/imports/multimedia/multimedia.cpp @@ -81,7 +81,7 @@ static QObject *multimedia_global_object(QQmlEngine *qmlEngine, QJSEngine *jsEng class QMultimediaDeclarativeModule : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QMultimediaDeclarativeModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } @@ -140,6 +140,9 @@ public: qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing, 2>(uri, 5, 7, "CameraImageProcessing", trUtf8("CameraImageProcessing is provided by Camera")); + // 5.8 types (nothing new, re-register one of the types) + qmlRegisterType<QSoundEffect>(uri, 5, 8, "SoundEffect"); + qmlRegisterType<QDeclarativeMediaMetaData>(); qmlRegisterType<QAbstractVideoFilter>(); } diff --git a/src/imports/multimedia/plugins.qmltypes b/src/imports/multimedia/plugins.qmltypes index 91fff02eb..20bbf7d3e 100644 --- a/src/imports/multimedia/plugins.qmltypes +++ b/src/imports/multimedia/plugins.qmltypes @@ -4,7 +4,7 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -nonrelocatable QtMultimedia 5.7' +// 'qmlplugindump -nonrelocatable QtMultimedia 5.8' Module { dependencies: ["QtQuick 2.0"] @@ -1248,8 +1248,24 @@ Module { isCreatable: false isSingleton: true exportMetaObjectRevisions: [0] + Enum { + name: "VolumeScale" + values: { + "LinearVolumeScale": 0, + "CubicVolumeScale": 1, + "LogarithmicVolumeScale": 2, + "DecibelVolumeScale": 3 + } + } Property { name: "defaultCamera"; type: "QJSValue"; isReadonly: true } Property { name: "availableCameras"; type: "QJSValue"; isReadonly: true } + Method { + name: "convertVolume" + type: "double" + Parameter { name: "volume"; type: "double" } + Parameter { name: "from"; type: "VolumeScale" } + Parameter { name: "to"; type: "VolumeScale" } + } } Component { name: "QDeclarativePlaylist" @@ -1794,9 +1810,10 @@ Module { prototype: "QObject" exports: [ "QtMultimedia/SoundEffect 5.0", - "QtMultimedia/SoundEffect 5.3" + "QtMultimedia/SoundEffect 5.3", + "QtMultimedia/SoundEffect 5.8" ] - exportMetaObjectRevisions: [0, 0] + exportMetaObjectRevisions: [0, 0, 0] Enum { name: "Loop" values: { diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index 86f8f30ba..5a065072c 100644 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp @@ -689,9 +689,17 @@ QDeclarativeAudio::PlaybackState QDeclarativeAudio::playbackState() const /*! \qmlproperty real QtMultimedia::Audio::volume - This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume). + This property holds the audio volume. - Defaults to 1.0. + The volume is scaled linearly from \c 0.0 (silence) to \c 1.0 (full volume). Values outside this + range will be clamped. + + The default volume is \c 1.0. + + UI volume controls should usually be scaled nonlinearly. For example, using a logarithmic scale + will produce linear changes in perceived loudness, which is what a user would normally expect + from a volume control. See \l {QtMultimedia::QtMultimedia::convertVolume()}{QtMultimedia.convertVolume()} + for more details. */ /*! @@ -1310,9 +1318,17 @@ void QDeclarativeAudio::_q_mediaChanged(const QMediaContent &media) /*! \qmlproperty real QtMultimedia::MediaPlayer::volume - This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume). + This property holds the audio volume of the media player. - Defaults to 1.0. + The volume is scaled linearly from \c 0.0 (silence) to \c 1.0 (full volume). Values outside this + range will be clamped. + + The default volume is \c 1.0. + + UI volume controls should usually be scaled nonlinearly. For example, using a logarithmic scale + will produce linear changes in perceived loudness, which is what a user would normally expect + from a volume control. See \l {QtMultimedia::QtMultimedia::convertVolume()}{QtMultimedia.convertVolume()} + for more details. */ /*! diff --git a/src/imports/multimedia/qdeclarativemultimediaglobal.cpp b/src/imports/multimedia/qdeclarativemultimediaglobal.cpp index b2a1aed12..999f086d5 100644 --- a/src/imports/multimedia/qdeclarativemultimediaglobal.cpp +++ b/src/imports/multimedia/qdeclarativemultimediaglobal.cpp @@ -183,4 +183,57 @@ QJSValue QDeclarativeMultimediaGlobal::availableCameras() const return availableCameras; } +/*! + \qmlmethod real QtMultimedia::QtMultimedia::convertVolume(real volume, VolumeScale from, VolumeScale to) + + Converts an audio \a volume \a from a volume scale \a to another, and returns the result. + + Depending on the context, different scales are used to represent audio volume. All Qt Multimedia + classes that have an audio volume use a linear scale, the reason is that the loudness of a + speaker is controlled by modulating its voltage on a linear scale. The human ear on the other + hand, perceives loudness in a logarithmic way. Using a logarithmic scale for volume controls + is therefore appropriate in most applications. The decibel scale is logarithmic by nature and + is commonly used to define sound levels, it is usually used for UI volume controls in + professional audio applications. The cubic scale is a computationally cheap approximation of a + logarithmic scale, it provides more control over lower volume levels. + + Valid values for \a from and \a to are: + \list + \li QtMultimedia.LinearVolumeScale - Linear scale. \c 0.0 (0%) is silence and \c 1.0 (100%) is + full volume. All Qt Multimedia types that have an audio volume use a linear scale. + \li QtMultimedia.CubicVolumeScale - Cubic scale. \c 0.0 (0%) is silence and \c 1.0 (100%) is full + volume. + \li QtMultimedia.LogarithmicVolumeScale - Logarithmic scale. \c 0.0 (0%) is silence and \c 1.0 + (100%) is full volume. UI volume controls should usually use a logarithmic scale. + \li QtMultimedia.DecibelVolumeScale - Decibel (dB, amplitude) logarithmic scale. \c -200 is + silence and \c 0 is full volume. + \endlist + + The following example shows how the volume value from a UI volume control can be converted so + that the perceived increase in loudness is the same when increasing the volume control from 0.2 + to 0.3 as it is from 0.5 to 0.6: + + \code + Slider { + id: volumeSlider + + property real volume: QtMultimedia.convertVolume(volumeSlider.value, + QtMultimedia.LogarithmicVolumeScale, + QtMultimedia.LinearVolumeScale) + } + + MediaPlayer { + volume: volumeSlider.volume + } + \endcode + + \since 5.8 +*/ +qreal QDeclarativeMultimediaGlobal::convertVolume(qreal volume, + QDeclarativeMultimediaGlobal::VolumeScale from, + QDeclarativeMultimediaGlobal::VolumeScale to) const +{ + return QAudio::convertVolume(volume, QAudio::VolumeScale(from), QAudio::VolumeScale(to)); +} + QT_END_NAMESPACE diff --git a/src/imports/multimedia/qdeclarativemultimediaglobal_p.h b/src/imports/multimedia/qdeclarativemultimediaglobal_p.h index 2374b560c..101bd899a 100644 --- a/src/imports/multimedia/qdeclarativemultimediaglobal_p.h +++ b/src/imports/multimedia/qdeclarativemultimediaglobal_p.h @@ -53,6 +53,7 @@ #include <QtQml/qqml.h> #include <QtQml/qjsvalue.h> +#include <QtMultimedia/qaudio.h> QT_BEGIN_NAMESPACE @@ -63,12 +64,23 @@ class QDeclarativeMultimediaGlobal : public QObject Q_PROPERTY(QJSValue defaultCamera READ defaultCamera NOTIFY defaultCameraChanged) Q_PROPERTY(QJSValue availableCameras READ availableCameras NOTIFY availableCamerasChanged) + Q_ENUMS(VolumeScale) + public: + enum VolumeScale { + LinearVolumeScale = QAudio::LinearVolumeScale, + CubicVolumeScale = QAudio::CubicVolumeScale, + LogarithmicVolumeScale = QAudio::LogarithmicVolumeScale, + DecibelVolumeScale = QAudio::DecibelVolumeScale + }; + explicit QDeclarativeMultimediaGlobal(QJSEngine *engine, QObject *parent = 0); QJSValue defaultCamera() const; QJSValue availableCameras() const; + Q_INVOKABLE qreal convertVolume(qreal volume, VolumeScale from, VolumeScale to) const; + Q_SIGNALS: // Unused at the moment. QCameraInfo doesn't notify when cameras are added or removed, // but it might change in the future. |