-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve audio settings #1582
base: master
Are you sure you want to change the base?
Improve audio settings #1582
Conversation
Unfortunately, int fields don't seem to be editable currently, though the checkboxes work.
The following links are available: build (ubuntu-18.04, full)
build (windows-latest, full) build (macOS-10.15, full) |
The following links are available: build (ubuntu-18.04, full)
build (macOS-10.15, client) build (windows-latest, full) build (self-hosted_debian-11_aarch64, full)
|
The following links are available: build (macOS-10.15, full) build (ubuntu-18.04, full)
build (windows-latest, full) build (self-hosted_debian-11_aarch64, full)
|
The following links are available: build (ubuntu-18.04, full)
build (macOS-10.15, full) build (windows-latest, full) build (self-hosted_debian-11_aarch64, full)
|
Experimentally verified that nothing is heard below this value.
Codec feature info doesn't actually work yet, type needs registering
The following links are available: build (macOS-10.15, full) build (ubuntu-18.04, full)
build (windows-latest, full) build (self-hosted_debian-11_aarch64, full)
|
These two constants are no longer used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the scripting interface, I would generally prefer to deal objects for this kind of things in JavaScript, instead of bunch of get/set functions, something similar in spirit to the settings JSON API we have, but that also seems like something way out of scope for this PR. I'm also not sure what the intended use cases are, so might be overthinking it.
/* | ||
struct CodecSettings { | ||
QString codec; | ||
Encoder::Bandpass bandpass = Encoder::Bandpass::Fullband; | ||
Encoder::ApplicationType applicationType = Encoder::ApplicationType::Audio; | ||
Encoder::SignalType signalType = Encoder::SignalType::Auto; | ||
int bitrate = 128000; | ||
int complexity = 100; | ||
bool enableFEC = 0; | ||
int packetLossPercent = 0; | ||
bool enableVBR = 1; | ||
}; | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is identical to the definition in the included plugins/CodecPlugin.h, not sure if it's here for reference, but seems out of place anyway
/* | |
struct CodecSettings { | |
QString codec; | |
Encoder::Bandpass bandpass = Encoder::Bandpass::Fullband; | |
Encoder::ApplicationType applicationType = Encoder::ApplicationType::Audio; | |
Encoder::SignalType signalType = Encoder::SignalType::Auto; | |
int bitrate = 128000; | |
int complexity = 100; | |
bool enableFEC = 0; | |
int packetLossPercent = 0; | |
bool enableVBR = 1; | |
}; | |
*/ |
static int getStaticJitterFrames() { return _numStaticJitterFrames; } | ||
static bool shouldMute(float quietestFrame) { return quietestFrame > _noiseMutingThreshold; } | ||
static float getAttenuationPerDoublingInDistance() { return _attenuationPerDoublingInDistance; } | ||
static const std::vector<ZoneDescription>& getAudioZones() { return _audioZones; } | ||
static const std::vector<ZoneSettings>& getZoneSettings() { return _zoneSettings; } | ||
static const std::vector<ReverbSettings>& getReverbSettings() { return _zoneReverbSettings; } | ||
static const std::pair<QString, CodecPluginPointer> negotiateCodec(std::vector<QString> codecs); | ||
static const std::vector<Encoder::CodecSettings> getCodecSettings() { return _codecSettings; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this comes from the line above, but return const value seems odd, unless I'm missing some coding standard. Hard to think of any actual use cases for it though in general, outside of some really weird proxy types maybe.
static const std::vector<Encoder::CodecSettings> getCodecSettings() { return _codecSettings; } | |
static const std::vector<Encoder::CodecSettings>& getCodecSettings() { return _codecSettings; } |
I would change negotiateCodec as well to return a plain value without const, but that would be out of scope of this PR.
@@ -1417,10 +1417,109 @@ | |||
{ | |||
"name": "codec_preference_order", | |||
"label": "Audio Codec Preference Order", | |||
"help": "List of codec names in order of preferred usage", | |||
"help": "List of codec names in order of preferred usage -- mod2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't figure out what mod2 means here...
/** | ||
* @brief Represents the settings loaded from the domain's configuration page | ||
* | ||
* Encoder classes are created EntityScriptServer, Agent, AudioMixerClientData and AudioClient, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Encoder classes are created EntityScriptServer, Agent, AudioMixerClientData and AudioClient, | |
* Encoder classes are created by EntityScriptServer, Agent, AudioMixerClientData and AudioClient, |
@@ -55,8 +55,8 @@ AthenaOpusEncoder::AthenaOpusEncoder(int sampleRate, int numChannels) { | |||
|
|||
setBitrate(DEFAULT_BITRATE); | |||
setComplexity(DEFAULT_COMPLEXITY); | |||
setApplication(DEFAULT_APPLICATION); | |||
setSignal(DEFAULT_SIGNAL); | |||
setApplication(Encoder::ApplicationType::Audio); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the default application type was VOIP before, not sure if this change is intentional. If I understand correctly this gets overwritten by CodecSettings' default which is also set to Audio.
@@ -10,14 +10,196 @@ | |||
// | |||
#pragma once | |||
|
|||
#include <algorithm> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary include?
I'm thinking something like single set/get pair for all encoder settings, that would accept and return an object. The returned object would contain only what the current encoder supports, removing the need for getEncoderFeatures, and the object that the setter accepts could be partial, only setting whatever is specified. |
I've introduced some conflicts with this PR by moving the opus and PCM codec code into a library and decoupling the plugin and codec interfaces to make it all easier to reuse in context of the client library and Unity SDK. It's might be a while before that needs to be merged with master, so ideally we should get this finished up and merged first, if there aren't any major issues. |
Hello! Is this still an issue? |
This implements configurable config settings for audio codecs. It's still at an early stage, and only being submitted for feedback and collaboration.
TODO list:
Audio.getEncoderFeatures()
Initial API for audio codecs, client side:
Audio.getCodec()
-- returns current codecAudio.getCodecs()
-- list of known codecsAudio.getAllowedCodecs()
-- list of codecs the interface is willing to use. All codecs are accepted if the list is empty. Will check that the names correspond with something ingetCodecs()
, and filter out any unknown entries.Audio.setAllowedCodecs()
-- set list of allowed codecs for the interface.Audio.getEncoderVBR()
-- is VBR enabledAudio.setEncoderVBR(bool)
-- enable/disable Variable Bit RateAudio.getEncoderBitrate()
Audio.getEncoderBitrate(int bitrate)
-- Bit rate, in bits/s. 2400 to 512000. Default is 128000 (128kbps)Audio.getEncoderComplexity()
Audio.getEncoderComplexity(int complexity)
-- How CPU intensive compression is, 0 to 100.Audio.getEncoderFEC()
-- is VBR enabledAudio.setEncoderFEC(bool)
-- enable/disable Forward Error CorrectionAudio.getEncoderPacketLossPercent()
Audio.setEncoderPacketLossPercent(int percent)
-- how much data loss to allow forNot working:
Audio.getEncoderFeatures()
-- returns a feature list for the current encoderTesting:
You can test with yourself by using this console command:
Audio.setServerEcho(true)
. This will bounce audio off the domain at yourself. Microphone has to be on for it to work.Use for instance
Audio.setAllowedCodecs(["zlib"])
in the console, and observe the rise in bandwidth usage.Use
Audio.setEncoderBitrate(5000)
to see the effect of 5 kbps audioUse
Audio.setEncoderComplexity(1)
to see the effect of less CPU intensive encodingUse
Audio.setEncoderFEC(true)
andAudio.setEncoderPacketLossPercent(10)
to try error correction. Needs a connection with some packet loss.Feedback would be very welcome -- especially regarding whether the API makes sense, and if there are threading issues anywhere in this.