AudioEngine QML Type | Qt Multimedia 5.15.18 (original) (raw)

Organize all your 3d audio content in one place. More...

Import Statement: import QtAudioEngine 1.15
Since: Qt 5.0
Inherits: Item

Properties

Signals

Methods

Detailed Description

Rectangle { color:"white" width: 300 height: 500

[AudioEngine](qml-qtaudioengine-audioengine.html) {
    id:audioengine

    [AudioSample](qml-qtaudioengine-audiosample.html) {
        name:"explosion"
        source: "explosion-02.wav"
    }

    [Sound](qml-qtaudioengine-sound.html) {
        name:"explosion"
        [PlayVariation](qml-qtaudioengine-playvariation.html) {
            sample:"explosion"
        }
    }

    dopplerFactor: 1
    speedOfSound: 343.33 // Approximate speed of sound in air at 20 degrees Celsius

    listener.up:"0,0,1"
    listener.position:"0,0,0"
    listener.velocity:"0,0,0"
    listener.direction:"0,1,0"
}

[MouseArea](qml-qtquick-mousearea.html) {
    anchors.fill: parent
    onPressed: {
        audioengine.sounds["explosion"].play();
    }
}

}

AudioEngine acts as a central library for configuring all 3d audio content in an app, so you should define only one in your app.

It is mostly used as a container to access other types such as AudioCategory, AudioSample and Sound.

See also AudioCategory, AudioSample, Sound, SoundInstance, AttenuationModelLinear, and AttenuationModelInverse.

Property Documentation

This property holds a simple scaling for the effect of doppler shift.

This property holds the listener object. You can change various properties to affect the 3D positioning of sounds.

See also AudioListener.

This property indicates how many live sound instances there are at the moment.

This property indicates if the audio engine is loading any audio sample at the moment. This may be useful if you specified the preloaded property in AudioSample and would like to show a loading screen to the user before all audio samples are loaded.

/sa finishedLoading, AudioSample::preloaded

Container of all Sound instances.

This property holds the reference value of the sound speed (in meters per second) which will be used in doppler shift calculation. The doppler shift calculation is used to emulate the change in frequency in sound that is perceived by an observer when the sound source is travelling towards or away from the observer. The speed of sound depends on the medium the sound is propagating through.

Signal Documentation

This signal is emitted when loading has completed.

The corresponding handler is onFinishedLoading.

Note: The corresponding handler is onFinishedLoading.

This signal is emitted when the loading property changes.

The corresponding handler is onIsLoadingChanged.

Note: The corresponding handler is onIsLoadingChanged.

liveInstanceCountChanged()

This signal is emitted when the number of live instances managed by the AudioEngine is changed.

The corresponding handler is onLiveInstanceCountChanged.

Note: The corresponding handler is onLiveInstanceCountChanged.

This signal is emitted when the AudioEngine is ready to use.

The corresponding handler is onReady.

Note: The corresponding handler is onReady.

Method Documentation

addAttenuationModel(AttenuationModel attenuationModel)

Adds the given attenuationModel to the engine. This can be used when the AttenuationModelLinear / AttenuationModelInverse is created dynamically:

import QtAudioEngine 1.1

AudioEngine { id: engine

Component.onCompleted: {
    var attenuationModel = Qt.createQmlObject('import QtAudioEngine 1.1; AttenuationModelLinear {}', engine);
    attenuationModel.name ="linear"
    attenuationModel.start = 20
    attenuationModel.end = 180
    engine.addAttenuationModel(attenuationModel);
}

}

Adds the given category to the engine. This can be used when the AudioCategory is created dynamically:

import QtAudioEngine 1.1

AudioEngine { id: engine

Component.onCompleted: {
    var category = Qt.createQmlObject('import QtAudioEngine 1.1; AudioCategory {}', engine);
    category.name = "sample";
    category.volume = 0.9;
    engine.addAudioCategory(category);
}

}

Adds the given sample to the engine. This can be used when the AudioSample is created dynamically:

import QtAudioEngine 1.15

AudioEngine { id: engine

Component.onCompleted: {
    var sample = Qt.createQmlObject('import QtAudioEngine 1.1; AudioSample {}', engine);
    sample.name = "example";
    sample.source = "example.wav";
    engine.addAudioSample(sample);
}

}

Adds the given sound to the engine. This can be used when the Sound is created dynamically:

import QtAudioEngine 1.1

AudioEngine { id: engine

Component.onCompleted: {
    var sound = Qt.createQmlObject('import QtAudioEngine 1.1; Sound {}', engine);
    sound.name = "example";
    engine.addSound(sound);
}

}

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.