text
stringlengths
1
112
the sink level that leads to the situation where the source gain gets turned do wn with the
sink gain turned up to full to compensate it means that the user can no longer increase the
volume at their ears and the audio quality is reduced as the codec is sampling and encoding
a signal with a very low amplitude this decreases the allimportant signal to noise ratio as
on decoding and amplification the noise gets amplified as well
chapter volume audio input and microphone control
to address this its important that the gain occurs at the end of the audio chain but for that
to work all of the volume control clients need to k eep track of its value so they always know
where they are its a bit like the old joke where a driver stops to ask a passer by if he could
give him directions to get to dublin and the passer by replies if i was going to dublin i
wouldnt start from here fortunately the gatt client server model has notifications so
we can make use of these to ensure that every volume control client knows the current gain
level on the server but to be absolutely sure the volume control service includes an
additional safeguard called the changecounter which well explore below
looking back at figure it also explains the architecture where the volume control state
is as close as possible to the final point of rendering this brings us on to the individual
volume control services these are very thin documents so we can skim through them fairly
quickly
volume control service
like the control service weve seen before all of the hard work is done by two characteristics
the volume control point which the clients use to set the volume level and
the volume state which the server uses to notify the current volume level after
the volume control point characteristic has been written
we should strictly be talking about gain rather than volume but as everyone is used to the
colloquial use of volume ill stick with it a third characteristic volume flags is used to let
a client know about the history of the current volume setting
the volume state characteristic has three fields all one octet lo ng which are shown in figure
there is only one instance of the volume state characteristic on an acceptor
field name values
volumesetting to minim um maximum
mute not muted
muted
changecounter to
figure the volume state characteristic of vcs
the volumesetting is defined as a value from minimum volume to maximum with
no stipulation on how those figures are related to the output volume it is left to the
implementer to map these values to actual output volume with the expectation t hat the user
perception is approximately linear ie if the volumesetting value is set to then the
resulting output should sound as if it is halfway to the maximum this brings us back to the
debate about how volume is perceived our hearing is generally logarithmic which is why
sound intensity is measured in decibels but that can be affected by what it is were listening
section volume control service
to leaving it to the manufacturer does mean that if speakers or earbuds from different
manufacturers are used together ch anges to their volume may not align with the listeners
expectation one may appear louder than the other at certain settings solving that fe ll into
the too difficult category so its been left to implementation
the value of the volumesetting field is changed as a result of an operation on the volume
control point characteristic qv which modifies the current value or a local operation on
the user interface of the device the value stored in volumesetting is not affected by any
mute operation
the mute indicates whether the audio stream has been muted this is independent of the
volumesetting value so that when a device is unmuted the audio volume will resume at its
previous level
changecounter is the feature mentio ned above which ensures that all volume control
clients are synchronised when an acceptor implementing vcs is powered on the server
initialises changecounter with a random value between and every subsequent
operation on the volume control poin t characteristic or the devices local controls whether
to change volume or mute which result s in a change to the volumesetting or mute field
values will result in the changecounter incrementing its value by once it reaches a value
of it will roll around to and keep incrementing
the purpose of changecounter is to ensure that any client attempting to change the current
volume or mute setting s is aware of what they are currently this is checked by requiring every
write procedure by a clien t to include the current value of changecounter which they hold
unless that matches the value in the volume state characteristic it is assumed they are out of
sync the command is ignored and no notification will be sent in this case the client sh ould
recognise the lack of a notification read the volume state characteristic and try again
to change the volume or mute a device the volume control client writes to the volume
control point characteristic of the volume control service using one of th e volume control
point procedures this command contains an opcode a changecounter value and in the
case of the set absolute volume command a volumesetting value the six opcodes are
listed in table
opcode operation operands
x relative volume down changecounter
x relative volume up changecounter
x unmute relative volume down changecounter
x unmute relative volume up changecounter
x set absolute volume changecounter volumesetting
x unmute changecounter
chapter volume audio input and microphone control
opcode operation operands
x mute changecounter
xxff reserved for future use
table volume control point characteristic opcodes
most of these are self explanatory relative volume down and up change the volume setting
without affecting the mute state so can be used to change the volume level which will be
applied when a device is eve ntually unmuted opcodes x and x unmute and mute
without affecting the volume level whilst opcodes x and x apply a relative volume step
at the same time as muting or unmuting set absolute volume takes an additional parameter
which is the a bsolute volume level required
although the volumesetting ranges from to for all devices very few are likely to
contain more than twenty one discrete volume levels this requires a server to define a step
size which is applied whenever a volume setting command is issued the step size is
effectively number of steps the following equations are used by the server to calculate
the new value written into the volumesetting value of the volume state characteristic
relative volume down vol umesetting max volumesetting step size
relative volume up volumesetting min volumesetting step size
persisting volume
the final characteristic is the volume flags characteristic which is a bitfield of which only
one bit is defin ed this is bit which is the volumesettingpersisted field if set to it
directs a client to reset the volume by writing to the volume control point characteristic with