cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to record stereo audio through the line-in jack with the STM32F746G Discovery board?

misterstarshine
Associate III
Posted on October 03, 2016 at 20:56

Hi.

I would like to record stereo audio with the line-in jack on the STM32F746G Discovery board. I haven't seen any example that deals with stereo input. Is this supposed to be possible at all or is there a hardware of software limitation? According to the schematic the input jack is stereo and is connected in that manner to the audio codec.

Thanks in advance

#stm32f7-audio-stereo
16 REPLIES 16
slimen
Senior
Posted on October 04, 2016 at 11:45

Hello j.tobbe,

Have a look to the STM32F746G-DISCO discovery User manual (

http://www.st.com/content/ccc/resource/technical/document/user_manual/f0/14/c1/b9/95/6d/40/4d/DM00190424.pdf/files/DM00190424.pdf/jcr:content/translations/en.DM00190424.pdf

) to have more information about hardware features on the board.

Regards

Posted on October 04, 2016 at 13:20

> I haven't seen any example that deals with stereo input. Is this supposed to be possible at all or is there a hardware of software limitation?

> According to the schematic the input jack is stereo and is connected in that manner to the audio codec.

There's not only a stereo in jack but also a dual mic. I'd be very surprised if none of them would work.

But why don't you simply try, e.g. looping back the data to the same codec?

JW

misterstarshine
Associate III
Posted on October 04, 2016 at 19:18

Thanks for your reply. It seems like there are many software limitations. Excerpt from BSP_AUDIO_IN_OUT_Init routine for example


uint8_t BSP_AUDIO_IN_OUT_Init(uint16_t InputDevice, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)

{

uint8_t ret = AUDIO_ERROR;

uint32_t deviceid = 0x00;

uint32_t slot_active;


if
(InputDevice != INPUT_DEVICE_DIGITAL_MICROPHONE_2) 
/* Only MICROPHONE_2 input supported */

{

ret = AUDIO_ERROR;

}

else

{

/* Disable SAI */

SAIx_In_DeInit();

SAIx_Out_DeInit();

claims only ''microphone 2'' is supported. Another excerpt from wm8994_Init looks like this


/* Enable the DMIC2(Right) to AIF1 Timeslot 1 (Right) mixer path */

counter += CODEC_IO_Write(DeviceAddr, 0x609, 0x0002);


/* GPIO1 pin configuration GP1_DIR = output, GP1_FN = AIF1 DRC1 signal detect */

counter += CODEC_IO_Write(DeviceAddr, 0x700, 0x000D);

break
; 

case
INPUT_DEVICE_INPUT_LINE_2 :

default
:

/* Actually, no other input devices supported */

counter++;

break
;

}

}

else

{

inputEnabled = 0;

with the somewhat funny statement ''actually no other devices supported'' even for MIC2. Does anyone agree that these limitations appears intentional? Totally confusing code. If I knew how to modify the code to be able to perform DSP with stereo performance I'd be very happy.
Posted on October 04, 2016 at 19:39

I think you'll need to thoroughly review the codec documentation and its connectivity on the board. 

https://www.cirrus.com/en/products/pro/detail/P1325.html

Then view the code through that prism. It is more likely that the code supplied is the most lazy/expeditious implementation to demonstrate a base level of functionality. It is not the job of the engineers to provide a commercial ready solution, but to provide a starting point, and prove out the general plumbing of the hardware.

Codecs and audio paths/streams are complex topics, and hard to implement.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 04, 2016 at 19:48

> with the somewhat funny statement ''actually no other devices supported''

The line input is ''one device'' with two channels, IN1L and IN1P. Read the codec's datasheet thoroughly, matching it to the example code.

JW

misterstarshine
Associate III
Posted on October 05, 2016 at 18:43

Thanks Jan. This shines some light on this. The thing that confused me was that mic1 and mic2 are two mono devices that gives stereo when combined unlike for example line1 that is a stereo device.

I've already begun digging in the codecs datasheet and I think I could figure out how make the codec DSP ready fom a settings point of view. I'm much more concerned about how to configure the STM32F7 to do this and worst of all how to reconfigure DMA to do this properly. I've got a huge task in front of me and I wonder if I'm really capable of figuring this out.

In my opinion the configuration that enables input and output simultaneously through the same audio buffer that can be optionally modified is a very generic and all purpose configuration. It can be used for DSP as well as input only or output only. Strange that this has not been done on this board already and documented.

Posted on February 04, 2017 at 00:34

j.tobbe wrote:

In my opinion the configuration that enables input and output simultaneously through the same audio buffer that can be optionally modified is a very generic and all purpose configuration. It can be used for DSP as well as input only or output only. Strange that this has not been done on this board already and documented.

I agree completely. I got an stm32f746 with the intention of doing some real time DSP, but since I was unable to get line-in input and output simultaneously, it has been collecting dust.

hans23
Associate II
Posted on February 05, 2017 at 20:38

Hi,

i modified the STM32F746 DISCO Cube 'USB Waverecorder and Waveplayer Demo', so it works as Analog Audio Talkthru from Line In to Headphone Out! So my answer is ' Yes' you can read Line In as stereo audio, do any audio effect and output it at headphone out.

rad one
Associate
Posted on February 24, 2017 at 01:25

Hi,

You can get LineIn to Headphones by modifying one of the projects provided: 

/STM32Cube/Repository/STM32Cube_FW_F7_V1.6.0/Projects/STM32746G-Discovery/Examples/BSP/Src/audio_rec.c

by changing function call in the line #90 to

if (BSP_AUDIO_IN_Init

Ex

(

INPUT_DEVICE_INPUT_LINE_1

,DEFAULT_AUDIO_IN_FREQ, DEFAULT_AUDIO_IN_BIT_RESOLUTION, DEFAULT_AUDIO_IN_CHANNEL_NBR) == AUDIO_OK)

It works with loop buffer for 8s and plays recorded sound back - it is original purpose of this project. It's not instant stream but I hope I will figure out how to do it and do DSP in between. Maybe DSP will not work very well this way, I don't know. One disappointing thing I've noticed was noisy recording (or playing) - even for nothing plugged to LineIn. I'm really new to microprocessors and play it for only few days. I hope to gain more knowledge quickly.