2013-02-19 28 views
1

。 我有一个项目需要通过X-Fi声卡与A/V接收器连接。 A/V接收器连接到7.1扬声器系统。我想知道开始和结束的方式来分别访问每个7.1声道,以便我可以将飞机驾驶舱信息导入模拟器。我使用OpenAL并使用C语言编写代码。我开发了一些代码,我认为应该这样做,但是我在其他6个扬声器上播放了音频流血。以下是我已经编写的一些代码的示例。我希望有人能帮助我。使用OpenAL将声音输出到特定频道的全部7.1

谢谢,Vincent.` { 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; 

}`

回答

0

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

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

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

干杯,

法里德