void Quit() { StopMusic(); alureUpdateInterval(0); alureSleep(0.1f); alureShutdownDevice(); }
bool initSoundStuff (HWND hwnd) { if(!alureInitDevice(NULL, NULL)) { debugOut( "Failed to open OpenAL device: %s\n", alureGetErrorString()); return 1; } int a; for (a = 0; a < MAX_SAMPLES; a ++) { soundCache[a].stream = NULL; soundCache[a].playing = false; soundCache[a].fileLoaded = -1; soundCache[a].looping = false; intpointers[a] = a; } for (a = 0; a < MAX_MODS; a ++) { modCache[a].stream = NULL; modCache[a].playing = false; } if (! alureUpdateInterval(0.01)) { debugOut("Failed to set Alure update interval: %s\n", alureGetErrorString()); return 1; } return soundOK = true; }
void audio_off() { if(!alureUpdateInterval(0.0)) err("audio_off", "could not stop"); if(!loaded_sounds.empty()) for(std::vector<ALuint>::iterator i = loaded_sounds.begin(); i != loaded_sounds.end(); i++) { alSourcei(*i, AL_BUFFER, 0); alDeleteSources(1, &(*i)); } if(!loaded_buffers.empty()) for(std::vector<ALuint>::iterator i = loaded_buffers.begin(); i != loaded_buffers.end(); i++) alDeleteBuffers(1, &(*i)); alureShutdownDevice(); }
bool audio_on() { if(!alureInitDevice(NULL, NULL)) { err("audio", "could not initiate"); return false; } fluid_set_log_function(FLUID_WARN, dumberror, NULL); fluid_set_log_function(FLUID_ERR, dumberror, NULL); fluid_set_log_function(FLUID_INFO, dumberror, NULL); fluid_set_log_function(FLUID_DBG, dumberror, NULL); alureUpdateInterval(0.05); atexit(audio_off); alure_state = 1; return true; }
void Init(int frequency, int resolution, int sources) { (void)resolution; --sources; // one spare source for music ALCint attribs[] = { ALC_FREQUENCY, frequency, /*ALC_MONO_SOURCES, sources, ALC_STEREO_SOURCES, 1,*/ 0 }; alureInitDevice(NULL, attribs); soundSources = new ALuint[sources]; alGenSources(sources, soundSources); alGenSources(1, &musicSource); //alGenBuffers(2, musicBufs); soundSourceCount = sources; alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); alSpeedOfSound(1400.0); alDopplerFactor(0.7); alureUpdateInterval(0.03333f); }
void Init(int frequency, int resolution, int sources) { (void)resolution; --sources; // one spare source for music ALCint attribs[] = { ALC_FREQUENCY, frequency, /*ALC_MONO_SOURCES, sources, ALC_STEREO_SOURCES, 1,*/ 0 }; if (AL_FALSE == alureInitDevice(NULL, attribs)) { LOG("Sound", LOG_ERROR, "ALURE init failure"); exit(1); } soundSources = new ALuint[sources]; alGenSources(sources, soundSources); alGenSources(1, &musicSource); alGenBuffers(2, musicBufs); soundSourceCount = sources; alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); alSpeedOfSound(1400.0); alDopplerFactor(0.7); alureUpdateInterval(0.03333f); #ifndef NDEBUG if (alGetError()) LOG("Sound", LOG_ERROR, "OpenAL init failure"); const ALchar* err = alureGetErrorString(); if (strcmp(err, "No error")) { LOG("Sound", LOG_ERROR, "ALURE init failure: %s", err); exit(1); } #endif }
int main () { if (!alureInitDevice(NULL, NULL)) { std::fprintf(stderr, "Failed to open OpenAL device: %s\n", alureGetErrorString()); return 1; } alGenSources(1, &src); if (alGetError() != AL_NO_ERROR) { std::fprintf(stderr, "Failed to create OpenAL source!\n"); alureShutdownDevice(); return 1; } // Seeting Blip Buffer synth.treble_eq( -18.0f ); synth.volume (0.80); synth.output (&blipbuf); // Init Blip Buffer with a buffer of 250ms (second paramter is time in ms) if ( blipbuf.set_sample_rate( SR, 1000 / 4 ) ) { std::fprintf(stderr, "Failed to create Blip Buffer! Our of Memory\n"); alureShutdownDevice(); return 1; } blipbuf.clock_rate( blipbuf.sample_rate() ); blipbuf.bass_freq(300); // Equalization like a TV speaker stream = alureCreateStreamFromCallback (StreamCB, nullptr, AL_FORMAT_MONO16, SR, SR/2, 0, nullptr); if(!stream) { std::fprintf(stderr, "Error creating stream! %s\n", alureGetErrorString()); alDeleteSources(1, &src); alureShutdownDevice(); return 1; } if (!alurePlaySourceStream(src, stream, 4, 0, eos_callback, NULL)) { std::fprintf(stderr, "Failed to play stream: %s\n", alureGetErrorString()); isdone = 1; } alureUpdateInterval(0.005f); // Should be a independint thread playing the stream while(!isdone) { freq -= 1; if (freq < 1) { freq = 600; } alureSleep(0.02f); } alureStopSource(src, AL_FALSE); alDeleteSources(1, &src); alureDestroyStream(stream, 0, NULL); alureShutdownDevice(); return 0; }
static void deinit_alure(void) { alureUpdateInterval(0.0f); DeleteCriticalSection(&cs_StreamPlay); }