Beispiel #1
0
	void Flanger::setWaveformTriangle(bool value) {
		m_waveformTriangle = value;
		if (m_waveformTriangle) {
			alEffecti(m_effect, AL_FLANGER_WAVEFORM, AL_FLANGER_WAVEFORM_TRIANGLE);
		} else {
			alEffecti(m_effect, AL_FLANGER_WAVEFORM, AL_FLANGER_WAVEFORM_SINUSOID);
		}
	}
Beispiel #2
0
	void Chorus::setWaveformTriangle(bool value) {
		m_waveformTriangle = value;
		if (m_waveformTriangle) {
			alEffecti(m_effect, AL_CHORUS_WAVEFORM, AL_CHORUS_WAVEFORM_TRIANGLE);
		} else {
			alEffecti(m_effect, AL_CHORUS_WAVEFORM, AL_CHORUS_WAVEFORM_SINUSOID);
		}
	}
Beispiel #3
0
ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValues)
{
    ALCcontext *Context;

    Context = alcGetCurrentContext();
    SuspendContext(Context);

    if (effect && alIsEffect(effect))
    {
        ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);

        if(param == AL_EFFECT_TYPE)
        {
            alEffecti(effect, param, piValues[0]);
        }
        else if(ALEffect->type == AL_EFFECT_EAXREVERB)
        {
            switch(param)
            {
            case AL_EAXREVERB_DECAY_HFLIMIT:
                alEffecti(effect, param, piValues[0]);
                break;

            default:
                alSetError(AL_INVALID_ENUM);
                break;
            }
        }
        else if(ALEffect->type == AL_EFFECT_REVERB)
        {
            switch(param)
            {
            case AL_REVERB_DECAY_HFLIMIT:
                alEffecti(effect, param, piValues[0]);
                break;

            default:
                alSetError(AL_INVALID_ENUM);
                break;
            }
        }
        else if(ALEffect->type == AL_EFFECT_ECHO)
        {
            switch(param)
            {
            default:
                alSetError(AL_INVALID_ENUM);
                break;
            }
        }
        else
            alSetError(AL_INVALID_ENUM);
    }
    else
        alSetError(AL_INVALID_NAME);

    ProcessContext(Context);
}
Beispiel #4
0
// Thread: Any. Must be locked: AudioMutex.
bool CreatePlaybackDevice() {
	if (AudioDevice) return true;

	AudioDevice = alcOpenDevice(nullptr);
	if (!AudioDevice) {
		LOG(("Audio Error: Could not create default playback device, enumerating.."));
		EnumeratePlaybackDevices();
		return false;
	}

	ALCint attributes[] = {
		ALC_STEREO_SOURCES, 128,
		ALC_FREQUENCY, Media::Player::kDefaultFrequency,
		0
	};
	AudioContext = alcCreateContext(AudioDevice, attributes);
	alcMakeContextCurrent(AudioContext);
	if (ContextErrorHappened()) {
		DestroyPlaybackDevice();
		return false;
	}

	ALfloat v[] = { 0.f, 0.f, -1.f, 0.f, 1.f, 0.f };
	alListener3f(AL_POSITION, 0.f, 0.f, 0.f);
	alListener3f(AL_VELOCITY, 0.f, 0.f, 0.f);
	alListenerfv(AL_ORIENTATION, v);

#ifndef TDESKTOP_DISABLE_OPENAL_EFFECTS
	// playback speed related init
	// generate an effect slot and an effect
	alGenAuxiliaryEffectSlots(1, &_playbackSpeedData.uiEffectSlot);
	alGenEffects(1, &_playbackSpeedData.uiEffect);
	// initialize the pitch shifter effect
	alEffecti(_playbackSpeedData.uiEffect, AL_EFFECT_TYPE, AL_EFFECT_PITCH_SHIFTER);
	// 12 semitones = 1 octave
	alEffecti(_playbackSpeedData.uiEffect, AL_PITCH_SHIFTER_COARSE_TUNE, kPlaybackSpeedTune);
	// connect the effect with the effect slot
	alAuxiliaryEffectSloti(_playbackSpeedData.uiEffectSlot, AL_EFFECTSLOT_EFFECT, _playbackSpeedData.uiEffect);
	// initialize a filter to disable the direct (dry) path
	alGenFilters(1, &_playbackSpeedData.uiFilter);
	alFilteri(_playbackSpeedData.uiFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
	// disable all frequencies
	alFilterf(_playbackSpeedData.uiFilter, AL_LOWPASS_GAIN, 0.f);
	// to use the modified playback speed:
	// connect both the effect slot and filter with the stream source and set AL_PITCH
#endif // TDESKTOP_DISABLE_OPENAL_EFFECTS

	alDistanceModel(AL_NONE);

	return true;
}
Beispiel #5
0
	EaxReverb::EaxReverb() :
		m_density(1.0f),
		m_diffusion(1.0f),
		m_gain(0.32f),
		m_gainHf(0.89f),
		m_gainLf(0.0f),
		m_decayTime(1.49f),
		m_decayHfRatio(0.83f),
		m_decayLfRatio(1.0f),
		m_reflectionsGain(0.05f),
		m_reflectionsDelay(0.007f),
		m_reflectionsPan(AudioSpaceCoordinate(0.0, 0.0, 0.0)),
		m_lateReverbGain(1.26f),
		m_lateReverbDelay(0.011f),
		m_lateReverbPan(AudioSpaceCoordinate(0.0, 0.0, 0.0)),
		m_echoTime(0.25f),
		m_echoDepth(0.0f),
		m_modulationTime(0.25f),
		m_modulationDepth(0.0f),
		m_airAbsorptionGainHf(0.994f),
		m_hfReference(5000.0f),
		m_lfReference(250.0f),
		m_roomRolloffFactor(0.0f),
		m_decayHfLimit(true) {

		m_effectType = SE_EFFECT_EAXREVERB;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
	}
Beispiel #6
0
	ALboolean COALExtProvider::CreateEffect(ALuint *puiEffect, ALenum eEffectType)
	{
		if(!m_initialized) return AL_FALSE;

		ALboolean bReturn = AL_FALSE;
	
		if (puiEffect)
		{
			// Clear AL Error State
			alGetError();
	
			// Generate an Effect
			alGenEffects(1, puiEffect);
			if (alGetError() == AL_NO_ERROR)
			{
				// Set the Effect Type
				alEffecti(*puiEffect, AL_EFFECT_TYPE, eEffectType);
				if (alGetError() == AL_NO_ERROR)
					bReturn = AL_TRUE;
				else
					alDeleteEffects(1, puiEffect);
			}
		}
	
		return bReturn;
	}
Beispiel #7
0
	RingModulator::RingModulator() :
		m_frequency(440.0f),
		m_highpassCutoff(800.0f),
		m_waveform(0) {
		m_effectType = SE_EFFECT_RING_MODULATOR;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_RING_MODULATOR);
	}
