Не могу услышать пространственное аудио - PullRequest
0 голосов
/ 09 апреля 2019

Я хочу создать небольшой пример с одноигровой игрой и FMOD coreApi (fmod 2.0) для воспроизведения трехмерного пространственного звука с использованием плагина для резонансного звука от Google

Но у меня проблемы с применением пространственного эффекта к источнику звука. Я могу слышать это правильно, но без какого-либо эффекта панорамирования / hrtf.

Плагин загружается правильно, и я могу загрузить / применить DSP к группам каналов, но все работает.

Я использую заголовки c # fmod, чтобы использовать библиотеку (работает нормально) и помещаю весь код в игровой класс Monogame. Это код моего класса

код:

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using FMOD;
using System;

namespace game1_with_fmod_wrapper
{
    /// <summary>
    /// This is the main type for your game.
    /// </summary>
    public class Game1 : Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        FMOD.System fmod;
        ChannelGroup masterChannel;
        ChannelGroup world3DChannel;
        uint raHandle;
        uint ralistenerHandle;
        uint raSourceHandle;
        DSP listenerDSP;
        VECTOR listenerPos = new VECTOR { x = 10, y = 0, z = -5 };
        VECTOR listenerVel = new VECTOR { x = 0, y = 0, z = 0 };
        VECTOR listenerForward = new VECTOR { x = 0, y = 0, z = 1 };
        VECTOR listenerUp = new VECTOR { x = 0, y = 1, z = 0 };

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            FMOD.Factory.System_Create(out fmod);
            fmod.init(1024, INITFLAGS.NORMAL,(IntPtr)OUTPUTTYPE.AUTODETECT);
            fmod.getMasterChannelGroup(out masterChannel);
            fmod.createChannelGroup("world", out world3DChannel);
            FMOD.RESULT ldpluginresult = fmod.loadPlugin("plugins/resonanceaudio.dll", out raHandle);

            fmod.getNestedPlugin(raHandle, 0, out ralistenerHandle);
            fmod.getNestedPlugin(raHandle, 2, out raSourceHandle);
            fmod.createDSPByPlugin(ralistenerHandle, out listenerDSP);
            world3DChannel.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.TAIL,listenerDSP);
            fmod.set3DNumListeners(1);
            fmod.set3DListenerAttributes(0,ref listenerPos, ref listenerVel, ref listenerForward, ref listenerUp);


            base.Initialize();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Sound jumpsound;
            fmod.createSound("grito.wav",  MODE._3D| MODE.LOOP_NORMAL, out jumpsound);
            Channel jumpchannel;
            fmod.playSound(jumpsound, world3DChannel,paused: true,channel: out jumpchannel);
            fmod.createDSPByPlugin(raSourceHandle, out DSP sourceDSP);
            jumpchannel.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.TAIL, sourceDSP);

            VECTOR pos = new VECTOR { x = 30, y = 0, z = 0 };
            VECTOR vel = new VECTOR { x = 0, y = 0, z = 0 };
            jumpchannel.set3DAttributes(ref pos, ref vel);
            jumpchannel.setPaused(false);






            // TODO: use this.Content to load your game content here
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// game-specific content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
            fmod.release();

        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();

            // TODO: Add your update logic here
            fmod.update();
            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }
    }
}

Что не так в коде?

Ваша помощь будет очень признательна;)

Я тоже писал этот вопрос на форумах fmod, но мне не повезло

Ссылка на тему: https://qa.fmod.com/t/c-unable-to-ear-spatialiced-audio-using-coreapi-and-resonanceaudio/14546

Спасибо!

...