How to get data from Stm32 USB audio device and send to DAC? - audio

I am using a STM32F103RCT6 board with STM32CubeIDE. I enabled the USB Audio device and the code is working and windows recognized the board as an audio device or speaker.
I have searched and read documents but I have no idea what it is doing in the code.
The code is only MX_USB_DEVICE_Init();
1- Is it now receiving data from PC and saving them somewhere in RAM in a buffer?
2- How I can get access to the data and send them to DAC?
I am not going to use I2C and a codec because I don't have a codec IC. So I just want to use DAC to generate the audio to send to speakers.
Thanks!

Related

PCM data handling with Raspberry 4 and audio codec (TLV320AIC3104)

I´m working on a project with a Raspberry 4 compute module and IO board.
This is a schema of the project:
https://drive.google.com/file/d/1mg5IhAKTUE2Athzafis1KSsEJS1T7DXG/view?usp=sharing
I have to handle audio and voice to make calls with the raspberry. My setup consists of an audio box, which has a headset connected to it, pass the signal through a TLV320AIC3104 audio codec connected via PCM to the raspberry, and then make calls through a USB modem, which has an integrated audio card. I need two way communication.
So far, I can make the calls with the raspberry and have audio and voice with the caller, using a USB headset.
I am using the TLV320AIC3104EVM-K evaluation board (https://www.ti.com/lit/ug/slau218a/slau218a.pdf?ts=1664262721095&ref_url=https%253A%252F%252Fwww.ti.com%252Ftool%252FTLV320AIC3104EVM-K) to learn how to connect the audio codec to the raspberry, but so far I have been unable to get anything. When the TLV320AIC3104EVM-K is connected to the PC via USB I can use the headset passing through the audio box without problems.
The thing is I can´t figure out how to connect the audio codec to the raspberry to get the headset audio, and then finish the setup passing the information to the modem and back.
I understand that the connection between the TLV320AIC3104EVM-K and the Raspberry is actually an I2S connection. I have connected the GPIO PCM ports (GPIO 18, 19, 20, 21). I have configured the raspberry in the file /etc/asound.conf to have the card0 as default, being this card the one from the modem.
/etc/asound.conf
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
And have the GPIO ports configured to ALT0.
What am I missing here?

no audio data from PC send to STM32F4 audio class USB

I'm working in an audio project. We use stm32f407 like a USB audio device to get audio data from PC then send out by I2S module. We are using stm32f4 Discovery kit and STM32cubeMX. After generate code by following this video, i change nothing and flash to Kit; my PC identifies that STM Audio device but there isn't any data send to my kit when play music, except MuteCMD . My question is:
i don't know which function is callback when data stream from PC to Kit.
why PC identifies that my kit is an audio output device but the callback of volume control isn't called when I config volume on PC and there isn't any data of music send to my device. The only one mute control callback function is called when i mute the PC.
this is my config in STM32cubeMX
pinout config figure
USB device config figure 1
USB device config figure 2
USB device config figure 3
PC identifies AUDIO device figure
choosing PC's audio output device figure
fail to play test tone figure
You should set USBD_AUDIO_FREQ to 22050 (or 44100, or 11025). Your value is 22100 and it seems like Windows or built-in audio drivers can't use that frequency.
I had exact same problem.
My project is generated from STM32Cube.
Windows recognizes the F7-DISCO board as sound card but failed to play test sounds.
I changed USBD_AUDIO_FREQ to 48000 and PID to 0x5730 (22320 in decimal).
And then everything works fine.

Can anyone explain how voice commands works via Bluetooth remote(Nexus player remote) in Android(Nexus player)?

Can anyone please elaborate following questions?
How bluetooth stack handles audio data?
How audio commands are processed?
Did we need any service to process audio data?
Thanks in advance.
Basically, voice commands over BLE require:
some audio codec for reducing required bandwidth (ADPCM and SBC are common, OPUS is emerging),
some audio streaming method through BLE,
decoding and getting the audio stream from BLE daemon to a command processing framework.
In the android world, command processing framework is google sauce (closed) that most easily gets its audio from an ALSA device. What is left to be done is getting audio from the remote to an ALSA device.
So for audio streaming, either you:
use a custom L2CAP channel or a custom GATT service, this requires a custom android service app and/or modifications to Bluedroid to handle those, it will need a way to inject audio stream as ALSA, most probably with a "loop" audio device driver,
declare audio as custom HID reports, this way, Bluedroid injects them back to the kernel, then add a custom HID driver that processes these reports and exposes an audio device.
Audio over BLE is not standard, so all implementations do not do the actual same thing. In Nexus Player case, implementation uses HID: It streams an ADPCM audio stream, chunked in HID reports. There is a special HID driver "hid-atv-remote.c" in Android linux kernel that exposes an ALSA device in addition to input device. Bluedroid has no information about audio, all it does is forwarding HID reports from BLE to UHID.

Arduino nano, sound detection

I got an Arduino nano V3.0, connected via USB to my computer, and powered with the USB.
I want to use the nano to send a signal over the USB to the computer when it detects a sound of some amplitude.
Anybody knows how to connect a sound sensor to nano as easily as possible?
thanks
rough
I found this link useful http://arduinobasics.blogspot.com/2013/05/sound-sensor.html. Just connect sensor to arduino and adopt code for your needs (you don't need leds, just sensor). To send sensor status over USB use Serial class on Arduino and terminal application on PC.
You have 2 options, one of them is to buy a microphone which outputs a pulse when sound exceeds the threshold you've set on the potentiometer on the board, for example this one: Microphone Detector
The other option is to buy a microphone which outputs an analog stream which can be read by the A0 port on the Arduino Nano.
This Adafruit link can help you understand the code. As you can see, the analogRead(0); reads the A0 port of the arduino.

Cannot get clean sound from ZTE voice modem

My problem is associated with ZTE usb data modem.
ZTE USB modem have Communications(COM1), Diagnostics(COM2), Service(COM3) and Voice(COM4) ports. I can receive and send voice to voice port. But i can not get clean sound like WCDMA UI. How can I receive and send data with high quality?
Please look at my Visual C++ source code: http://serv7.boxca.com/files/0/z9g2d59a8rtw6n/ModemDial.zip
Does anyone now where is my error?

Resources