使用OpenAL将声音输出到特定通道7.1

时间:2013-02-19 14:07:03

标签: openal

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

谢谢,文森特。{     ALuint NorthWestSource;     ALint PlayStatus;

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;

}`

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。我想给左耳或右耳发音。到目前为止我找到的唯一方法是用声音为你生成立体声缓冲区(7.1缓冲区),然后用零覆盖另一个通道上的信息(...其他7个通道),然后再播放来自听众面前的来源。

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

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

干杯,

法里德