5

我正在编写游戏的音频部分,并且正在使用 OpenAL。我想使用一些扩展,但测试总是失败:

TRACE: AudioManager - Sound device: 'Generic Software'
TRACE: AudioManager - Enabling OpenAL extensions...
TRACE: AudioManager - Compressor support: NO
TRACE: AudioManager - Reverb support: YES
TRACE: AudioManager - Chorus support: NO
TRACE: AudioManager - Distortion support: NO
TRACE: AudioManager - Echo support: NO
TRACE: AudioManager - Flanger support: NO
TRACE: AudioManager - Frequency shifter support: NO
TRACE: AudioManager - Vocal morpher support: NO
TRACE: AudioManager - Pitch shifter support: NO
TRACE: AudioManager - Ring modulator support: NO
TRACE: AudioManager - AutoWAH support: NO
TRACE: AudioManager - Equalizer support: NO
TRACE: AudioManager - EAX Reverb support: YES

这是因为我只得到了Generic Software驱动,它只支持混响和EAX混响。不仅在我的机器上,在其他机器上也是如此。

以下是我检测 OpenAL 使用的驱动程序的方法:

ALchar device[256];
ZeroMemory(device, 256);
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT"))
{
    strcpy_s(device, 256, alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER));
}
else if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"))
{
    strcpy_s(device, 256, alcGetString(NULL, ALC_DEVICE_SPECIFIER));
}

TRACE_AUDIOMANAGER("Sound device: '%s'", device);

g_System = alcOpenDevice(device);

根据规范,设备说明符应返回两个驱动程序:“通用硬件”和“通用软件”,由 NULL 终止符分隔。

我的声卡是使用 nvhda32v.sys 驱动程序(版本 1.0.0.63,2009 年 11 月 11 日更新)的“NVIDIA 高清音频”设备。

为什么 OpenAL 检测不到我的硬件?

4

4 回答 4

2

OpenAL 应始终返回默认音频设备,除非您使用的是 Creative 声卡。这些扩展都是特定于广告素材的。这与期望在 NVIDIA 显卡上获得 Intel 特定的 OpenGL 扩展相同。

作为记录,以下是您设置 OpenAL 的方式:

// create a default device
ALCdevice* device = alcOpenDevice("");
if (!device)
{
    LOG_ERROR("Could not create OpenAL device.");
    return false;
}

// context attributes, 2 zeros to terminate 
ALint attribs[6] = {
    0, 0
};

ALCcontext* context = alcCreateContext(device, attribs);
if (!context)
{
    LOG_ERROR("Could not create OpenAL context.");
    alcCloseDevice(device);
    return false;
}

if (!alcMakeContextCurrent(context))
{
    LOG_ERROR("Could not enable OpenAL context.");
    alcDestroyContext(context);
    alcCloseDevice(device);
    return false;
}

LOG_INFO("[OpenAL] Version: %s", alGetString(AL_VERSION));
LOG_INFO("[OpenAL] Vendor: %s", alGetString(AL_VENDOR));
LOG_INFO("[OpenAL] Renderer: %s", alGetString(AL_RENDERER));
于 2012-06-12T10:13:18.440 回答
1

你确定你检查下一个字符串,因为alcGetString(NULL, ALC_DEVICE_SPECIFIER)返回字符串数组,试试这样:

char* devices = (char*)alcGetString(NULL, ALC_DEVICE_SPECIFIER);
while(devices && *devices !=NULL)
{
    ALCdevice* device = alcOpenDevice(devices);
    ...
    ...
    devices += strlen(devices) + 1; //next device
}
于 2010-07-29T00:54:00.910 回答
1

对于那些仍在寻找获取所有设备的方法的人//除了输出 - 仍然是通用的,适用于输入//

公共:int* CHECK_DEVICES_IN(int MAX_DEVICES) { int devices=0; char* 设备[MAX_DEVICES]; 整数检查=0;while(devices<=MAX_DEVICES&&checked } checked++; } return devices; /* int returned=0; while(returned

  public:ALchar* DEVICES_IN(int REQUIRED)
   { ALchar* result="0";
     ALchar* device=(ALchar*)alcGetString(NULL,ALC_CAPTURE_DEVICE_SPECIFIER);
     int POS=0;
     while(device && device!=NULL && strlen(device)>0 && POS<=REQUIRED)
      { if(POS==REQUIRED)
         { result=device; }
        device+=strlen(device)+1;
        POS++; 
      }
     return result;
   }
于 2014-11-03T17:45:15.563 回答
0

Vista 上没有“通用硬件”设备:http ://connect.creativelabs.com/openal/OpenAL%20Wiki/OpenAL%C2%AE%20and%20Windows%20Vista%E2%84%A2.aspx

干杯!

于 2010-08-03T07:36:46.543 回答