<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Don't use OPUS_SET_COMPLEXITY(0) unless you absolutely have to. That means "give me all the distortions" so I wouldn't be surprised if that's where those are coming from. If your encoding path can't handle full 10 complexity, dial it down to 9, 8, etc until it runs ok.</div><div dir="ltr"><br></div><div dir="ltr">opus_custom_decode doesn't downsample from 48kHz, so your playback code must still be treating it as if it's 15kHz, thus the pitch down. If you can swing it, play as 48kHz, otherwise you have to insert another CPU-hogging resampler. If you do need it and don't have a resampler handy, Opus has silk_resampler_init & silk_resampler available for you.</div><div dir="ltr"><br></div><div>Emily Bowman<br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 17, 2019 at 12:47 PM Peter Svensson <<a href="mailto:petersvenss85@gmail.com">petersvenss85@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial" lang="EN-US">Hi all !</span><span style="font-size:12pt;font-family:"Times New Roman",serif" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">If
someone could give me a hint on how to proceed with the following i'd be very
happy:</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">I
have a test setup on an nrf52832 (Cortex M4) in which I receive audio from a
PDM microphone (64 sample frame) and pass it directly to an I2S device i.e.
from ISR to ISR. With uncompressed audio this works just fine.</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">Now
I try to insert OPUS1.3 in the path but cannot make it work. The audio passes
through but ends up “down pitched” and heavily distorted. </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">Due
to the 32MHz base clock (+ prescalers) available it is not possible to get the
desired 16kHz sample rate. I am therefore forced to work with 15625Hz.</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">As
I understand it the opus encoder does not mind a strange sample rate as it will
re-sample it to 48kHz (Correct?). The decoder, however, will always output
48kHz, 24kHz, 16kHz etc (Correct?) which is incompatible with my 15625Hz rate.
(However; If my assumptions are correct there could be a possibility to make my
I2S device master and, thus, be able to pull the data at 16kHz)</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">Consequently
I have been looking at “opus custom” as a solution but even with a (seemingly)
low complexity it does not yield the desired result.</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><u><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">Setup
code:</span></u></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">mode
= opus_custom_mode_create(15625, 64, &err);</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">size
= opus_custom_encoder_get_size(mode, 1);</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">enc
= malloc(size);</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">err
= opus_custom_encoder_init(enc, mode, 1);</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">err
= opus_custom_encoder_ctl(enc, OPUS_SET_BITRATE(16000));</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">err
= opus_custom_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0));</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">size
= opus_custom_decoder_get_size(mode, 1);</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">dec
= malloc(size);</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">err
= opus_custom_decoder_init(dec, mode, 1);</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><u><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">ISR
code (called once every 4.096ms):</span></u></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> nbBytes = opus_custom_encode(</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> enc, (opus_int16 *)lMicBuf, 64,
codedMicBuf, 64);</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> frame_size = opus_custom_decode(</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> dec, codedMicBuf, 64, decodedMicBuf, 64);</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><u><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">Build:</span></u></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">C:\Program
Files\SEGGER\SEGGER Embedded Studio for ARM
3.50\gcc\arm-none-eabi\bin\cc1" -fmessage-length=0
-fno-diagnostics-show-caret -mcpu=cortex-m4 -mlittle-endian -mfloat-abi=hard
-mfpu=fpv4-sp-d16 -mthumb -mtp=soft -nostdinc "-isystem</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">-D__SIZEOF_WCHAR_T=4
-D__ARM_ARCH_7EM__ -D__SES_ARM -D__ARM_ARCH_FPV4_SP_D16__ -D__SES_VERSION=35000
-DARM_MATH_CM4 -D__FPU_PRESENT -DDEBUG "-D DEBUG_NRF"
-DCONFIG_GPIO_AS_PINRESET -DINITIALIZE_USER_SECTIONS -DNO_VTOR_CONFIG -DNRF52
-DNRF52832_XXAA -DCONFIG_NFCT_PINS_AS_GPIOS -DOPUS_BUILD -DVAR_ARRAYS
-DFIXED_POINT -DDISABLE_FLOAT_API -DCUSTOM_MODES "-DARM_MATH_CM4 "
"-DOPUS_ARM_INLINE_EDSP " -DDOPUS_ARM_INLINE_ASM
-DOPUS_ARM_INLINE_MEDIA -MD </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">Any
ideas?</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">Regards</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:Arial,sans-serif" lang="EN-US">Peter</span></p></div>
_______________________________________________<br>
opus mailing list<br>
<a href="mailto:opus@xiph.org" target="_blank">opus@xiph.org</a><br>
<a href="http://lists.xiph.org/mailman/listinfo/opus" rel="noreferrer" target="_blank">http://lists.xiph.org/mailman/listinfo/opus</a><br>
</blockquote></div></div></div></div></div></div>