Beispiel #8
0
	FrequencyShifter::FrequencyShifter() :
		m_frequency(0.0f),
		m_leftDirection(0),
		m_rightDirection(0) {
		m_effectType = SE_EFFECT_FREQUENCY_SHIFTER;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_FREQUENCY_SHIFTER);
	}
Beispiel #9
0
AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *values)
{
    ALCcontext *Context;
    ALCdevice  *Device;
    ALeffect   *ALEffect;

    switch(param)
    {
        case AL_EFFECT_TYPE:
            alEffecti(effect, param, values[0]);
            return;
    }

    Context = GetContextRef();
    if(!Context) return;

    Device = Context->Device;
    if((ALEffect=LookupEffect(Device, effect)) == NULL)
        alSetError(Context, AL_INVALID_NAME);
    else
    {
        /* Call the appropriate handler */
        V(ALEffect,setParamiv)(Context, param, values);
    }

    ALCcontext_DecRef(Context);
}
Beispiel #10
0
	Autowah::Autowah() :
		m_attackTime(0.06f),
		m_releaseTime(0.06f),
		m_resonance(1000.0f),
		m_peakGain(11.22f) {
		m_effectType = SE_EFFECT_AUTOWAH;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_AUTOWAH);
	}
Beispiel #11
0
	Echo::Echo() :
		m_delay(0.1f),
		m_lrDelay(0.1f),
		m_damping(0.5f),
		m_feedback(0.5f),
		m_spread(-1.0f) {
		m_effectType = SE_EFFECT_ECHO;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_ECHO);
	}
