2016-10-03 11:56 AM
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-stereo2016-10-04 02:45 AM
Hello j.tobbe,
Have a look to the STM32F746G-DISCO discovery User manual ( ) to have more information about hardware features on the board.Regards2016-10-04 04:20 AM
> 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? JW2016-10-04 10:18 AM
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.
2016-10-04 10:39 AM
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.2016-10-04 10:48 AM
> 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. JW2016-10-05 09:43 AM
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.2017-02-03 04:34 PM
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.
2017-02-05 11:38 AM
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.
2017-02-23 04:25 PM
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 toif (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.