Exemplo n.º 1
0
NSoundSystem::NSoundSystem()
{
    ALCsizei Count;
    const char** DeviceNames = alureGetDeviceNames(true,&Count);
    for (int i=0;i<Count;i++)
    {
        GetGame()->GetLog()->Send("ALURE",2,std::string("Found device: ") + DeviceNames[i] + ".");
    }
    bool Found = false;
    for (int i=0;i<Count;i++)
    {
        if (alureInitDevice(DeviceNames[0],NULL) != AL_FALSE)
        {
            GetGame()->GetLog()->Send("ALURE",2,std::string("Using device: ") + DeviceNames[0] + ".");
            Found = true;
            break;
        }
    }
    if (!Found)
    {
        GetGame()->GetLog()->Send("ALURE",0,"Failed to use any sound devices!");
        alureFreeDeviceNames(DeviceNames);
        return;
    }
    alureFreeDeviceNames(DeviceNames);
    alListener3f(AL_POSITION,0,0,0);
    alListener3f(AL_VELOCITY,0,0,0);
    alListener3f(AL_ORIENTATION,0,0,-1);
}
Exemplo n.º 2
0
int is::Audio::init() {
    // Grab available devices and print them.
    int deviceCount;
    const char** deviceNames = alureGetDeviceNames( true, &deviceCount );
    if ( !deviceCount ) {
        os->printf( "ERR OpenAL failed to find any usable devices for audio playback!\n" );
        alureFreeDeviceNames( deviceNames );
        audio->checkErrorSimple();
        return 1;
    }
    os->printf( "INF OpenAL detected the following devices for audio:\n" );
    for ( int i=0; i<deviceCount; i++ ) {
        os->printf( "INF     %.\n", deviceNames[i] );
    }

    // Attempt to use any device starting from the first.
    int i = 0;
    while ( alureInitDevice( deviceNames[i], NULL ) == AL_FALSE && i < deviceCount ) {
        audio->checkErrorSimple();
        i++;
    }
    if ( i == deviceCount ) {
        os->printf( "ERR OpenAL failed to find any usable devices for audio playback!\n" );
        alureFreeDeviceNames( deviceNames );
        return 1;
    }
    os->printf( "INF OpenAL: Using %.\n", deviceNames[i] );
    alureFreeDeviceNames( deviceNames );

    // Initialize the listener
    alListener3f( AL_POSITION, 0.f, 0.f, 0.f );
    alListener3f( AL_VELOCITY, 0.f, 0.f, 0.f );
    float ori[6] = {
        0, 0, -1,
        0, 1, 0 };
    alListenerfv( AL_ORIENTATION, ori );
    audio->checkErrorSimple();

    lua->doFolder( "data/sounds" );
    return 0;
}