Beispiel #12
0
	Distortion::Distortion() :
		m_edge(0.2f),
		m_gain(0.05f),
		m_lowpassCutoff(8000.0f),
		m_eqCenter(3600.0f),
		m_eqBandwidth(3600.0f) {
		m_effectType = SE_EFFECT_DISTORTION;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_DISTORTION);
	}
Beispiel #13
0
	VocalMorpher::VocalMorpher() :
		m_phonemeA(0),
		m_phonemeB(10),
		m_phonemeCoarseA(0),
		m_phonemeCoarseB(0),
		m_waveform(0),
		m_rate(1.41f) {
		m_effectType = SE_EFFECT_VOCAL_MORPHER;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_VOCAL_MORPHER);
	}
Beispiel #14
0
	Flanger::Flanger() :
		m_waveformTriangle(true),
		m_phase(0),
		m_rate(0.27f),
		m_depth(1.0f),
		m_feedback(-0.5f),
		m_delay(0.002f) {
		m_effectType = SE_EFFECT_FLANGER;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_FLANGER);
	}
Beispiel #15
0
	Chorus::Chorus() :
		m_waveformTriangle(true),
		m_phase(90),
		m_rate(1.1f),
		m_depth(0.1f),
		m_feedback(0.25f),
		m_delay(0.016f) {
		m_effectType = SE_EFFECT_CHORUS;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_CHORUS);
	}
Beispiel #16
0
	Equalizer::Equalizer() :
		m_lowGain(1.0f),
		m_lowCutoff(200.0f),
		m_mid1Gain(1.0f),
		m_mid1Center(500.0f),
		m_mid1Width(1.0f),
		m_mid2Gain(1.0f),
		m_mid2Center(3000.0f),
		m_mid2Width(1.0f),
		m_highGain(1.0f),
		m_highCutoff(6000.0f) {
		m_effectType = SE_EFFECT_EQUALIZER;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_EQUALIZER);
	}
Beispiel #17
0
	Reverb::Reverb() :
		m_density(1.0f),
		m_diffusion(1.0f),
		m_gain(0.32f),
		m_gainHf(0.89f),
		m_decayTime(1.49f),
		m_decayHfRatio(0.83f),
		m_reflectionsGain(0.05f),
		m_reflectionsDelay(0.007f),
		m_lateReverbGain(1.26f),
		m_lateReverbDelay(0.011f),
		m_airAbsorptionGainHf(0.994f),
		m_roomRolloffFactor(0.0f),
		m_decayHfLimit(true) {

		m_effectType = SE_EFFECT_REVERB;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB);
	}
