Translation of Matlab & Simulink models to SpecC specification Models

by

 

Involves translation of Matlab/Simulink models to Spec C specification models.

stdlsbenc.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%DATA EMBEDDING USING STANDARD LSB ALGORITHM %%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clc;
clear all;
close all;
warning off;

%%%%%%%%%%%%%%%%%%%%%%%%%%READING THE TEXT FILE%%%%%%%%%%%%%%%%%%%%%%%%%%%

fid=fopen('text.txt','r');
F=fread(fid);
str=char(F');
fclose(fid);

%%%%%%%%%%%%%%%%%%%%%%%CHARACTER TO BINARY CONVERSION%%%%%%%%%%%%%%%%%%%%%
wm=double(str);
wm1=dec2bin(wm);
wm2=wm1';
wm3=wm2(:);
binseq=wm3';
l=length(binseq);

%%%%%%%%%%%%%%%%%%%%%%%%%%%READING THE AUDIO FILE%%%%%%%%%%%%%%%%%%%%%%%%%

[x, Fs, N] = wavread('sss.wav');
figure,plot(x);

%%%%%%%%%%%%%%%%%%%%%%%EMBEDDING THE WATERMARK IN LSB%%%%%%%%%%%%%%%%%%%%%

no_samples = length(x) - 32*9;
pattern = randint(1,l,no_samples,0);
for i = 1:l
    sample = x(pattern(i),1);
    sample = (sample+1)*(2^15);
    sample = dec2bin(sample,16);
    sample(16) =num2str(binseq(i));
    sample = bin2dec(sample);
    sample = sample/(2^15) - 1;
    x(pattern(i),1) = sample;
end

%%%%%%%%%%%%%%%%%%%%%WRITING THE WATERMARKED AUDIO FILE%%%%%%%%%%%%%%%%%%%

wavwrite(x, Fs, N,'rec1.wav');
figure,plot(x);

Contact us