This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

USB Audio input is not working on EK-TM4C1294XL board.

Other Parts Discussed in Thread: EK-TM4C1294XL

Hello, 

I'm now having the EK-TM4C1294XL board, and trying to make an application that captures the audio data from USB audio card which is connected to the 1294XL board.   In the TivaWare sample applications, there is the "usb_host_audio_in" application for the dk-tm4c129x board, so I'm now trying to port it onto 1294XL board.

Currently, the USB enumeration for the audio card was successful, and USB audio format for input was set to 48000/16bit/Stereo correctly, but the audio capture callback is not invoked when I play some audio from the USB audio card, so I cannot capture the audio data from USB audio card. 

I suspected that it was caused by the pinout configuration, so I tried various ways, but there's no luck, so I made very simple test application like the attached file, so can you please look at the code and let me know if there's any missing code or wrong configuration?

Any comment would be appreciate.

usb_host_audio_in_for_1294xl.zip

Thanks & B. Regards,

Inbae

  • Hello Inbae,

    Which audio input card is being used and does the USB protocol analyzer show that data IN to the TM4C129x is being streamed?

    Regards
    Amit
  • Hello Amit,

    Actually, I'm now testing it using 3 different USB audio cards(the below picture is the one of them), but all of the 3 USB cards show the same problem, so I suspect it was caused by the sample application.   I don't have any USB protocol analyzer, but I guess the USB audio cards were streaming the audio data into TC4C1294XL boards because the USB audio cards were working with the Windows PC. 

    So, can you please look at the sample application if there's any missing steps or something else? 

    BTW, when I searched the USB protocol analyzer, almost analyer are working on Windows system, so is ther any analyzer working on the TM4C1294XL board?

    Thanks & B. Regards,

    Inbae  

  • Hello Inbae,

    OK. Let us first look if a audio stream is sent from the TM4C to the USB Audio device, does it work?

    Note that an embedded device and PC are considered as different systems from USB perspective. An embedded device may not need to have every possible driver while a PC does have the capacity to have every possible driver.

    Also is the USB audio device a USB certified device? I have used a RealTek sound card (which is a USB certified product) and audio playback works.

    I am looking for a USB protocol analyzer like LeCroy.

    Regards
    Amit
  • Hello Amit,

    Yes, the audio stream is successfully sent from the TM4C to my USB audio devices, thus, the problem is only occurred for streaming from USB Audio device to TM4C. 

    Regarding to the USB certified devices or not, I'm not sure if it's certified or not, but I saw the USB certification mark on the device box.

    At this point, audio out(TM4C to USB device) is working fine, but the audio in(USB device to TM4C) is not working with the same configuration, so I have searched some documents to find out if there's any additional steps for audio input, but couldn't find it, so do you have any idea for it ? 

    Thanks & B. Regards,

    Inbae

  • Hello Inbae

    Which external Audio Device are you using?

    Regards
    Amit
  • Hello Amit,

    I'm now testing 3 different USB audio cards that were manufactured and selling in Korean market like the below pictures, but all the USB cards shows the same problem (audio playback is working well, but audio capture is not working as I raised this issue. ).   Today, I ordered another USB audio card which has the USB certification, so I'll test it using the device and let you know the testing result again.  

    BTW, is the audio capture working with your USB device on 1294XL board?

    Thanks & B. Regards,

    Inbae

        

  • Hello Inbae,

    In the last set of tests it was working. Let me order one of the portable one's like you have since the test rig uses a different USB sound card.

    Regards
    Amit
  • Hello Amit,

    Today, I've got another USB audio card that has the USB certification, but the result is the same as before ( Audio playing is working, but capturing is not working. ).

    So, I think that it's not the USB compatibility issue because the 4 different USB audio cards shows the same behavior, so I guess that it's caused by some problem in the USB host audio application interface or pin out configuration on 1294XL board, etc...  

    I think the usb host audio input has not been tested on TM4C 1294XL board because the 1294XL board doesn't have the usb audio sample applications, isn't it right?, if yes, please test it on the TM4C1294XL board with any USB audio card.

    Thanks & B. Regards,

    Inbae

  • Hello Inbae

    There is an audio input application on the DK-TM4C129x. That would help verify the application is working as expected or not. If not then a debug of that application with the new set of devices would be the first place I would be debugging. My USB audio devices are on their way, so I should have something to debug next week.

    Regards
    Amit
  • Hello Amit,

    Do you have any update on this issue?

    Any comment would be appreciated.

    Thanks & B. Regards,

    Inbae

  • Hello Inbae,

    Not yet. My debug time is on another issue. I may have to defer the debug of the USB Audio for now.

    Regards
    Amit
  • Hello Amit,

    Have you had any chances for debugging it?

    Any comments would be appreciated.

    Thanks & B. Regards,

    Inbae

  • Hello Inbae,

    Apologies for the delay on the issue debug. I will get promptly onto it.

    Regards
    Amit
  • Hello Amit,

    Any clue on this issue?

    Any comment will be appreciated.

    Thanks & B. Regards,

    Inbae

  • Hello Inbae

    The issue I found was that the wrong channel was set for input capture

    The following
    USBSoundInputFormatSet(48000, 16, 2)

    should be
    USBSoundInputFormatSet(48000, 16, 1)

    Regards
    Amit
  • Hi Amit,

    Thanks a lot for the information, I have verified that the audio capture callback is called continuously with your suggestion.

    But, let me ask a quick question, your suggestion is changing the capturing format to Mono from Stereo, 

    so does it mean that it's a bug on USB audio driver on 1294XL board? ( The USB host audio in sample application was also provided for the Stereo format. )

    Anyway, based on your suggestion, I'll try to capture the Mono audio on 1294XL board and try to play it on the same device with also Mono format, and get back to you if I have any problem for playing it with Mono on USB audio.

    Thanks again for the information.

    Thanks & B. Regards,

    Inbae

  • Hello Inbae,

    Yes, there was an issue with the usb_host_audio_in example code. The USB drivers were working all fine. Do note that the MIC will be mono unless the MIC you have will capture audio from two directions (highly unlikely in most day-2-day mics)

    Regards
    Amit
  • Hello Amit,

    Let me ask some more questions.

    The current status is :
    1. The usb_host_audio_input application is working well with Mono.
    2. The usb_host_audio_output application is working well with Stereo. (In case of output, only the stereo is working, Mono is not working, but it's not a problem in our project.)

    What we want to implement with USB audio :
    1. We want to implement a loop-back audio functionality. I mean that I want to play the audio data in real time that are captured from USB audio input.
    2. Thus, I made a sample application like this :
    Main task initializes the USB audio and creates two tasks, one is for capturing USB audio input data, the other one is for playing the captured audio data to USB output.
    3. For this app, my expectations were :
       3.1. The input callback will be called with USB_EVENT_RX_AVAILABLE whenever there're enough captured data in USB input buffer
       3.2. The output callback will be called with USB_EVENT_TX_COMPLETE whenever there're enough available buffer space on the USB output buffer.
    4. But, the real behavior on the board was :
    4.1. The input callback seems to be called with USB_EVENT_RX_AVAILABLE whenever there're enough captured data in USB input buffer.
    4.2. But, the output callback was called with USB_EVENT_RX_AVAILABLE(rather than USB_EVENT_TX_COMPLETE), so I think it's wrong and cannot play it.

    Thus, my questions are :
    1. Can the USBSoundBufferIn() and USBSoundBufferOut() be called simultaneously in one application?
    2. If I want to implement the loop-back audio functionality, is there any guide lines for how to implement it?

    Any comment would be appreciate.

    Thanks & B. Regards,
    Inbae

  • Hello Inbae,

    Yes, USBSoundBufferIn and USBSoundBuffferOut can be called in simultaneously, However we do not have an implementation for such a scenario within the application example and it needs to be checked as to how to do it.

    Regards
    Amit
  • Hello Amit,

    When I searched the documents, there's no comments about the simultaneous calling of USBSoundBufferIn/USBSoundBufferOut.
    Thus, can you please let me know how to do it?

    Thanks & B. Regards,
    Inbae

  • Hello Inbae,

    The example code given in TivaWare for usb_host_audio_in does that.

    Regards
    Amit
  • Hello Amit,

    The example code given in TivaWare for usb_host_audio_in does NOT show the simultaneouls calling of USBSoundBufferIn and USBSoundBuffferOut,
    it just captures audio data from USB audio input using USBSoundBufferIn(), and it plays the captured data into the speaker on the board using NON USB AUDIO API.

    So, let me explain the issue again, I want to implement the USB audio LOOPBACK functionality, it means that plays audio data into USB AUDIO OUTPUT while capturing the audio data from USB AUDIO INPUT, so I created two tasks, one task is capturing audio data from USB audio input using USBSoundBufferIn(), the other task is playing the data into USB audio output using USBSoundBufferOut(), but, in this case, the USB audio input/output callbacks are working as follow :
    1. The input callback is ivoked with USB_EVENT_RX_AVAILABLE whenever there're enough captured data in USB input buffer. it's good.
    2. But, the output callback was called also with USB_EVENT_RX_AVAILABLE(rather than USB_EVENT_TX_COMPLETE), it's not good, the output callback should be called with USB_EVENT_TX_COMPLETE.

    So, I guess that it's a bug in USB audio driver on 1294XL board, or USBSoundBufferIn and USBSoundBufferOut cannot be called simultaneously in one program, or the simultaneouse calling requires some additional procedures, etc..

    So, can you please let me know how can I implement the USB audio loopback functinality?

    Thanks & B. Regards,
    Inbae

  • Hello Inbae,

    As I mentioned earlier, there is no ready to use example. However to use the USBSoundBufferOut you have to refer to the usb_host_audio example and register the callback function.

    Regards
    Amit
  • Hello Amit,

    I'm still confusing, so let me ask it again for clarifying your answer. (sorry for annoying you.)

    I know the usb_host_audio example and usb_host_audio_in example are running well when I run them separately,
    but when I combined the usb_host_audio and usb_host_audio_in into one program, it doesn't work as expected becasue of the problem that I wrote earlier.

    So, can you please clarify what is the meaning of "there is no ready to use example"?, does it mean that I cannot get any further help on this issue from this forum?

    Thanks & B. Regards,
    Inbae
  • The USB bus is a highly complex matter - just download and read the specs. Experts with extensive knowledge are not very widespread. And for performance and resource reasons, this expertise is not primarily sought in the fields the Cortex M devices usually cover. And your question is highly specific. I a person in the know were present, he would probably have answered already.

    , does it mean that I cannot get any further help on this issue from this forum?

    Most likely, yes.

    But perhaps, Tsuneo Chinzei shows up here, to save your day ...

  • Hello Inbae,

    I would need a reference project from you which can work either on the DK-TM4C129x or EK-TM4C1294XL to see what the issue is.

    That would help me debug whether the issue is in the driver or not.

    Regards
    Amit
  • Hello Amit,

    Please find the attached sample application for EK-TM4C1294XL, the application is simplified as much as I can just for showing the problem.
    It creates two tasks, RenderTask is for playing audio to USB, CaptureTask is for capturing audio from USB.

    If you run it on the EK-TM4C1294XL, you can see only the "USBAudioInCallback() was invoked with 2 !!" messages because the USBAudioOutCallback() was called with "USB_EVENT_RX_AVAILABLE", so the USBAudioOutCallback() logs are not printed out.

    If you have any questions for the app, please let me know anytime.

    Usb_Audio_For_FreeRTOS.zip

    Thanks & B. Regards,
    Inbae

  • Hello Inbae,

    This will take time since I do not have access to protocol analyzer as of now.

    Regards
    Amit
  • Hello Inbae,

    I think I found the issue. In the usblib file usbhostenum.c line 4074-4077 reads as

    }
    else if(g_sUSBHCD.psUSBOUTPipes[ui32Idx].iState ==
    ePipeWriteDMASend)
    {

    This should have been

    }
    if(g_sUSBHCD.psUSBOUTPipes[ui32Idx].iState ==
    ePipeWriteDMASend)
    {

    After making the change and reducing the UARTprintf to just "I" and "O" for input or output, I can see the two alternating.

    I have filed a bug on the file and it would be corrected in TivaWare 2.1.4 (as 2.1.3 is already under release flow).

    Please check and confirm

    Regards
    Amit
  • Hello Amit,

    Thanks so much for the fix, finally, it's working now.

    Even though USB input is working only for mono whereas output is working only for stereo on 1294XL board, I can hear very clear audio with converting mono to stereo.

    Thanks again for the fix.

    Best Regards,
    Inbae

  • Hello Inbae,

    Glad that it fixed the issue (and apologies for the delay in the bug identification and fix)

    Regards
    Amit