1set_volume_per_voice(3)         Allegro manual         set_volume_per_voice(3)
2
3
4

NAME

6       set_volume_per_voice  -  Sets  the volume of a voice. Allegro game pro‐
7       gramming library.
8

SYNOPSIS

10       #include <allegro.h>
11
12
13       void set_volume_per_voice(int scale);
14

DESCRIPTION

16       By default, Allegro will play a centered sample at half volume on  both
17       the  left  and  right channel. A sample panned to the far right or left
18       will be played at maximum volume on that channel only. This is done  so
19       you  can  play  a  single panned sample without distortion. If you play
20       multiple samples at full volume, the mixing process can result in clip‐
21       ping,  a  noticeable  form  of  distortion.  The more samples, the more
22       likely clipping is to occur, and the more clipping, the worse the  out‐
23       put will sound.
24
25       If  clipping  is a problem - or if the output is too quiet - this func‐
26       tion can be used to adjust the volume of each voice. You  should  first
27       check  that  your speakers are at a reasonable volume, Allegro's global
28       volume is at maximum (see set_volume() below),  and  any  other  mixers
29       such  as  the  Windows  Volume Control are set reasonably. Once you are
30       sure that Allegro's output level is unsuitable  for  your  application,
31       use this function to adjust it.
32
33       Each  time  you increase the parameter by one, the volume of each voice
34       will halve. For example, if you pass 4, you can play up to  16  centred
35       samples at maximum volume without distortion.
36
37       If  you  pass  0 to this function, each centred sample will play at the
38       maximum volume possible without distortion, as will all samples  played
39       through  a mono driver. Samples at the extreme left and right will dis‐
40       tort if played at full volume. If you wish to play  panned  samples  at
41       full  volume  without  distortion,  you should pass 1 to this function.
42       Note: this is different from the function's behaviour in  WIPs  3.9.34,
43       3.9.35  and  3.9.36. If you used this function under one of these WIPs,
44       you will have to increase your parameter by one to get the same volume.
45
46       Note: The default behaviour has changed as of Allegro  4.1.15.  If  you
47       would  like  the  behaviour  of earlier versions of Allegro, pass -1 to
48       this function. Allegro will choose a value dependent on the  number  of
49       voices,  so  that  if you reserve n voices, you can play up to n/2 nor‐
50       malised samples with centre panning  without  risking  distortion.  The
51       exception  is  when  you  have  fewer  than  8 voices, where the volume
52       remains the same as for 8 voices. Here are the values, dependent on the
53       number of voices:
54
55          1-8 voices - set_volume_per_voice(2)
56           16 voices - set_volume_per_voice(3)
57           32 voices - set_volume_per_voice(4)
58           64 voices - set_volume_per_voice(5)
59
60       Of  course  this function does not override the volume you specify with
61       play_sample() or voice_set_volume(). It simply alters the overall  out‐
62       put  of  the  program. If you play samples at lower volumes, or if they
63       are not normalised, then you can play more of them without distortion.
64
65       It is recommended that you hard-code the parameter into  your  program,
66       rather than offering it to the user. The user can alter the volume with
67       the configuration file instead,  or  you  can  provide  for  this  with
68       set_volume().
69
70       To restore volume per voice to its default behaviour, pass 1.
71
72

SEE ALSO

74       reserve_voices(3),           set_volume(3),           install_sound(3),
75       detect_digi_driver(3), detect_midi_driver(3)
76
77
78
79Allegro                          version 4.2.2         set_volume_per_voice(3)
Impressum