I want to store my voice samples in a multiple voice packets and then want to store them in a buffer. The buffer size is 100ms and 500bytes. the packets will be played after 20ms interval.
Please help and guide.
No products are associated with this question.
5 Comments
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/58109#comment_121138
Does this happen to be about Simulink ?
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/58109#comment_132403
import java.net.Socket import java.io.*if (nargin < 3) number_of_retries = 20; % set to -1 for infinite endretry = 0; input_socket = []; message = [];retry = retry + 1; if ((number_of_retries > 0) && (retry > number_of_retries)) fprintf(1, 'Too many retries\n'); break; endtry fprintf(1, 'Retry %d connecting to %s:%d\n', ... retry, host, port);% throws if unable to connect input_socket = Socket(host, port);% get a buffered data input stream from the socket input_stream = input_socket.getInputStream; d_input_stream = DataInputStream(input_stream);% read data from the socket - wait a short time first pause(0.5); bytes_available = input_stream.available; fprintf(1, 'Reading %d bytes\n', bytes_available);message = zeros(1, bytes_available, 'uint8'); for i = 1:bytes_available message(i) = d_input_stream.readByte; end% cleanup input_socket.close; break;catch if ~isempty(input_socket) input_socket.close; end% pause before retrying pause(1); end end endDirect link to this comment:
http://www.mathworks.com/matlabcentral/answers/58109#comment_132404
import java.net.ServerSocket import java.io.*if (nargin < 3) number_of_retries = 20; % set to -1 for infinite end retry = 0;server_socket = []; output_socket = [];try if ((number_of_retries > 0) && (retry > number_of_retries)) fprintf(1, 'Too many retries\n'); break; endfprintf(1, ['Try %d waiting for client to connect to this ' ... 'host on port : %d\n'], retry, output_port);% wait for 1 second for client to connect server socket server_socket = ServerSocket(output_port); server_socket.setSoTimeout(1000);output_stream = output_socket.getOutputStream; d_output_stream = DataOutputStream(output_stream);% output the data over the DataOutputStream % Convert to stream of bytes fprintf(1, 'Writing %d bytes\n', length(message)) d_output_stream.writeBytes(char(message)); d_output_stream.flush;% clean up server_socket.close; output_socket.close; break;catch if ~isempty(server_socket) server_socket.close endif ~isempty(output_socket) output_socket.close end% pause before retrying pause(1); end end endDirect link to this comment:
http://www.mathworks.com/matlabcentral/answers/58109#comment_132405
system('matlab -nodisplay -r YourScriptName &')Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/58109#comment_132410
Dear Robert can you please explain to me how i will execute these client and server on the same machine. Kindly explain it step by step as I am new with the matlab and also with the networking portion of Matlab. I have found this code on the Mathworks forum.