我正在尝试使用UDP协议将matlab中的音频流传输到多个设备
matlab中的此代码使用UDP协议将音频从matlab发送到另一台设备
初始化
% Initialize several configuration parameters.
useMicrophone = false;
IP_address = '127.0.0.1';
IP_port = 30000;
sampleRate = 44100;
nChannels = 1;
freq = [100 99];
samplesPerFrame = 512;
% Create System objects to send local information to a remote client.
if useMicrophone
% NOTE: audioDeviceReader requires an Audio Toolbox (TM) license
localSource = audioDeviceReader('SampleRate', sampleRate,...
'NumChannels', nChannels); %#ok<UNRCH>
else
localSource = dsp.SineWave('SampleRate', sampleRate,...
'Frequency', freq(1:nChannels),...
'SamplesPerFrame', samplesPerFrame);
end
remoteSink = dsp.UDPSender('RemoteIPAddress', IP_address, ...
'RemoteIPPort', IP_port);
% Create System objects to listen to data produced by the remote client.
remoteSource = dsp.UDPReceiver('LocalIPPort', IP_port,...
'MaximumMessageLength', samplesPerFrame,...
'MessageDataType', 'double');
localSink = audioDeviceWriter('SampleRate', sampleRate);
流处理循环
fiveSeconds = 5*sampleRate;
for i=1:(fiveSeconds/samplesPerFrame)
% Connect the local source to the remote sink.
% In other words, transmit audio data.
localData = localSource();
remoteSink( localData(:));
% Connect the remote source to the local sink
% In other words, receive audio data.
remoteData = remoteSource();
if ~isempty(remoteData)
localSink(remoteData);
end
end
任何人都有一个想法,我如何才能使用UDP在php中接收此声音并在localhost中播放它