Skip to content

Add OPUS_SET_MIN_BANDWIDTH to set minInternalSampleRate #373

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nguditi
Copy link

@nguditi nguditi commented Oct 25, 2024

… (which is using NARROWBAND)

  • Implement OPUS_SET_MIN_BANDWIDTH to OPUS_BANDWIDTH_WIDEBAND to allow configuration of minInternalSampleRate in Silk mode during encoding.
  • This enables additional options for decoding, supporting both LACE and NOLACE modes, which require Wideband audio.

… (which is using NARROWBAND)

- Implement OPUS_SET_MIN_BANDWIDTH to OPUS_BANDWIDTH_WIDEBAND to allow configuration of minInternalSampleRate in Silk mode during encoding.
- This enables additional options for decoding, supporting both LACE and NOLACE modes, which require Wideband audio.
@jmvalin
Copy link
Member

jmvalin commented Oct 25, 2024

Can you explain a bit more in what context you would be using it that doesn't currently work?

@nguditi
Copy link
Author

nguditi commented Oct 28, 2024

Can you explain a bit more in what context you would be using it that doesn't currently work?

Hi jmvalin.

When audio passes through the encoder, it’s limited to a 4 kHz frequency, which reduces the quality to narrowband. This also prevents the LACE/NOLACE features from working when decoding, as they require wideband, which needs a minimum of 8 kHz. To resolve this and enable LACE/NOLACE, you need to set the encoder’s bandwidth to wideband by calling the following command:

opus_encoder_ctl(encoder, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_WIDEBAND));

But this command also limits the upper bound and sets the bandwidth strictly to wideband. However, I want to avoid restricting the upper bound for higher-quality audio. I simply want to set the lower bound to enable LACE/NOLACE for low-quality audio while keeping the original algorithm for medium and high-quality audio.

I hope you understand the situation I'm facing.

Thank you

@nguditi
Copy link
Author

nguditi commented Oct 28, 2024

Let me tell you a story.

I want to test the Low-Bitrate Speech Quality Enhancement feature of Opus v1.5. My initial thought was to simply run the provided docs/trivial_example.c with a bitrate limit down to about 3 kbps for 16-bit audio with 1 channel, or 6 kbps for 32-bit audio with 1 channel, along with opus_decoder_ctl(decoder, OPUS_SET_COMPLEXITY(7)). However, the output file quality remains poor, as if the complexity setting wasn’t applied to the decoder. I looked into it further and realized this feature only works with wideband audio quality. I then downloaded an audio file from the Opus demo site, analyzed it in Audacity, and saw that their 32-bit, 1-channel audio was at 8 kHz with a bitrate of 6 kbps. How did they manage that encoding? It turns out that you need to use the configuration to set a fixed bandwidth for the encoder.

..and finally, the output sounds as good as in the Opus demo.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants