void PORT_SetFloatValue(void* controlIDV, float value) {
    PortControl* portControl = (PortControl*) controlIDV;

    if (portControl != NULL) {
        if (portControl->controlType == CONTROL_TYPE_VOLUME) {
            switch (portControl->channel) {
            case CHANNELS_MONO:
                setRealVolume(portControl, SND_MIXER_SCHN_MONO, value);
                break;

            case CHANNELS_STEREO:
                setFakeVolume(portControl, value, getFakeBalance(portControl));
                break;

            default:
                setRealVolume(portControl, portControl->channel, value);
            }
        } else if (portControl->controlType == CONTROL_TYPE_BALANCE) {
            if (portControl->channel == CHANNELS_STEREO) {
                setFakeVolume(portControl, getFakeVolume(portControl), value);
            } else {
                ERROR0("PORT_SetFloatValue(): Balance only allowed for stereo channels!\n");
            }
        } else {
            ERROR1("PORT_SetFloatValue(): inappropriate control type: %s!\n",
                   portControl->controlType);
        }
    }
}
/*
 * sets the unsigned values for left and right volume according to
 * the given volume (0...1) and balance (-1..0..+1)
 */
static void setFakeVolume(PortControl* portControl, float vol, float bal) {
    float volumeLeft;
    float volumeRight;

    if (bal < 0.0f) {
        volumeLeft = vol;
        volumeRight = vol * (bal + 1.0f);
    } else {
        volumeLeft = vol * (1.0f - bal);
        volumeRight = vol;
    }
    setRealVolume(portControl, SND_MIXER_SCHN_FRONT_LEFT, volumeLeft);
    setRealVolume(portControl, SND_MIXER_SCHN_FRONT_RIGHT, volumeRight);
}
Esempio n. 3
0
bool SIDInfo::setVolume(long val)
{
	if (!hasVolume || !_sid || globalMax < 1) return false;

	if (val > 0) _isEmulMuted = false;

	return setRealVolume(val*(max-min)/globalMax);
}
Esempio n. 4
0
bool SIDInfo::setEmulMute(bool mute)
{
	if (!hasVolume || !_sid) return false;

	snd_mixer_elem_t* elem = snd_mixer_find_selem(_handle, _sid);

	if (!elem) return false;

	if (mute == _isEmulMuted) return true;

	if (mute)
	{
		_isEmulMuted = true;
		_lastVol = getRealVolume();
		return setRealVolume(min);
	}
	else
	{
		_isEmulMuted = false;
		bool ret = setRealVolume(_lastVol);
		_lastVol = min;
		return ret;
	}
}