AudioEngine QML 类型

将所有 3D 音频内容组织在一处。 更多...

import 语句: import QtAudioEngine 1.1
Since: Qt 5.0
继承: Item

特性

信号

方法

详细描述

Rectangle {
    color:"white"
    width: 300
    height: 500
    AudioEngine {
        id:audioengine
        AudioSample {
            name:"explosion"
            source: "explosion-02.wav"
        }
        Sound {
            name:"explosion"
            PlayVariation {
                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 {
        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.

另请参阅 AudioCategory , AudioSample , Sound , SoundInstance , AttenuationModelLinear ,和 AttenuationModelInverse .

特性文档编制

categories : map

Container of all AudioCategory 实例。

dopplerFactor : real

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

listener : QtAudioEngine::AudioListener

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

另请参阅 AudioListener .

liveInstances : int

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

loading : bool

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

samples : map

Container of all AudioSample 实例。

sounds : map

Container of all Sound instances.

speedOfSound : real

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.


信号文档编制

finishedLoading ()

此信号发射当 loading 已完成。

相应处理程序是 onFinishedLoading .

isLoadingChanged ()

此信号发射当 loading 特性改变。

相应处理程序是 onIsLoadingChanged .

liveInstanceCountChanged ()

This signal is emitted when the number of live instances managed by the AudioEngine 改变。

相应处理程序是 onLiveInstanceCountChanged .

ready ()

此信号发射当 AudioEngine is ready to use.

相应处理程序是 onReady .


方法文档编制

addAttenuationModel ( AttenuationModel attenuationModel )

添加给定 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);
    }
}
																		

addAudioCategory ( AudioCategory category )

添加给定 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);
    }
}
																			

addAudioSample ( AudioSample sample )

添加给定 sample to the engine. This can be used when the AudioSample is created dynamically:

import QtAudioEngine 1.1
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);
    }
}
																				

addSound ( Sound sound )

添加给定 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);
    }
}
																					

版权所有  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1