Beispiel #18
0
	ALboolean COALExtProvider::SetEFXEAXReverbProperties(EFXEAXREVERBPROPERTIES *pEFXEAXReverb, ALuint uiEffect)
	{
		if(!m_initialized) return AL_FALSE;

		ALboolean bReturn = AL_FALSE;
	
		if (pEFXEAXReverb)
		{
			// Clear AL Error code
			alGetError();
	
			alEffectf(uiEffect, AL_EAXREVERB_DENSITY, pEFXEAXReverb->flDensity);
			alEffectf(uiEffect, AL_EAXREVERB_DIFFUSION, pEFXEAXReverb->flDiffusion);
			alEffectf(uiEffect, AL_EAXREVERB_GAIN, pEFXEAXReverb->flGain);
			alEffectf(uiEffect, AL_EAXREVERB_GAINHF, pEFXEAXReverb->flGainHF);
			alEffectf(uiEffect, AL_EAXREVERB_GAINLF, pEFXEAXReverb->flGainLF);
			alEffectf(uiEffect, AL_EAXREVERB_DECAY_TIME, pEFXEAXReverb->flDecayTime);
			alEffectf(uiEffect, AL_EAXREVERB_DECAY_HFRATIO, pEFXEAXReverb->flDecayHFRatio);
			alEffectf(uiEffect, AL_EAXREVERB_DECAY_LFRATIO, pEFXEAXReverb->flDecayLFRatio);
			alEffectf(uiEffect, AL_EAXREVERB_REFLECTIONS_GAIN, pEFXEAXReverb->flReflectionsGain);
			alEffectf(uiEffect, AL_EAXREVERB_REFLECTIONS_DELAY, pEFXEAXReverb->flReflectionsDelay);
			alEffectfv(uiEffect, AL_EAXREVERB_REFLECTIONS_PAN, pEFXEAXReverb->flReflectionsPan);
			alEffectf(uiEffect, AL_EAXREVERB_LATE_REVERB_GAIN, pEFXEAXReverb->flLateReverbGain);
			alEffectf(uiEffect, AL_EAXREVERB_LATE_REVERB_DELAY, pEFXEAXReverb->flLateReverbDelay);
			alEffectfv(uiEffect, AL_EAXREVERB_LATE_REVERB_PAN, pEFXEAXReverb->flLateReverbPan);
			alEffectf(uiEffect, AL_EAXREVERB_ECHO_TIME, pEFXEAXReverb->flEchoTime);
			alEffectf(uiEffect, AL_EAXREVERB_ECHO_DEPTH, pEFXEAXReverb->flEchoDepth);
			alEffectf(uiEffect, AL_EAXREVERB_MODULATION_TIME, pEFXEAXReverb->flModulationTime);
			alEffectf(uiEffect, AL_EAXREVERB_MODULATION_DEPTH, pEFXEAXReverb->flModulationDepth);
			alEffectf(uiEffect, AL_EAXREVERB_AIR_ABSORPTION_GAINHF, pEFXEAXReverb->flAirAbsorptionGainHF);
			alEffectf(uiEffect, AL_EAXREVERB_HFREFERENCE, pEFXEAXReverb->flHFReference);
			alEffectf(uiEffect, AL_EAXREVERB_LFREFERENCE, pEFXEAXReverb->flLFReference);
			alEffectf(uiEffect, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, pEFXEAXReverb->flRoomRolloffFactor);
			alEffecti(uiEffect, AL_EAXREVERB_DECAY_HFLIMIT, pEFXEAXReverb->iDecayHFLimit);
	
			if (alGetError() == AL_NO_ERROR)
				bReturn = AL_TRUE;
		}
	
		return bReturn;
	}
