<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/124801/best-place-for-audio-processing-adjustments</link><description>Hello all, 
 I am working on a project with 2 nrf5340 Audio DK&amp;#39;s, and I have been working for a while now on getting myself familiar with the audio application, but I have a few questions. First of all I assumed it would be wise to develop on top of the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 04 Nov 2025 13:57:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/124801/best-place-for-audio-processing-adjustments" /><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/553320?ContentTypeID=1</link><pubDate>Tue, 04 Nov 2025 13:57:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41bcb215-1397-4235-a1e5-081a7089c71d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I have not looked into the details, but there are several ways it could detect it. As it is encrypted and would look like just random noise, I expect it detects that the frame is invalid and sets&amp;nbsp; BEC_detect flag (see page 70 in &lt;a href="https://www.bluetooth.com/specifications/specs/low-complexity-communication-codec-1-0-1/"&gt;LC3 spec v1.0.1&lt;/a&gt;). Also, I recommend you have a look at&amp;nbsp;Appendix B Packet Loss Concealment.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/553280?ContentTypeID=1</link><pubDate>Tue, 04 Nov 2025 10:20:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2b41e8b-e6bf-49b3-b836-cf0f55441f2d</guid><dc:creator>Jorritv3</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for your reply, sorry for my late response.&lt;br /&gt;But how does the codec know it is garbage?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/552921?ContentTypeID=1</link><pubDate>Thu, 30 Oct 2025 14:36:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20360e72-428e-4437-afb0-dad08e6000c7</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Aha, then I se. I do not think that is the case. The codec will see that the input data is gabage and use error concealment. And as there is no data of value anywhere, the best&amp;nbsp;concealment is simply no signal/silence.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/552796?ContentTypeID=1</link><pubDate>Wed, 29 Oct 2025 15:22:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:353a6248-6768-41de-8688-d7c3f270aea5</guid><dc:creator>Jorritv3</dc:creator><description>&lt;p&gt;I think you are misunderstanding, sorry for my unclear explanation.&lt;br /&gt;&lt;br /&gt;I am doing an encryption after encoding, this would mean the encoded data that gets send to the other device should be encrypted. At the other device I do the decryption before the decoding, so the original sound should come out.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;When I do both encryption and decryption, I&amp;nbsp;&lt;strong&gt;Do&amp;nbsp;&lt;/strong&gt;hear the original audio.&lt;br /&gt;But when I&amp;nbsp;&lt;strong&gt;Only&lt;/strong&gt; do the encryption (So no decryption at the other side), I hear nothing.&lt;br /&gt;&lt;br /&gt;I expect to hear noise since my data received at the other device it garbage.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;My question is why all PCM data gets set to 0 when&amp;nbsp;&lt;strong&gt;decoding&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;So at the decoding side encrypted data comes in, but that device shouldn&amp;#39;t know it is encrypted, so how why does it produce no sound at all, instead of garbled noise.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/552766?ContentTypeID=1</link><pubDate>Wed, 29 Oct 2025 13:38:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5620a10-fdb1-4334-9858-69e0a9141e5f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I see. But then there should not be any difference with encryption or not, as the data into the decoder will be indentical to what it would be if ti was not encrypted. Is there a difference or did I misunderstand something? If this fails with encryption but not without it, you need to look into your encryption/decryption, as ther eseems to be an issue there. Can you verify that the decrypted data is identical to the data before encryption?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/552731?ContentTypeID=1</link><pubDate>Wed, 29 Oct 2025 10:47:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c798aea1-ef20-432d-8962-84b03f4b9fa1</guid><dc:creator>Jorritv3</dc:creator><description>&lt;p&gt;No I am encrypting after encoding, and decrypting before decoding.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/552728?ContentTypeID=1</link><pubDate>Wed, 29 Oct 2025 10:14:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb45cc0c-594b-4e7d-a8ce-92beca28900b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Can you Is this data now encrypted before or after encoding? If you encrypt data before encoding I am not sure how the result will be, as the encoder is lossy and expects an audio signal. The encrypted signal is effectively white noise and impossible to compress in any measningfull way. It could perhaps also be that as there is no data erroc concelment will result in zero output (no noise)? If so, te return value will be 0 (LC3_RESULT_NO_ERROR) according to the &lt;a href="https://github.com/nrfconnect/sdk-nrfxlib/blob/3b210a24d3bc7ecfc268e0feab6436306b11e7cb/lc3/codec/inc/LC3API.h#L367"&gt;API documentation for&amp;nbsp;LC3DecodeSessionData&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/552535?ContentTypeID=1</link><pubDate>Mon, 27 Oct 2025 15:53:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26de0208-a70c-4c67-8e98-f0e1eb6847ed</guid><dc:creator>Jorritv3</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So I pass valid data to LC3DecodeSessionData(), not LC3DecodeOutput(), and it returns 0, so it should be valid. This is modified data in the sense that I applied an XOR operation to the bytes after encoding. And indeed they are not empty, but still the output frames are zero.&lt;/p&gt;
