[Scummvm-devel] Audio volume control (proposed mixer/imuse/... changes)
Max Horn
max at quendi.de
Sun Nov 28 12:27:01 CET 2004
Am 28.11.2004 um 20:11 schrieb Pawel Kolodziejski:
>> * IMuseDigital does its own volume effects, based on these three types
>> of audio data
>
> that three volumes are as addons to volume control, and they are need
> to
> be between imuse volume control(initial sound volume, fades) and mixer
> master volume. effective "type" volume level is independent of imuse(i
> mean, it not cause change internal imuse volume logic). volGroupId
> tell to
> what mixer channel sound belongs. imuse should only tell to mixer what
> volume level is for each volume group.
> path for scumm sound volume control:
> scumm script volume level -> imuse(control sample volume level, fades)
> ->
> attach and set volume level of groups(master(should be, compared to
> original imuse, not as in scummvm exist), music, sfx, voice) -> mixer.
.....
I am afraid I only understood 30% or less of what you wrote there,
Pawel :-/. And I am not sure whether you just tried to describe the
current situation in SCUMM/iMuse, or whether you wanted to point out a
fundamental problem with my suggestion or something like that...
Anyway, first thing: I looked at the iMuseDigital code before I wrote
my original mail, and I am pretty sure that modifying it to make use of
my proposed changes would be trivial.
Essentially, iMuseDigital already divides sound data into three (or
really: four) groups:
- sfx
- muxic
- speech
- none / global (group 0)
And that matches exactly with my proposal. For iMuseDigital, the main
visible change would be that the sfx/music/speech volume effect would
not be done inside iMuseDigital anymore, but rather inside the mixer.
Consider this code fragment (from dimuse.cpp):
int vol = track->vol / 1000;
if (track->volGroupId == 1)
vol = (vol * _volVoice) / 128;
if (track->volGroupId == 2)
vol = (vol * _volSfx) / 128;
if (track->volGroupId == 3)
vol = (vol * _volMusic) / 128;
track->mixerVol = vol;
This would probably end up looking like this:
if (track->volGroupId == 1)
track->audioType = SoundMixer::kSpeechAudioDataType;
else if (track->volGroupId == 2)
track->audioType = SoundMixer::kSFXAudioDataType;
else if (track->volGroupId == 3)
track->audioType = SoundMixer::kMusicAudioDataType;
track->mixerVol = track->vol / 1000;
and then later, the value of track->audioType would be passed to
SoundMixer::playInputStream.
[...]
>> * the data is then volume-scaled based on the volume set for that type
> i don't understand that sentence the same as next to next below point.
What I mean is this: sound data which is marked as being of type "SFX"
will be subjected to the "SFX volume" set in the mixer; music data will
be subjected to the "music volume"; speech data by the "speech volume".
And data of type "none" will not be changed at all.
After all that, we can (optionally) also apply a master volume, should
we choose to do so (this corresponds to the current "global" volume
setting in the mixer).
>> * type "none" is not volume scaled at all, which still allows engines
>> to do their own volume effects if needed
> sounds good for me, as kind additional "option"
It corresponds to volGroupId 0, actually.
>
>> * note: these are the "base" volumes; of course the ability to change
>> the volume/balance of each sound directly will be retained!
>
> i'm not sure what you mean. you could precise path of volume control.
To speak in the terms of iMuseDigital:
* _volVoice, _volSfx, _volMusic specify the *base volume* of the
respective sound category
* in addition to this, there might be a global "master volume"
* finally, each sound source (each AudioStream object) may have a
volume associated. This corresponds to track->vol
Example (all volumes from 0 to 256): master volume is 192, speech
volume 220, sfx volume 120, music volume 0
We start playing a speech sound with volume 128. It ends up as
128 * 220 * 192 / (256 * 256)
We also play another speech with volume 210 (e.g. somebody is
"shouting" :-)
210 * 220 * 192 / (256 * 256)
Finally, a music stream is playing, with volume 128:
128 * 0 * 192 / (256 * 256)
So it ends up mute, because the overall music volume is set to 0
>
>> * we need to discuss whether we want to / need to retain the global
>> "master" volume. If we keep it, it should effect *everything*; setting
>> it to 0 would effectively mute all sound.
>
> "master" as most priority volume control might be usefull.
> from imuse point, "master" is like one of volume groups and it's
> independent to rest volumes groups, but our imuse not needed as i wrote
> above.
Actually, the master volume would be only useful to the user, who would
be able to decide how loud he wants the SFX to be. I don't think iMuse
or anything else would modify it -- only the user.
>
Bye,
Max
More information about the Scummvm-devel
mailing list