in frequency bands (using the spatial metadata) to obtain the spatial output, for example a binaural output. 

The aforementioned solution is particularly suitable for encoding captured spatial sound from microphone arrays (e.g., in mobile phones, VR cameras, stand- alone microphone arrays). However, it may be desirable for such an encoder to have also other input types than microphone-array captured signals, for example, loudspeaker signals, audio object signals, or Ambisonic signals. 

Analysing first-order Ambisonics (FOA) inputs for spatial metadata extraction has been thoroughly documented in scientific literature related to Directional Audio Coding (DirAC) and Harmonic planewave expansion (Harpex). This is since there exist microphone arrays directly providing a FOA signal (more accurately: its variant, the B-format signal), and analysing such an input has thus been a point of study in the field. 

A further input for the encoder is also multi-channel loudspeaker input, such as 5.1 or 7.1 channel surround inputs. 

However with respect to the directional components of the metadata, which may comprise an elevation, azimuth (and energy ratio which is 1-diffuseness) of a resulting direction, for each considered time/frequency subband. Quantization of these directional components is a current research topic. 

## Summary 

There is provided according to a first aspect an apparatus comprising means for: receiving values for sub-bands of a frame of an audio signal, the values comprising at least one azimuth value, at least one elevation value and at least one energy ratio value for each sub-band; determining an allocation of first number of bits to encode the values of the frame, wherein the first number of bits is fixed; encoding the at least one energy ratio value of the frame based on a defined allocation of a second number of bits from the first number of bits; encoding the at least one azimuth value and/or at least one elevation value of the frame based on a defined allocation of a third number of bits from the first number of bits, wherein the third number of bits is variably distributed on a sub-band-by-sub-band basis. 

