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.

Launchpad USB Audio In



I noticed that there is no USB audio example for the Stellaris Launchpad.  Does this mean that the Launchpad cannot act as a USB audio input device?  I have a custom microphone and I'd like to use the stellaris to hook four of them up and act as a USB audio device that has four channels.

If the launchpad can do audio in, where can I find an example?

  • Nathan,

    You are correct, In general alot of the USB examples did not get ported to the Stellaris launchpad. This does not mean it is not capable. All of the USB examples, including Host Audio can be found on the ek-lm4f232 board. Look in that boards examples directory. You will need verify and most likely change some pin mappings between the two boards, but it should be a straight forward and relatively simple port.

    Good Luck,

    -Austin

  • Hi Nathan,

    TivaWare (and StellarisWare) doesn't yet have any Audio In (ie. microphone device) example. They have just Audio Out (Speaker) device.

    We have discussed on Audio In implementation on this topic,
    "How to transfer microphone data via usb?"
    http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/201393.aspx

    It's a long discussion (four pages), but finally Andre has made his implementation.
    You may skip the first page, the "implementation guidance" starts at the second page.

    In this discussion, usbdaudio.c on SterallisWare 9453 was modified for microphone.
    On TivaWare, you'll modify usbdaudio.c, too.
    C:\ti\TivaWare_C_Series-2.0.1.11577\usblib\device\usbdaudio.c

    On TivaWare, prefix of variables and subroutines are changed, for example,
    static unsigned char g_pAudioDeviceDescriptor[] // SterallisWare 9453
    static uint8_t g_pui8AudioDeviceDescriptor[]    // TivaWare 2.0.1.11577

    But the major flow of the code is the same.

    I have a custom microphone and I'd like to use the stellaris to hook four of them up

    Do you like four microphones start/stop independently, or simultaneously?
    Depending on your requirement, USB configuration alters.

    Tsuneo

  • Tsuneo, all four mics will start simultaneously but I do need to be able to pull their audio into separate channels.  I will read the thread that you posted. 

    I did not see the usb_dev_audio example, only the usb_host_audio example.  I don't want to play the audio on the stellaris, I want the launchpad to act almost as a USB audio device that I can connect to a PC and record the audio.  I had planned on using the ADC on the stellaris to hook up the microphones.

  • Tsuneo, I think I am beginning to understand.

    So I need to modify the stellarisware library.


    Could I get you to look at this snippet of code to make sure I understand the descriptors.  I've changed them to what I think matches this http://www.usb.org/developers/devclass_docs/audio10.pdf in appendix B.

    From usbdaudio.c

    //*****************************************************************************
    //
    // The remainder of the configuration descriptor is stored in flash since we
    // don't need to modify anything in it at runtime.
    //
    //*****************************************************************************
    const unsigned char g_pAudioControlInterface[] =
    {
        //
        // Vendor-specific Interface Descriptor.
        //
        9,                          // Size of the interface descriptor.
        USB_DTYPE_INTERFACE,        // Type of this descriptor.
        AUDIO_INTERFACE_CONTROL,    // The index for this interface.
        0,                          // The alternate setting for this interface.
        0,                          // The number of endpoints used by this
                                    // interface.
        USB_CLASS_AUDIO,            // The interface class
        USB_ASC_AUDIO_CONTROL,      // The interface sub-class.
        0,                          // The interface protocol for the sub-class
                                    // specified above.
        0,                          // The string index for this interface.
    
        //
        // Audio Header Descriptor.
        //
        9,                          // The size of this descriptor.
        USB_DTYPE_CS_INTERFACE,     // Interface descriptor is class specific.
        USB_ACDSTYPE_HEADER,        // Descriptor sub-type is HEADER.
        USBShort(0x0100),           // Audio Device Class Specification Release
                                    // Number in Binary-Coded Decimal.
                                    // Total number of bytes in
                                    // g_pAudioControlInterface
        USBShort((9 + 9 + 12 + 13 + 9)),
        1,                          // Number of streaming interfaces.
        1,                          // Index of the first and only streaming
                                    // interface.
    
        //
        // Audio Input Terminal Descriptor.
        //
        12,                         // The size of this descriptor.
        USB_DTYPE_CS_INTERFACE,     // Interface descriptor is class specific.
        USB_ACDSTYPE_IN_TERMINAL,   // Descriptor sub-type is INPUT_TERMINAL.
        AUDIO_IN_TERMINAL_ID,       // Terminal ID for this interface.
                                    // USB streaming interface.
        USBShort(USB_TTYPE_MICROPHONE),
        0,                          // ID of the Output Terminal to which this
                                    // Input Terminal is associated.
        1,                          // Number of logical output channels in the
                                    // Terminal's output audio channel cluster.
        USBShort(USB_CHANNEL_L),    // Describes the spatial location of the
        							// logical channels.
        0,                          // Channel Name string index.
        0,                          // Terminal Name string index.
    
        //
        // Audio Output Terminal Descriptor.
        //
        9,                          // The size of this descriptor.
        USB_DTYPE_CS_INTERFACE,     // Interface descriptor is class specific.
        USB_ACDSTYPE_OUT_TERMINAL,  // Descriptor sub-type is INPUT_TERMINAL.
        AUDIO_OUT_TERMINAL_ID,      // Terminal ID for this interface.
                                    // Output type is a generic speaker.
        USBShort(USB_ATTYPE_STREAMING),
        0,       					// ID of the input terminal to which this
                                    // output terminal is connected.
        AUDIO_IN_TERMINAL_ID,       // ID of the feature unit that this output
                                    // terminal is connected to.
        0,                          // Output terminal string index.
    
    };
    
    //*****************************************************************************
    //
    // The audio streaming interface descriptor.  This describes the two valid
    // interfaces for this class.  The first interface has no endpoints and is used
    // by host operating systems to put the device in idle mode, while the second
    // is used when the audio device is active.
    //
    //*****************************************************************************
    const unsigned char g_pAudioStreamInterface[] =
    {
        //
        // Vendor-specific Interface Descriptor.
        //
        9,                          // Size of the interface descriptor.
        USB_DTYPE_INTERFACE,        // Type of this descriptor.
        AUDIO_INTERFACE_OUTPUT,     // The index for this interface.
        0,                          // The alternate setting for this interface.
        0,                          // The number of endpoints used by this
                                    // interface.
        USB_CLASS_AUDIO,            // The interface class
        USB_ASC_AUDIO_STREAMING,    // The interface sub-class.
        0,                          // Unused must be 0.
        0,                          // The string index for this interface.
    
        //
        // Vendor-specific Interface Descriptor.
        //
        9,                          // Size of the interface descriptor.
        USB_DTYPE_INTERFACE,        // Type of this descriptor.
        1,                          // The index for this interface.
        1,                          // The alternate setting for this interface.
        1,                          // The number of endpoints used by this
                                    // interface.
        USB_CLASS_AUDIO,            // The interface class
        USB_ASC_AUDIO_STREAMING,    // The interface sub-class.
        0,                          // Unused must be 0.
        0,                          // The string index for this interface.
    
        //
        // Class specific Audio Streaming Interface descriptor.
        //
        7,                          // Size of the interface descriptor.
        USB_DTYPE_CS_INTERFACE,     // Interface descriptor is class specific.
        USB_ASDSTYPE_GENERAL,       // General information.
        AUDIO_OUT_TERMINAL_ID,      // ID of the terminal to which this streaming
                                    // interface is connected.
        1,                          // One frame delay.
        USBShort(USB_ADF_PCM),      //
    
        //
        // Format type Audio Streaming descriptor.
        //
        11,                         // Size of the interface descriptor.
        USB_DTYPE_CS_INTERFACE,     // Interface descriptor is class specific.
        USB_ASDSTYPE_FORMAT_TYPE,   // Audio Streaming format type.
        USB_AF_TYPE_TYPE_I,         // Type I audio format type.
        1,                          // One audio channel.
        2,                          // Two bytes per audio sub-frame.
        16,                         // 16 bits per sample.
        1,                          // One sample rate provided.
        USB3Byte(8000),             // Only 48000 sample rate supported.
    
        //
        // Endpoint Descriptor
        //
        9,                              // The size of the endpoint descriptor.
        USB_DTYPE_ENDPOINT,             // Descriptor type is an endpoint.
                                        // OUT endpoint with address
                                        // ISOC_OUT_ENDPOINT.
        0x81,							// IN Endpoint 1.
        0x01,							// Isochronus, not shared.
        USBShort(8000), // The maximum packet size.
        1,                              // The polling interval for this endpoint.
        0,                              // Refresh is unused.
        0,                              // Synch endpoint address.
    
        //
        // Audio Streaming Isochronous Audio Data Endpoint Descriptor
        //
        7,                              // The size of the descriptor.
        USB_ACSDT_ENDPOINT,             // Audio Class Specific Endpoint Descriptor.
        USB_ASDSTYPE_GENERAL,           // This is a general descriptor.
        USB_EP_ATTR_ACG_NONE,           // Sampling frequency is supported.
        USB_EP_LOCKDELAY_UNDEF,         // Undefined lock delay units.
        USBShort(0),                    // No lock delay.
    };

    -Nathan

  • Your descriptors are fine, except for this field, if single microphone would be assigned.

    // Audio Header Descriptor.
    USBShort((9 + 9 + 12 + 13 + 9)),
    <--- Header (9) + Input Terminal (12) + Output Terminal (9)

    // Endpoint Descriptor
    USBShort(8000), // The maximum packet size.
    <--- USBShort( 8 * 2 )


    But you want to carry signals of four microphones.
    And then, the descriptor should be modified for four channels.

    // Audio Input Terminal Descriptor.
    1,   <--- 4      // Number of logical output channels in the
    USBShort(USB_CHANNEL_L),  
    <--- USBShort(USB_CHANNEL_L | USB_CHANNEL_R | USB_CHANNEL_LC | USB_CHANNEL_RC)

    // Format type Audio Streaming descriptor.
    1,   <--- 4      // Four audio channel.

    // Endpoint Descriptor
    USBShort(8000), // The maximum packet size.
    <--- USBShort( 8 * 2 * 4 )

    Tsuneo

  • Tsuneo,

    Quick question, why do you put USBShort( 8 * 2 ) instead of USBShort( 16 )?

    -Nathan

  • Either will do.

    Just to clarify 8 samples of two bytes.

    Tsuneo