<?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>USB Audio Half Used Packets</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/33995/usb-audio-half-used-packets</link><description>I am looking at the audio data received from USB. Every packet is only half filled. That is, the first 96 samples have valid data and the second 96 contain zeros. I am using the usbd_audio project. What is going on here? 
 This is stereo audio; every</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 18 Jun 2018 14:21:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/33995/usb-audio-half-used-packets" /><item><title>RE: USB Audio Half Used Packets</title><link>https://devzone.nordicsemi.com/thread/136590?ContentTypeID=1</link><pubDate>Mon, 18 Jun 2018 14:21:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b563aea-e6eb-4cf4-807e-ea9ed79223b5</guid><dc:creator>Andrew</dc:creator><description>&lt;p&gt;Do&amp;#39;h!&amp;nbsp; I was getting lost in mix of samples versus bytes.&lt;/p&gt;
&lt;p&gt;Thanks for the help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB Audio Half Used Packets</title><link>https://devzone.nordicsemi.com/thread/136524?ContentTypeID=1</link><pubDate>Mon, 18 Jun 2018 10:53:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd28ffd6-32ec-45ae-96d8-6c75b92709c0</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is the code that fetches the EP size and sets 192 bytes to m_temp_buffer_size:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;size_t rx_size = app_usbd_audio_class_rx_size_get(&amp;amp;m_app_audio_headphone.base);
m_temp_buffer_size = rx_size;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Which in turn checks that specific endpoint and returns the&amp;nbsp;OUT SIZE (read from NRF_USBD-&amp;gt;SIZE.ISOOUT, since this is an isochronous transfer) which the PC sends:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;size_t app_usbd_audio_class_rx_size_get(app_usbd_class_inst_t const * p_inst)
{
    nrf_drv_usbd_ep_t ep_addr;

    ep_addr = ep_iso_addr_get(p_inst);
    ASSERT(NRF_USBD_EPISO_CHECK(ep_addr));

    return (size_t)nrf_drv_usbd_epout_size_get(ep_addr);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Remember that &amp;quot;int16_t m_temp_buffer[96];&amp;quot; will be equal to 192 bytes in memory.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB Audio Half Used Packets</title><link>https://devzone.nordicsemi.com/thread/136416?ContentTypeID=1</link><pubDate>Fri, 15 Jun 2018 17:20:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d65d4a7a-0513-43b5-8a3d-64000a3057d1</guid><dc:creator>Andrew</dc:creator><description>&lt;p&gt;Thanks for responding!&amp;nbsp; Yes, I am still seeing this.&amp;nbsp; I am thinking it is a matter of buffer size definition.&lt;/p&gt;
&lt;p&gt;I have only added code to aggregate the samples into a lager buffer.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define GRAB_DATA
#ifdef GRAB_DATA
static int16_t muchLargerBuffer[1000];
static unsigned int bigCount = 0;
static unsigned int smallCount = 0;
#endif


/**
 * @brief User event handler @ref app_usbd_audio_user_ev_handler_t (headphones)
 */
static void hp_audio_user_ev_handler(app_usbd_class_inst_t const * p_inst,
                                     app_usbd_audio_user_event_t   event)
{
    app_usbd_audio_t const * p_audio = app_usbd_audio_class_get(p_inst);
    UNUSED_VARIABLE(p_audio);
    switch (event)
    {
        case APP_USBD_AUDIO_USER_EVT_CLASS_REQ:
            hp_audio_user_class_req(p_inst);
            break;
        case APP_USBD_AUDIO_USER_EVT_RX_DONE:
        {
            ret_code_t ret;
            /* Block from headphones copied into buffer, send it into microphone input */
            #ifdef GRAB_DATA
            if(bigCount&amp;lt;99000){
                bigCount += m_temp_buffer_size;
            }
            else if(bigCount&amp;lt;100000){
                memcpy(muchLargerBuffer+smallCount, m_temp_buffer, m_temp_buffer_size);
                bigCount += m_temp_buffer_size;
                smallCount += m_temp_buffer_size;
            }
            else{
                NRF_LOG_INFO(&amp;quot;Stop Here!&amp;quot;);
            }
            #endif
            ret = app_usbd_audio_class_tx_start(&amp;amp;m_app_audio_microphone.base, m_temp_buffer, m_temp_buffer_size);
            if (NRF_SUCCESS == ret)
            {
                bsp_board_led_invert(LED_AUDIO_RX);
            }
            break;
        }
        default:
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The size of the buffer,&amp;nbsp;m_temp_buffer, is 2*48=96 but the size of the data sent is 192.&amp;nbsp; More specifically, m_temp_buffer_size is found to be 192 when watched in the debugger.&lt;/p&gt;
&lt;p&gt;I see 192 pop up in one more place, at the audio class definition.&amp;nbsp; However, I am not sure what the &amp;quot;Endpoint size&amp;quot; is supposed to be the size of any way.&lt;/p&gt;
&lt;p&gt;So it looks like data I am getting delivered is 96 bytes in size, like I would expect, but the size that is sent through to the usbd audio class is double that, which doesn&amp;#39;t make sense.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB Audio Half Used Packets</title><link>https://devzone.nordicsemi.com/thread/135771?ContentTypeID=1</link><pubDate>Tue, 12 Jun 2018 14:30:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec58888f-dded-4fa7-9cb0-9cfdf05e922c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sorry for the late reply. Are you still seeing this issue?&lt;/p&gt;
&lt;p&gt;Which version of the nRF52840 are you using? Note that engineering A (pca10056 v0.9.x and lower) workarounds have been removed from SDK 15.&lt;/p&gt;
&lt;p&gt;Also, have you edited the example in any way? I see that all samples in the&amp;nbsp;m_temp_buffer is filled up with non-zero values.&lt;/p&gt;
&lt;p&gt;The example is setup with a buffer size of 48 (times 2 for stereo, equals 192 bytes on the USB descriptor side), so I do not see how you should see 96 samples of zeroes unless the audio stream is such.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB Audio Half Used Packets</title><link>https://devzone.nordicsemi.com/thread/130661?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 16:57:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0af51ed9-a021-4352-8367-a742bb239c56</guid><dc:creator>Andrew</dc:creator><description>&lt;p&gt;Stereo.&amp;nbsp; When you do stereo the samples are interleaved.&amp;nbsp; Therefore, more specifically, the packet contains 48 samples of left and 48 samples of right.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB Audio Half Used Packets</title><link>https://devzone.nordicsemi.com/thread/130659?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 16:32:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08a64ddd-f3df-4808-8445-258b68b11d4d</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Mono vs. stereo?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>