【问题标题】:Surrounding 3d sound effects using howler.js or another library?使用 howler.js 或其他库环绕 3d 音效?
【发布时间】:2019-07-19 12:27:07
【问题描述】:

我正在做一个项目,我需要添加 3d 音效,就像声音在听者音效中不断移动一样。是否有可能使用 howlerjs 来实现这一点,我看到使用 howler 我可以从特定坐标/方向播放声音,但是如何实现环绕声/ambisonics 声音? 或者其他 JavaScript 库来实现这一点?

感谢您的帮助。

【问题讨论】:

    标签: javascript audio 3d surround


    【解决方案1】:

    晚了半年,但是是的,这在 howler.js 中是完全可能的,我自己没有使用过,但从文档来看,你可以更新位置。我发现还有更多的库可以做到这一点,请在此处查看 3dage 如何完全满足您的要求: https://codepen.io/naugtur/pen/QgmvOB?editors=1010

      var world = IIIdage.World({
        tickInterval: 200
      })
    
      var annoyingFly = IIIdage.Thing({
        is: ['fly'],
        sounds: {
          'buzzing constantly': {
            sound: 'buzz',
            times: Infinity
          }
        },
        reacts: [
          {
            // to: world.random.veryOften(),
            to: world.time.once(),
            with: 'buzzing constantly'
          }
        ]
      })
    
    // scene should create and expose a default world or accept one
      var scene = IIIdage.Scene({
        title: 'Annoying fly',
        library: {
          sounds: {
            'buzz': {
              src: ['https://webaudiogaming.github.io/3dage/fly.mp3']
            }
          }
        },
        world: world,
        things: [ // scene iterates all things and spawns them into the world. same can be done manually later on.
          annoyingFly({
            pos: [-1, -15, 0],
            dir: [1, 0, 0],
            v: 1
          })
        ]
      }).load().run()
    
    
      setTimeout(function () {
        scene.dev.trace(IIIdage.dev.preview.dom())
      }, 500)
    
    
      setInterval(function rotateVector() {
        var angleRad = 0.15
        var d=scene.things[0].attributes.dir
        var x=d[0], y=d[1]
        var cosAngle = Math.cos(angleRad), sinAngle = Math.sin(angleRad)
    
        scene.things[0].attributes.dir = [x * cosAngle - y * sinAngle,  y * cosAngle + x * sinAngle, 0]
      }, 500)
    
      window.scene = scene
    

    还有一些其他人做类似的事情:

    如果您仍然需要帮助,希望这能将您推向正确的方向。

    【讨论】:

      猜你喜欢
      • 2021-01-07
      • 1970-01-01
      • 2018-02-12
      • 2010-09-09
      • 2014-11-03
      • 1970-01-01
      • 1970-01-01
      • 2013-06-24
      • 1970-01-01
      相关资源
      最近更新 更多