How can I receive http audio streams in Matlab?
5 次查看(过去 30 天)
显示 更早的评论
I used to put the URL (ex: http://192.168.1.23:8000/stream.m3u) for the audio stream into Simulink Multimedia File Reader "File Name" parameter but this no longer functions. Is there a new way of getting streaming audio into a Simulink model? Is there a function that allows me to receive http streams in a Matlab script?
7 个评论
Massimo Serafini
2023-5-26
编辑:Massimo Serafini
2023-5-26
I'm trying to receive multiple HTTP streams to mix them in a multichannel output. Like:
fileName1 = "live Stream 1"
afr1 = dsp.AudioFileReader(fileName1);
fileName2 = "live Stream 2"
afr2 = dsp.AudioFileReader(fileName2);
adw = audioDeviceWriter('SampleRate', 48000,...
'Driver','ASIO',...
'Device','default',...
'BufferSize', 32,...
'BitDepth','24-bit integer',...
'ChannelMappingSource', 'property',...
'ChannelMapping',1:4);
setup(adw ,zeros(afr1.SamplesPerFrame,4))
tic
while ~isDone(afr) && toc<60
audio = [afr1() afr2()];
adw(audio);
end
release(afr1);
release(afr2);
release(adw);
and this works fine, just a a bit slow before it starts playing. Anyway, if I try to add more streams the script becomes unresponsive, and it exits reporting this:
Error using AudioFileReader
Could not add the data source to the filter graph.
I've tried to pin pot the problem, and my last guess is in that the several http requests create a too long packets waiting.
Do you have any suggestion on this issue?
Thanks
回答(2 个)
Urmila Rajpurohith
2019-8-5
Assuming you need to Process Audio file in your Simulink model:
The “From Multimedia File” block accepts the audio files which have extensions such as
.wav, .wma, .avi, .aif, .aifc, .aiff, .mp3, .au, .snd, .mp4, .m4a, .flac, .ogg
So if you need to access web based data use following function in MATLAB
webread(url)
And then you can access the data in Simulink using “From Workspace” block and can process it further.
You can refer to below documentation link for more details on how to use “webread” function.
0 个评论
Richard Keniuk
2019-8-26
编辑:Richard Keniuk
2019-8-26
1 个评论
Massimo Serafini
2023-5-25
Hi Richard,
did you found a workaround for getting the live audio stream with webread?
thanks
Massimo
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!