how to read an audio file with a function that support code generation for Raspi?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Matlab_Beginner
am 2 Nov. 2022
Beantwortet: Prasanth Sunkara
am 10 Nov. 2022
i want to play audio on my Raspi, and i couldnt find a way on how to read an Audio File with a function that supports code generation. Only one exemple is shown in the Documentation about Audio Capture and it did not helped me.
in there a way how to do it, thanks in advance!
1 Kommentar
Walter Roberson
am 2 Nov. 2022
https://www.mathworks.com/help/dsp/ref/dsp.audiofilereader-system-object.html can have code generated -- but that code uses pre-defined dll that are not available for raspberry.
Akzeptierte Antwort
Walter Roberson
am 2 Nov. 2022
You can use putFile() to copy the file from the host to the Pi. But once it is there, there is no built-in support from MATLAB to play the file. You will need to system() the play command, or hook in to some appropriate library that exists on the Pi.
One particular audio file player is listed at https://www.makeuseof.com/tag/play-mp3-audio-raspberry-pi/
3 Kommentare
Walter Roberson
am 2 Nov. 2022
Note that audioplayer() exists for raspberry pi https://www.mathworks.com/help/supportpkg/raspberrypiio/ref/audioplayer.html and can be deployed.
That does not read from file though.
You might potentially be able to system() a program that reads the audio file and returns its samples -- that you can then play() with the audioplayer .
If you were to write raw sound data instead of an audio file, you could be even more certain of being able to handle it. I do not know at the moment whether fopen() can be deployed to the Pi, but it is worth a try. If so then the process would be to copy binary samples to the Pi, fopen() the file, fread() it, and then audioplayer() play() it.
The difference compared to your original question being that your original question asks to be able to support "audio files" -- which could potentially include a variety of file formats such as .mp3 and .avi and the audio track from H.265 video files, and could potentially include audio files with the same file extension but different encoders.
Weitere Antworten (1)
Prasanth Sunkara
am 10 Nov. 2022
Hi,
Have you tried Audio File read block of Simulink Support pacakge? Simulink Support Package offer more features for advanced workflows.
Thanks
0 Kommentare
Siehe auch
Kategorien
Mehr zu Code Generation and Deployment finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!