&lt;p&gt;This problem only happens when I only encrypt the data (so after encoding). What I would expect is to hear noise (meaning in this case encrypted audio), but when I also apply the decryption it sounds normal again. I want to hear the noise to prove the audio is correctly being processed, but instead the audio gets set to 0 at the &lt;span&gt;LC3DecodeSessionData()&lt;/span&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/552528?ContentTypeID=1</link><pubDate>Mon, 27 Oct 2025 15:09:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59cbc589-e5fd-4ef7-ae52-91def4937ae0</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am sorry for the late reply. Is it correct that you pass data to&amp;nbsp;&lt;span&gt;LC3DecodeOutput(), meaning non-empty input frame, but the output frame is all zero non the less? You write that there are no errors, does that include from&amp;nbsp;LC3DecodeOutput? What is the return value? If it returns 0 that means no error, and the output buffer should be a valid decoded frame containing raw PCM data.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Also, is this on unmodified data, or do you see ths issue only when you have manipulatedc the input data (before it was encoded I assume)?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/552048?ContentTypeID=1</link><pubDate>Tue, 21 Oct 2025 10:21:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4ec9ca6-6e68-4c5b-b00a-643eeaf31d79</guid><dc:creator>Jorritv3</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Thank you for taking the time.&lt;br /&gt;&lt;br /&gt;So first I looked at what was coming in on the decode side, but there the audio frame is all zeroes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;next I looked if the audio even arrived correctly at the other device, so after bleutooth transmission, which it does. In the file audio_datapath.c I see the audioframe having values before the sw_codec_decode, but the decoded data after the decode function is all zeroes, so somewhere in this function it goes wrong.&lt;br /&gt;&lt;br /&gt;In this function I saw that it depends on CONFIG_SW_CODEC_LC3 so I tried turning this on and placing some more print statements to see where the audio data is lost.&lt;/p&gt;
&lt;p&gt;In the file sw_codec_select.c there is this piece of code:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;case SW_CODEC_MONO: {
			if (meta-&amp;gt;bad_data &amp;amp;&amp;amp; SW_CODEC_OVERRIDE_PLC) {
				memset(decoded_data_mono[0], 0, PCM_NUM_BYTES_MONO);
				decoded_data_size = PCM_NUM_BYTES_MONO;
			} else {

				ret = sw_codec_lc3_dec_run(
					audio_frame-&amp;gt;data, audio_frame-&amp;gt;len, LC3_PCM_NUM_BYTES_MONO,
					0, decoded_data_mono[0], (uint16_t *)&amp;amp;decoded_data_size,
					meta-&amp;gt;bad_data);

				if (ret) {

					return ret;
				}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And I see that the data in the audio frame before this function has values, but the decoded data after this function is all zeroes. So I followed the sw_codec_lc3_dec_run function to see where it goes wrong there.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;And finally I end up at this line in sw_codec_lc3.c:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;ret&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;LC3DecodeSessionData&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;dec_handle_ch&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;audio_ch&lt;/span&gt;&lt;span&gt;], &amp;amp;&lt;/span&gt;&lt;span&gt;LC3DecodeInput&lt;/span&gt;&lt;span&gt;, &amp;amp;&lt;/span&gt;&lt;span&gt;LC3DecodeOutput&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;The audio is fine before this function, but is all zeroes after this function. I placed this logging:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;if (frame_counter % 200 == 0)
	{
		LOG_INF(&amp;quot;---- LC3 Decode #%d ----&amp;quot;, frame_counter);
		LOG_INF(&amp;quot;Ch:%d, FrameLen:%d, PCMbuf:%d, bad_frame:%d&amp;quot;,
				audio_ch, lc3_data_size, pcm_data_buf_size, bad_frame);
		LOG_HEXDUMP_INF(lc3_data, MIN(lc3_data_size, 16), &amp;quot;LC3 Input (first 16 bytes)&amp;quot;);
		LOG_INF(&amp;quot;Decoded bytesWritten:%d, PLCCounter:%d&amp;quot;,
				LC3DecodeOutput.bytesWritten, LC3DecodeOutput.PLCCounter);

		if (LC3DecodeOutput.bytesWritten &amp;gt; 0)
		{
			uint16_t *pcm16 = (uint16_t *)pcm_data;
			size_t samples_to_print = MIN(8, LC3DecodeOutput.bytesWritten / sizeof(uint16_t));
			printk(&amp;quot;PCM samples (first %zu): &amp;quot;, samples_to_print);
			for (size_t i = 0; i &amp;lt; samples_to_print; i++)
			{
				printk(&amp;quot;%d &amp;quot;, pcm16[i]);
			}
			printk(&amp;quot;\n&amp;quot;);
		}

		LOG_INF(&amp;quot;---------------------------&amp;quot;);
	}&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Which returns 0 bad_frames correct LC3 Input and no errors, but the PCM Samples printed are all zeroes.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;I don&amp;#39;t know what this function does but is there a way to make it work, because I don&amp;#39;t understand why it doesn&amp;#39;t output anything when I encrypt my data even though I expect random noise, (which I want to hear)&lt;br /&gt;&lt;br /&gt;I hope this clears up my issue, please let me know if you need more information.&lt;br /&gt;&lt;br /&gt;Kind regards.&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/551304?ContentTypeID=1</link><pubDate>Mon, 13 Oct 2025 15:01:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:971558d0-e508-46c4-a249-e436121066a5</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am not sure I understand. Can you elaborate, and perhaps show which changes you made in the codet?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/551119?ContentTypeID=1</link><pubDate>Fri, 10 Oct 2025 12:15:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c448582d-5c94-4950-8037-53812a76db54</guid><dc:creator>Jorritv3</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;First of all thank you for your help.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;So I tried to follow the audio path because there were no warnings or errors. I found the&amp;nbsp;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;sw_codec_lc3_dec_run function, which I assumed makes the PCM signal, to return only zeroes as PCM signal. I can not figure out why, but it seems to happen at&amp;nbsp;&lt;/span&gt;&lt;/span&gt;LC3DecodeSessionData (I might be wrong). Also it is not noted anywhere as a bad frame so it seems like the codec is decoding it but just writes all zeroes.&lt;br /&gt;&lt;br /&gt;The only other maybe notable thing is that I set&amp;nbsp;&lt;span&gt;CONFIG_SW_CODEC_LC3&lt;/span&gt;&lt;span&gt;=y in my conf.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;br /&gt;Any help is appreciated, thank you in advance.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/551023?ContentTypeID=1</link><pubDate>Thu, 09 Oct 2025 13:39:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aef492a3-9480-4642-9a7b-5323c57d242d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I would have expected that to work. Have you done any debugging to see what happens to the data and why there is no audio output? (Start with seeing if there are errors in the log, then move deeper from there)?&lt;/p&gt;
&lt;p&gt;PS: I assume this is just for experimentation, but to be on the safe side, I want to mention that if the end goal is encrypting the data, you should proably use standard Bluetooth security.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/550930?ContentTypeID=1</link><pubDate>Wed, 08 Oct 2025 14:19:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:287379e0-22be-4b50-a3b7-5e1e1816dbd7</guid><dc:creator>Jorritv3</dc:creator><description>&lt;p&gt;That makes a lot of sense, thank you.&lt;br /&gt;&lt;br /&gt;So I implemented it the way you are saying, and it seems to work. However if I only implement the encoding side without the decoding to check if the audio gets scrambled it doesn&amp;#39;t output anything anymore. This feels like a checksum of some sort is being implemented somewhere.&lt;/p&gt;
&lt;p&gt;Do you have an idea of why this doesn&amp;#39;t audio anymore? I would like to check wether the audio gets encrypted correctly, so it would be nice if it still reaches the speaker of my headset.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;P.S.&lt;br /&gt;&lt;br /&gt;I placed a very simple&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;const uint16_t xor_key = 0xAA;

for (size_t i = 0; i &amp;lt; audio_frame-&amp;gt;len; i++) {
	audio_frame-&amp;gt;data[i] ^= xor_key;
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;before the sw_codec_decode in audio.datapath.c and the same after the sw_codec_encode in audio_system.c.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best place for audio processing adjustments.</title><link>https://devzone.nordicsemi.com/thread/550799?ContentTypeID=1</link><pubDate>Tue, 07 Oct 2025 11:41:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fee426d7-1081-41ee-a935-9cfe8f6eb9e2</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The codec is a lossy codec, so you cannod encrypt (with simple xoring or any other method) before coding. Any such operations will have to happen after coding, and then the reverse operation must be performed before decoding. (If you were doing simple one way audio processing where the output signal is also an audio signal, and there is no reverse operation in the other end, that could have been doen before encoding).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>