Beispiel #19
0
void CEFX::CommitEffects()
{
	if (!supported)
		return;

	//! commit reverb properties
	for (std::map<ALuint, ALfloat>::iterator it = sfxProperties->properties_f.begin(); it != sfxProperties->properties_f.end(); ++it)
		alEffectf(sfxReverb, it->first, it->second);
	for (std::map<ALuint, ALint>::iterator it = sfxProperties->properties_i.begin(); it != sfxProperties->properties_i.end(); ++it)
		alEffecti(sfxReverb, it->first, it->second);
	for (std::map<ALuint, float3>::iterator it = sfxProperties->properties_v.begin(); it != sfxProperties->properties_v.end(); ++it)
		alEffectfv(sfxReverb, it->first, (ALfloat*)&it->second[0]);

	alEffectf(sfxReverb, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, sfxProperties->properties_f[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] * heightRolloffModifier);
	alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, sfxReverb);

	for (std::map<ALuint, ALfloat>::iterator it=sfxProperties->filter_properties_f.begin(); it != sfxProperties->filter_properties_f.end(); ++it)
		alFilterf(sfxFilter, it->first, it->second);

	updates++;
}
Beispiel #20
0
bool openal_init() {
	dev=alcOpenDevice(NULL);

	if(!dev)
		return true;

	ctx=alcCreateContext(dev,NULL);

	if(!ctx)
		return true;

	if(!alcMakeContextCurrent(ctx))
		return true;

	sound_init_extensions();
/*
	if(cvars["s_volume"]>100)
		cvars["s_volume"]=100;

	if(cvars["s_on"])
		alListenerf(AL_GAIN,float(cvars["s_volume"])/100);
	else
		alListenerf(AL_GAIN,0.0f);
*/
	alGenAuxiliaryEffectSlots(1,&uiEffectSlot);
	alGenEffects(1,&uiEffect);
	alEffecti(uiEffect,AL_EFFECT_TYPE,AL_EFFECT_REVERB);
	alAuxiliaryEffectSloti(uiEffectSlot,AL_EFFECTSLOT_EFFECT,uiEffect);

	alGenFilters(1,&uiFilter);
	alFilteri(uiFilter,AL_FILTER_TYPE,AL_FILTER_LOWPASS);
	alFilterf(uiFilter,AL_LOWPASS_GAIN,1.0f);
	alFilterf(uiFilter,AL_LOWPASS_GAINHF,0.1f);

	soundbuffers.push_back(new SoundBuffer("data/sfx/01.ogg"));
	soundbuffers.push_back(new SoundBuffer("data/sfx/02.ogg"));

	return false;
}
Beispiel #21
0
ALboolean QOpenALEngine::CreateEffect(ALuint *puiEffect, ALenum eEffectType)
{
    ALboolean bReturn = AL_FALSE;

    if (puiEffect)
    {
        // Clear AL Error State
        alGetError();

        // Generate an Effect
        alGenEffects(1, puiEffect);
        if (alGetError() == AL_NO_ERROR)
        {
            // Set the Effect Type
            alEffecti(*puiEffect, AL_EFFECT_TYPE, eEffectType);
            if (alGetError() == AL_NO_ERROR)
                bReturn = AL_TRUE;
            else
                alDeleteEffects(1, puiEffect);
        }
    }

    return bReturn;
}
Beispiel #22
0
CEFX::CEFX(ALCdevice* device)
	:enabled(false)
	,supported(false)
	,sfxProperties(NULL)
	,sfxSlot(0)
	,sfxReverb(0)
	,sfxFilter(0)
	,updates(0)
	,maxSlots(0)
	,maxSlotsPerSource(0)
{
	SetAirAbsorptionFactor(configHandler->GetFloat("snd_airAbsorption"));

	bool hasExtension = alcIsExtensionPresent(device, "ALC_EXT_EFX");

	if(hasExtension && alGenEffects && alDeleteEffects)
		supported = true;

	//! set default preset
	eaxPresets["default"] = eaxPresets[default_preset];

	//! always allocate this
	sfxProperties = new EAXSfxProps();
	*sfxProperties = eaxPresets[default_preset];

	if (!supported) {
		if(!hasExtension)
			LOG("  EFX Supported: no");
		else
			LOG("  EFX is supported but software does not seem to work properly");
		return;
	}

	//! clear log
	alGetError() ;

	//! Check Available Effects
	{
		static const ALuint effects[] = {
			AL_EFFECT_REVERB,
			AL_EFFECT_EAXREVERB,
			AL_EFFECT_CHORUS,
			AL_EFFECT_DISTORTION,
			AL_EFFECT_ECHO,
			AL_EFFECT_FLANGER,
			AL_EFFECT_FREQUENCY_SHIFTER,
			AL_EFFECT_VOCAL_MORPHER,
			AL_EFFECT_PITCH_SHIFTER,
			AL_EFFECT_RING_MODULATOR,
			AL_EFFECT_AUTOWAH,
			AL_EFFECT_COMPRESSOR,
			AL_EFFECT_EQUALIZER
		};

		ALuint alFx;
		alGenEffects(1, &alFx);
		if (alGetError() == AL_NO_ERROR) {
			for(size_t i = 0; i < sizeof(effects); i++) {
				const ALuint fx = effects[i];
				alEffecti(alFx, AL_EFFECT_TYPE, fx);
				effectsSupported[fx] = (alGetError() == AL_NO_ERROR);
			}
		}
		alDeleteEffects(1, &alFx);
	}

	//! Check Available Filters
	{
		static const ALuint filters[] = {
			AL_FILTER_LOWPASS,
			AL_FILTER_HIGHPASS,
			AL_FILTER_BANDPASS
		};

		ALuint alFilter;
		alGenFilters(1, &alFilter);
		if (alGetError() == AL_NO_ERROR) {
			for(size_t i = 0; i < sizeof(filters); i++) {
				const ALuint filter = filters[i];
				alFilteri(alFilter, AL_FILTER_TYPE, filter);
				filtersSupported[filter] = (alGetError() == AL_NO_ERROR);
			}
		}
		alDeleteFilters(1, &alFilter);
	}

	//! Check Max Available EffectSlots
	{
		int n;
		ALuint alFXSlots[128];
		for (n = 0; n < 128; n++) {
			alGenAuxiliaryEffectSlots(1, &alFXSlots[n]);
			if (alGetError() != AL_NO_ERROR)
				break;
		}
		maxSlots = n;

		alDeleteAuxiliaryEffectSlots(n, alFXSlots);
	}

	//! Check Max AUX FX SLOTS Per Sound Source
	alcGetIntegerv(device, ALC_MAX_AUXILIARY_SENDS, 1, (ALCint*)&maxSlotsPerSource);


	//! Check requirements
	if (!effectsSupported[AL_EFFECT_EAXREVERB]
		|| !filtersSupported[AL_FILTER_LOWPASS]
		|| (maxSlots<1)
		|| (maxSlotsPerSource<1)
	) {
		LOG_L(L_WARNING, "  EFX Supported: no");
		supported = false;
		return;
	}


	//! Create our global sfx enviroment
	alGenAuxiliaryEffectSlots(1, &sfxSlot);
	alGenEffects(1, &sfxReverb);
		alEffecti(sfxReverb, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
	alGenFilters(1, &sfxFilter);
		alFilteri(sfxFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
	if (!alIsAuxiliaryEffectSlot(sfxSlot) || !alIsEffect(sfxReverb) || !alIsFilter(sfxFilter)) {
		LOG_L(L_ERROR, "  Initializing EFX failed!");
		alDeleteFilters(1, &sfxFilter);
		alDeleteEffects(1, &sfxReverb);
		alDeleteAuxiliaryEffectSlots(1, &sfxSlot);
		supported = false;
		return;
	}


	//! Load defaults
	CommitEffects();
	if (!CheckError("  EFX")) {
		LOG_L(L_ERROR, "  Initializing EFX failed!");
		alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL);
		alDeleteFilters(1, &sfxFilter);
		alDeleteEffects(1, &sfxReverb);
		alDeleteAuxiliaryEffectSlots(1, &sfxSlot);
		supported = false;
		return;
	}

	//! User may disable it (performance reasons?)
	enabled = configHandler->GetBool("UseEFX");
	LOG("  EFX Enabled: %s", (enabled ? "yes" : "no"));
	if (enabled) {
		LOG_L(L_DEBUG, "  EFX MaxSlots: %i", maxSlots);
		LOG_L(L_DEBUG, "  EFX MaxSlotsPerSource: %i", maxSlotsPerSource);
	}

	configHandler->NotifyOnChange(this);
}
Beispiel #23
0
static ALvoid CDECL wine_alEffecti(ALuint eid, ALenum param, ALint value)
{
    alEffecti(eid, param, value);
}
Beispiel #24
0
	void PitchShifter::setCoarseTune(int16_t value) {
		value = std::min(value, int16_t(12));
		value = std::max(value, int16_t(-12));
		m_coarseTune = value;
		alEffecti(m_effect, AL_PITCH_SHIFTER_COARSE_TUNE, m_coarseTune);
	}
Beispiel #25
0
	void PitchShifter::setFineTune(int16_t value) {
		value = std::min(value, int16_t(50));
		value = std::max(value, int16_t(-50));
		m_fineTune = value;
		alEffecti(m_effect, AL_PITCH_SHIFTER_FINE_TUNE, m_fineTune);
	}
Beispiel #26
0
	void RingModulator::setWaveform(uint8_t value) {
		value = std::min(value, uint8_t(2));
		value = std::max(value, uint8_t(0));
		m_waveform = value;
		alEffecti(m_effect, AL_RING_MODULATOR_WAVEFORM, m_waveform);
	}
Beispiel #27
0
AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValues)
{
    ALCcontext *Context;
    ALCdevice  *Device;
    ALeffect   *ALEffect;

    Context = GetContextSuspended();
    if(!Context) return;

    Device = Context->Device;
    if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
    {
        if(param == AL_EFFECT_TYPE)
        {
            alEffecti(effect, param, piValues[0]);
        }
        else if(ALEffect->type == AL_EFFECT_EAXREVERB)
        {
            switch(param)
            {
            case AL_EAXREVERB_DECAY_HFLIMIT:
                alEffecti(effect, param, piValues[0]);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
            }
        }
        else if(ALEffect->type == AL_EFFECT_REVERB)
        {
            switch(param)
            {
            case AL_REVERB_DECAY_HFLIMIT:
                alEffecti(effect, param, piValues[0]);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
            }
        }
        else if(ALEffect->type == AL_EFFECT_ECHO)
        {
            switch(param)
            {
            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
            }
        }
        else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
        {
            switch(param)
            {
            case AL_RING_MODULATOR_FREQUENCY:
            case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
            case AL_RING_MODULATOR_WAVEFORM:
                alEffecti(effect, param, piValues[0]);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
            }
        }
        else
            alSetError(Context, AL_INVALID_ENUM);
    }
    else
        alSetError(Context, AL_INVALID_NAME);

    ProcessContext(Context);
}
int main (int argc, char **argv) {

    #pragma region // --- my init ---
    float pitchnow = 1.0;
    alListener3f(AL_POSITION, 0.0, 0.0, 0.0);

    #pragma endregion

    #pragma region // --- al init ---
// alut の初期化

    alutInit (&argc, argv);

// Hello World としゃべる音声の作成
    ALuint helloBuffer = alutCreateBufferHelloWorld();
    ALuint MusicBuffer = alutCreateBufferFromFile(FILENAME);
    if(AL_NONE == helloBuffer) {
        std::cerr<<"error:nofile"<<std::endl;
        exit(1);
    }

// ソースの作成
    ALuint helloSource;
    alGenSources (1, &helloSource);
    ALuint MusicSource;
    alGenSources (1, &MusicSource);


// ソースにバッファをバインド
    alSourcei (helloSource, AL_BUFFER, helloBuffer);
    alSourcei (MusicSource, AL_BUFFER, MusicBuffer);
    #pragma endregion

    #pragma region // --- effect init ---

    ALCdevice *pDevice = alcOpenDevice(NULL);
    if(!pDevice) {
        std::cerr<<"error : device not found"<<std::endl;
        exit(1);
    }

    LPALGENEFFECTS alGenEffects=(LPALGENEFFECTS)alGetProcAddress("alGenEffects");


    #pragma region // --- set Reverb ---
    ALuint Effect = 0;
    alGenEffects(1, &Effect);
    alEffecti(Effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB);

    #pragma endregion


    #pragma endregion

    cv::namedWindow("hoge");
    alSourcePlay(MusicSource);

    alSource3f(MusicSource, AL_POSITION, 100.0, 0.0, 0.0);
    alSource3f(MusicSource, AL_VELOCITY, 10.0, 0.0, 0.0);

    while(1) {

        char key = cv::waitKey(1);
        if(key=='s') {
            alSourcePlay(helloSource);
            //alutSleep(1);
        }
        if(key == 'p') {
            int state;
            alGetSourcei(MusicSource, AL_SOURCE_STATE, &state);
            if(state ==AL_PAUSED)alSourcePlay(MusicSource);
            else alSourcePause(MusicSource);
        }
        else if(key == 'q') {
            std::cout<<"good bye"<<std::endl;
            break;
        }
        else if(key == 'u') {
            pitchnow *= 2;
            alSourcef(MusicSource, AL_PITCH, pitchnow);
        }
        else if(key == 'd') {
            pitchnow /= 2;
            alSourcef(MusicSource, AL_PITCH, pitchnow);
        }

        // roop
        int state;
        alGetSourcei(MusicSource, AL_SOURCE_STATE, &state);
        if(state != AL_PLAYING) alSourcePlay(MusicSource);

    }


    #pragma region --- release ---
    // リソースを開放
    alSourceStop(helloSource);
    alDeleteSources( 1, &helloSource );
    alDeleteBuffers( 1, &helloBuffer );
    alSourceStop(MusicSource);
    alDeleteSources( 1, &MusicSource );
    alDeleteBuffers( 1, &MusicBuffer );
    alutExit ();
    #pragma endregion

    return 0;
}
Beispiel #29
0
	Compressor::Compressor() :
		m_active(true) {
		m_effectType = SE_EFFECT_COMPRESSOR;
		alEffecti(m_effect, AL_EFFECT_TYPE, AL_EFFECT_COMPRESSOR);
	}
Beispiel #30
0
	void Compressor::setCompressor(bool value) {
		m_active = value;
		alEffecti(m_effect, AL_COMPRESSOR_ONOFF, m_active ? AL_TRUE : AL_FALSE);
	}