The audio samples are in floating point representation.When i use dec2bin to convert the floating point number in binary, it only shows binary equivalent of digits before decimal point.But i want to reach LSB of the sample.
How to read LSB of audio sample?
7 views (last 30 days)
Show older comments
manisha sharma
on 27 Mar 2015
Commented: manisha sharma
on 29 Mar 2015
Hello everyone... I am working on audio steganography project.And i need to read and manipulate LSB of the audio sample.Please tell me a way to do this. Thanks in advance.
2 Comments
James Tursa
on 27 Mar 2015
Do you simply want to overwrite the trailing least significant byte of the mantissa with a different bit pattern? I.e., change the floating point value slightly but have your desired pattern embedded in the trailing bits?
Accepted Answer
James Tursa
on 27 Mar 2015
Here is an example of overwriting the least significant byte of a double with other bit patterns, in this case the string 'hidden':
% Arbitraty 6 element double vector
>> x = rand(1,6)
x =
0.957166948242946 0.485375648722841 0.800280468888800 0.141886338627215 0.421761282626275 0.915735525189067
% Find the location of the least significant byte in the double for this machine
>> LSB = find(typecast(1,'uint8')~=typecast(1+eps,'uint8'))
LSB =
1
% Re-interpret the bytes of the double vector as a uint8 vector
>> u = typecast(x,'uint8')
u =
Columns 1 through 35
153 127 112 148 28 161 238 63 82 133 98 6 101 16 223 63 124 40 48 201 229 155 233 63 216 151 19 224 84 41 194 63 202 83 230
Columns 36 through 48
8 35 254 218 63 32 30 143 150 180 77 237 63
% Our replacement data
>> s = 'hidden'
s =
hidden
% Construct the indexes for the replacement bytes
>> lower_bound = LSB
lower_bound =
1
>> upper_bound = LSB + 8*(numel(s)-1)
upper_bound =
41
% Replace the floating data with our new data
>> u(lower_bound:8:upper_bound) = s
u =
Columns 1 through 35
104 127 112 148 28 161 238 63 105 133 98 6 101 16 223 63 100 40 48 201 229 155 233 63 100 151 19 224 84 41 194 63 101 83 230
Columns 36 through 48
8 35 254 218 63 110 30 143 150 180 77 237 63
% Turn result back into double vector (note result is close to original x)
>> y = typecast(u,'double')
y =
0.957166948242940 0.485375648722843 0.800280468888797 0.141886338627212 0.421761282626269 0.915735525189076
% Now do the reverse to recover our hidden data
% Re-interpret the bytes of the double vector as a uint8 vector
>> w = typecast(y,'uint8')
w =
Columns 1 through 35
104 127 112 148 28 161 238 63 105 133 98 6 101 16 223 63 100 40 48 201 229 155 233 63 100 151 19 224 84 41 194 63 101 83 230
Columns 36 through 48
8 35 254 218 63 110 30 143 150 180 77 237 63
% Pick off our hidden bytes and re-interpret as a string
>> char(w(lower_bound:8:upper_bound))
ans =
hidden
3 Comments
More Answers (0)
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!