function encode_decode(codec) % ENCODE_DECODE(Coder) % Coder=1 AMR wideband coder at 4.75kbps % Coder=2 AMR wideband coder at 12.2kbps % Coder=3 G722 coder at 6.6kbps % Coder=4 G722 coder at 23.85kbps % Coder=5 G729 coder at 6.4kbps % Coder=6 G729 coder at 11.8kbps if (nargin < 1) help encode_decode; error('Too few input arguments'); end if codec>6 help encode_decode; error('The entered value is too big'); end codecs=[ 'amr_4750 '; 'amr_12200 '; 'g722_6600 '; 'g722_23850'; 'g729_6400 '; 'g729_11800'; ]; Path='./samples/'; s=input('Enter the filename :','s'); InputFile=[Path,s]; [fid, message] = fopen(InputFile); if ~isempty(message) error(message) end fclose(fid); BitFile=['./BitStream']; OutFile=strtrim([InputFile,'.',codecs(codec,:)]); % coding using the chosen codec switch codec case 1 % encoding stage disp('AMR wideband codec at 4.7kbps'); execline=sprintf('!wine amr_encoder MR475 %s %s',InputFile,BitFile); eval(execline); % decoding stage execline=sprintf('!wine ./amr_decoder %s %s',BitFile,OutFile); eval(execline); x=speechin(InputFile); y=speechin(OutFile); disp('The original signals ix in vector x'); disp('The decoded signal in vector y'); disp('Enter ">> dbcont" to exit the debug mode'); keyboard case 2 % encoding stage disp('AMR wideband codec at 12.2kbps'); execline=sprintf('!wine amr_encoder MR122 %s %s',InputFile,BitFile); eval(execline); % decoding stage execline=sprintf('!wine amr_decoder %s %s',BitFile,OutFile); eval(execline); x=speechin(InputFile); y=speechin(OutFile); disp('The original signals ix in vector x'); disp('The decoded signal in vector y'); disp('Enter ">> dbcont" to exit the debug mode'); keyboard case 3 % encoding stage disp('G722 codec at 6.60kbps'); execline=sprintf('!wine g722_encoder 0 %s %s',InputFile,BitFile); eval(execline); % decoding stage execline=sprintf('!wine g722_decoder %s %s',BitFile,OutFile); eval(execline); x=speechin(InputFile); y=speechin(OutFile); disp('The original signals ix in vector x'); disp('The decoded signal in vector y'); disp('Enter ">> dbcont" to exit the debug mode'); keyboard case 4 % encoding stage disp('G722 codec at 23.85kbps'); execline=sprintf('!g722_encoder 8 %s %s',InputFile,BitFile); eval(execline); % decoding stage execline=sprintf('!g722_decoder %s %s',BitFile,OutFile); eval(execline); x=speechin(InputFile); y=speechin(OutFile); disp('The original signals ix in vector x'); disp('The decoded signal in vector y'); disp('Enter ">> dbcont" to exit the debug mode'); keyboard case 5 % encoding stage disp('G729 codec at 6.4kbps'); execline=sprintf('!g729_encoder %s %s 0',InputFile,BitFile); eval(execline); % decoding stage execline=sprintf('!g729_decoder %s %s',BitFile,OutFile); eval(execline); x=speechin(InputFile); y=speechin(OutFile); disp('The original signals ix in vector x'); disp('The decoded signal in vector y'); disp('Enter ">> dbcont" to exit the debug mode'); keyboard case 6 % encoding stage disp('G729 codec at 11.8kbps'); execline=sprintf('!g729_encoder %s %s 2',InputFile,BitFile); eval(execline); % decoding stage execline=sprintf('!g729_decoder %s %s',BitFile,OutFile); eval(execline); x=speechin(InputFile); y=speechin(OutFile); disp('The original signals ix in vector x'); disp('The decoded signal in vector y'); disp('Enter ">> dbcont" to exit the debug mode'); keyboard end