<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: RT1020 SAI audio buffer manipulation in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1544155#M196875</link>
    <description>&lt;P&gt;Thank you, &lt;EM&gt;&lt;STRONG&gt;jingpan&lt;/STRONG&gt;&lt;/EM&gt;, for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My observation was made by modifying the example project from the RT1020 SDK. It was described as "baremetal" in the MCUXpresso IDE. Without an operating system, it is hard to find another process to overwrite the buffer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps the method I used to perform the overwriting was incorrect. In that case, please suggest a better alternative.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Oct 2022 15:19:47 GMT</pubDate>
    <dc:creator>dykwong</dc:creator>
    <dc:date>2022-10-26T15:19:47Z</dc:date>
    <item>
      <title>RT1020 SAI audio buffer manipulation</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1542392#M196744</link>
      <description>&lt;P&gt;The MIMXRT1020-EVK is a convenient platform for evaluating the RT1021 MCU, especially with the help of a good selection of example projects. It is equipped with a Wolfson WM8960 codec which is wired to separate analogue input sources - a 3.5mm headphone-mic socket (J11) on the left channel, and an onboard microphone (P1) on the right.&lt;BR /&gt;&lt;BR /&gt;From the SDK, the sai_edma_record_playback example project performs a simple loopback of the audio inputs to play them out on as stereo output on the socket. I have attempted to duplicate the left channel audio samples to overwrite the ones from the right channel by modification of the example source code:&lt;BR /&gt;&lt;BR /&gt;if (emptyBlock &amp;lt; BUFFER_NUMBER)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; xfer.data = Buffer + tx_index * BUFFER_SIZE;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; xfer.dataSize = BUFFER_SIZE;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // copy line-in mono audio to overwrite on-board mic&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; uint8_t *lc, *rc;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int cnt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lc = xfer.data;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rc = lc + 2;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(cnt = 0; cnt &amp;lt; BUFFER_SIZE / 2 / 2; cnt++)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *rc++ = *lc++;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *rc++ = *lc++;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lc += 2;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rc += 2;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (kStatus_Success == SAI_TransferSendNonBlocking(DEMO_SAI, &amp;amp;txHandle, &amp;amp;xfer))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tx_index++;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (tx_index == BUFFER_NUMBER)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tx_index = 0U;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;The above appeared to work, except that at the boundary of every block of 256 samples, a few samples appear to be missing. Please see the following screen capture of the analogue output channels which is zoomed in to show just 1ms. (The bottom trace is the unmodified left channel, and the top is the right one which was the duplicate.)&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="time span: 1ms" style="width: 289px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/197788i42A6C476DF435A0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="1ms zoom.jpg" alt="time span: 1ms" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;time span: 1ms&lt;/span&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="16ms frame boundaries" style="width: 483px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/197811i139CB114BB777E9C/image-size/large?v=v2&amp;amp;px=999" role="button" title="16ms frames.jpg" alt="16ms frame boundaries" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;16ms frame boundaries&lt;/span&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;I am at a loss searching for the origin of the apparent loss of these audio samples. I guess there may be some subtleties about the use of SAI.&lt;BR /&gt;&lt;BR /&gt;The above observation may be applicable to other evaluation boards in the i.MX series.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 06:07:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1542392#M196744</guid>
      <dc:creator>dykwong</dc:creator>
      <dc:date>2022-10-24T06:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: RT1020 SAI audio buffer manipulation</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1543939#M196860</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/207540"&gt;@dykwong&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You can check each buffer block's data after it is send by interrupt. Maybe it is changed by some other code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Jing&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 08:48:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1543939#M196860</guid>
      <dc:creator>jingpan</dc:creator>
      <dc:date>2022-10-26T08:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: RT1020 SAI audio buffer manipulation</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1544155#M196875</link>
      <description>&lt;P&gt;Thank you, &lt;EM&gt;&lt;STRONG&gt;jingpan&lt;/STRONG&gt;&lt;/EM&gt;, for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My observation was made by modifying the example project from the RT1020 SDK. It was described as "baremetal" in the MCUXpresso IDE. Without an operating system, it is hard to find another process to overwrite the buffer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps the method I used to perform the overwriting was incorrect. In that case, please suggest a better alternative.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 15:19:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1544155#M196875</guid>
      <dc:creator>dykwong</dc:creator>
      <dc:date>2022-10-26T15:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: RT1020 SAI audio buffer manipulation</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1544712#M196906</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/207540"&gt;@dykwong&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I can't find problem in your code. But the phenomenon looks so strange. If you don't touch anything, is there problems? If you compare data after copy, is there difference? Or even after the buffer is transmitted, is the data different?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Jing&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 05:38:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1544712#M196906</guid>
      <dc:creator>jingpan</dc:creator>
      <dc:date>2022-10-27T05:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: RT1020 SAI audio buffer manipulation</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1545543#M196968</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/61241"&gt;@jingpan&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The example project sai_edma_record_playback from the SDK captures by SAI RX the audio inputs from the on-board microphone and the line-in socket through the WM8960 codec continuously. The captured audio samples are untouched in the buffer, while SAI TX is used to play these captured samples back to the codec to complete the loopback.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before I have inserted my code fragment to overwrite the on-board microphone audio samples by the line-in ones, the output waveform on both output channels do not exhibit any observable gaps.&lt;BR /&gt;&lt;BR /&gt;It may be useful to reproduce my observation by running the example project code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 07:26:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/RT1020-SAI-audio-buffer-manipulation/m-p/1545543#M196968</guid>
      <dc:creator>dykwong</dc:creator>
      <dc:date>2022-10-28T07:26:07Z</dc:date>
    </item>
  </channel>
</rss>

