1

全部。我有一个项目需要通过 X-Fi 声波卡与 A/V 接收器连接。A/V 接收器连接到 7.1 扬声器系统。我想知道从头到尾分别访问每个 7.1 频道的方式,以便我可以在模拟器中引导飞机驾驶舱信息。我正在使用 OpenAL 并且正在用 C 编写此代码。我已经开发了一些我认为应该可以解决问题的代码,但是我在其他 6 个扬声器上得到了音频传输。下面是我已经编写的一些代码的示例。我希望有人可以在这里帮助我。

谢谢,文森特。`{ ALuint NorthWestSource; ALint 播放状态;

switch (event)
{
    case EVENT_COMMIT:
        //Load user selected .wav file into the buffer that is initialized here, "InitBuf".
        LoadDotWavFile();        

        //Generate a source, attach buffer to source, set source position, and play sound.
        alGenSources(NumOfSources, &NorthWestSource);      
        ErrorCheck();

        //Attach the buffer that contains the .wav file's data to the source. 
        alSourcei(NorthWestSource, AL_BUFFER, WavFileDataBuffer);
        ErrorCheck();

        //Set source's position, velocity, and orientation/direction.
        alSourcefv(NorthWestSource, AL_POSITION, SourcePosition);
        ErrorCheck();
        alSourcefv(NorthWestSource, AL_VELOCITY, SourceVelocity);
        ErrorCheck();
        alSourcefv(NorthWestSource, AL_DIRECTION, SourceDirectionNorthWest);
        ErrorCheck();
        alSourcei(NorthWestSource, AL_SOURCE_RELATIVE, AL_TRUE);
        ErrorCheck();
        alSourcei(NorthWestSource, AL_CONE_INNER_ANGLE, 180);
        ErrorCheck();
        alSourcei(NorthWestSource, AL_CONE_OUTER_ANGLE, 270);
        ErrorCheck();
        SetCtrlVal(panelHandle, PANEL_SOURCEISSET, 1);

        //Play the user selected file by playing the sources.
        alSourcePlay(NorthWestSource);
        ErrorCheck();

        //Check that the .wav file has finished playing and if so clean things up.
        do
        {
            alGetSourcei(NorthWestSource, AL_SOURCE_STATE, &PlayStatus);
            if(PlayStatus != AL_PLAYING)
            {
                printf("File done playing. \n");
            }//End do-while if statement
        }
        while(PlayStatus == AL_PLAYING);

        //Clean things up more before exiting out of this audio projection.
        alDeleteSources(NumOfSources, &NorthWestSource);
        ErrorCheck();
        alDeleteBuffers(NumOfBuffers, &WavFileDataBuffer);
        ErrorCheck();
        SetCtrlVal(panelHandle, PANEL_SOURCEISSET, 0);
        //alDeleteBuffers(NumOfBuffers, 
        break;
}
return 0;

}`

4

1 回答 1

0

我面临同样的问题。我想向左耳或右耳播放音调。到目前为止,我发现的唯一方法是用声音产生一个立体声缓冲区(为您提供 7.1 缓冲区),然后用零覆盖另一个通道(......为您提供的其他 7 个通道)上的信息,然后播放它来自听者面前的来源。

这是我的解决方法。我知道这很笨拙。但是,如果您想留在 openAL 中并避免直接使用 ALSA(对于 Linux)或 CoreAudio(对于 Mac)进行编程,我还没有找到更好的方法。

更直接地回答您的问题:不,似乎没有直接的说法(正如我所希望的那样):“3号演讲者说'Hello World'!所有其他演讲者保持沉默。”

干杯,

法里德

于 2014-02-17T18:08:55.003 回答