cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Cube-based USB Device Microphone in Audio Class streaming to Host PC

maggie
Associate III
Posted on October 10, 2014 at 04:04

Hi,

Ideally, I'd like to have a firmware that has the following support:

  1. Cube-based
  2. Works in STM32F4
  3. Works as a dual-mode USB Device (not Host) in Audio Device Class, where these 2 endpoints are configured:

  • (a) 1 isochronous IN endpoint to handle audio coming from a host PC (to act as speaker)
  • (b) 1 isochronous OUT endpoint to handle audio coming out to a host PC (to act as microphone)

I already have a firmware that satisfies (1), (2) and (3.a) which is described in another

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F4Discovery%20Cube-based%20USB%20Speaker%20application%20not%20working&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=116

, but I'm having problems accomplishing (3.b).

Of course I already checked the ''Audio_playback_and_record'' common among STM32F4 and available in STM32CubeF4 package, however, the recording part there is configured as USB Host, not to mention that the USB Class is Mass Storage Class, not Audio Device Class.

I can see related post

/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/USB%20Audio%20Device%20with%20I2S%20microphone&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=2355

, but no conclusive answers (there was one saying he was able to do it but no details as to how were posted).

At this

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F4Discovery%20Cube-based%20USB%20Speaker%20application%20not%20working&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=116

post, I was informed by someone from the Cube team that there isn't such a program yet for USB Device microphone where audio is configured to go to host PC (as of September 2014).

However,

/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/USB%20Audio%20Device%20with%20I2S%20microphone&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=2355

post I mentioned reached almost 2400 views, so that only means many people are searching for the same topic and still searching answers up until now (no other posts have more info aside from this one)...

So I created this post.

Anyone who can provide reference for us to allow STM32F4 to support ''USB Device microphone where audio is configured to go to host PC''?

Any reference that could give us a jump start would do - then we can keep this thread rolling.

BTW, I have STM32F4-Discovery with STM32F407VGx on hand.

Since it has on-board CS43L22 DAC, a MP45DT02 MEMS microphone, DAC OUT for earphones, and of course USB Device mode port - it's the perfect device I can use for evaluation.

Thanks in advance to those who can contribute to this post.

Regards,

Maj

#stm32cubef4-usb-microphone-audio
11 REPLIES 11
Posted on October 13, 2014 at 11:10

Hi Maj,

We'll let our development team know about your suggestion.

Regards,

Heisenberg.

maggie
Associate III
Posted on October 14, 2014 at 09:10

To Heisenberg

- please let us know once the development team released this in the future versions of STM32CubeF4 examples, via posting to this thread.

I know it would be a hassle (sorry), but I'm saying for the benefit of all those who browses this forum, so that we/they can link the answer via your future post (ie ''this is already released as part of STM32CubeF4 vX.X...'').

To all other users

 - if you were able to make a firmware successfully with this setup, please still feel free to post.

Thank you very much!

delphi
Associate II
Posted on August 03, 2016 at 19:29

That sound good! We must give a lot of critics to ST engineers. They must introduce such example! I insist on that!

marek2399
Associate II
Posted on May 27, 2018 at 15:19

Well, so two years and nothing? Really ST engineers? Awsome job. Till now i was really glad to use STM but their support starts to be really terrible.

TWong.11
Associate

I've been struggling for weeks to implement audio upstreaming feature on a stm32f103 board with cube generated codes, I can only stream lagging and intermittent sounds by using USBD_LL_Transmit() at DATAIN stage for now, I'm going really desperate.. And why are such basic examples nowhere to be found.

Maybe because it's not that basic to get it right. You've just told it: you've made the basic example stitching up ready made pieces of code, and the result is less than satisfactory.

JW

MAdur
Associate

Good one, @maggie​ 

I am starting to try to do almost the same thing on a STM32F7. Have you had any progress?

Gabriel Melo
Associate III

Did anyone get it to work already? I got some luck using X-CUBE-MEMS1 package, the device is recognized as a mic; however, when I try to send samples I get some very strange results and noisy samples.

The way I did it I just used the usbd_audio_in.h and .c files instead of the default usbd_audio.h and .c provided by ST (and calling the initialization and send functions).

Klang.Martin
Associate III

I've been looking for a USB microphone example for a long time. I've done my own solution, but calling USBD_LL_Transmit from the DataIn callback doesn't seem very clean, and it means I can't send MIDI messages while streaming audio which is a big issue for some of my use cases.

Then today I found this: X-CUBE-USB-AUDIO

It has a complete example with audio record, playback, and feedback. It's pretty complex! Disappointingly it also calls USBD_LL_Transmit from DataIn, and of course there's no MIDI support.

To be honest I have no idea how you are supposed to use the Cube expansion packages. It doesn't show up when I do Manage Embedded Software Packages in STM32CubeMX (latest version v5.4.0). And if I download it, and then try to add the zip to Cube, it says it's not a supported format.

So instead I just unzip the package and look at the code, which is fine. At least it unzips the project contents, rather than a Windows-only exe like the Bluetooth packages!

Anyhow I just thought I'd share, as it might be useful for others.