![extract hidden message from odd part of wav - 2018 12 28.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199879/extract%20hidden%20message%20from%20odd%20part%20of%20wav%20-%202018%2012%2028.png)
extract hidden message from odd part of wav
4 views (last 30 days)
Show older comments
moustafa abada
on 28 Dec 2018
Commented: moustafa abada
on 29 Dec 2018
I want to extract the hidden message from the first half of the odd part of wavfile. so far, I write this code, I know it's simple but line 6 gives error, I don't know why
also, If I get the first half of the odd part, will the hidden message appear ? or should I do something ?
![Capture.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199876/Capture.png)
clear all
close all
clc
x = audioread('hidden_message (2).wav');
t=-10:10; %vector time
xmt=[fliplr(x(t>=0)) fliplr(x(t<0))] %or xo(t) = 1/2 (x(t) - x(-t))
subplot(3,1,3);
xo=0.5*(x-xmt)
subplot(3,1,3);
plot(t,xo);
title('Odd part')
4 Comments
Star Strider
on 28 Dec 2018
Your description of it as the ‘first half of the odd part’ leaves much room for interpretation.
The time-domain signal appears to be the result of the fftshift (link) function on the ‘Time’ axis here.
This is now quite obviously homework, so your instructor must have given you some information on how your instructor created the the .wav file.
You must enlighten us.
Accepted Answer
Image Analyst
on 28 Dec 2018
Edited: Image Analyst
on 28 Dec 2018
OK, I've tagged it homework for you, since you forgot.
So you can find the "origin" by using size() and ceil(). Find the number of samples, then divide by 2. Take note if it's a single channel, or a stereo waveform with two channels. Then divide the length by 2 and round up to the next higher integer. So it if's 5 long, the origin is at index 3. If it's 12 long, the origin is at index 6. But I imagine your prof made sure the waveform was an odd number do that the "zero" location would be exactly ON an element.
So then take that middle index and just extract every other element. So if zeroIndex is, say, 1358, then 1 would be at 1359, 2 would be at 1360, 3 would be at 1361, etc. So you want just the odd ones so you'd want indexes 1359, 1361, 1363, etc. So
oddElements = signal(zeroIndex + 1 : 2 : end);
Now you need to take the first half of that so you need to get the length and divide by 2 and that should be the final signal.
I didn't see anything in your Professor's question about reversing or appending anything. Take a look at it again below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199882/image.png)
More Answers (2)
Image Analyst
on 28 Dec 2018
Unfortunately you've delayed an answer for two reasons:
- You forgot to attach 'hidden_message (2).wav'
- You forgot to give us the error message (ALL the red text).
It also looks like you've never read this link
We'll check back later after you've had a chance to fix the post.
In the mean time,
this
xmt=[fliplr(x(t>=0)) fliplr(x(t<0))] %or xo(t) = 1/2 (x(t) - x(-t))
will take elements 11 - 21 of x and reverse them, then append the reversed first 10 elements of x.
However, it won't work because when you're using logical indexing you must have the same number of elements in the logical index as the array. So unless x is both 10 elements long, and 11 elements long, using t < or > 0 as a logical index will fail. And of course x can't be both 10 elements long at the same time that it's 11 elements long. Anyway x is probably way, way longer than 11 elements long if it's an audio file.
Basically your extraction routine is totally not right and we're not sure what the right algorithm is.
4 Comments
Walter Roberson
on 28 Dec 2018
However, it won't work because when you're using logical indexing you must have the same number of elements in the logical index as the array
No, the indexing array can be a different size than the original array. The last true value must be before the actual end of the array though.
Image Analyst
on 28 Dec 2018
You're right. When I had tested that before posting, I forgot to cast the 0 and 1 to logical like below:
data = [1,2,3,4,5,6,7,8,9,10] % 10 long
logicalIndex = logical([0,1,1,0,1,1]) % 6 long. logical() is REQUIRED
out = data(logicalIndex) % Works
Walter Roberson
on 28 Dec 2018
x = audioread('hidden_message (2).wav');
That will always give you as many columns as there are channels. If there is only one channel then there will be exactly one column. The only time x could end up as a row array is if there were exactly one sample and multiple channels... unlikely.
xmt=[fliplr(x(t>=0)) fliplr(x(t<0))]
The only time that logical indexing returns a row vector is if the item being indexed ( x here) is a row vector. In all other cases, including the item being indexed being a column vector or a 2D array (with more than one row) or a multidimensional array, then what is returned is a column vector. So since x is multiple rows and an unknown number of columns, x(t>=0) is going to return a column vector. fliplr() of a column vector leaves the column vector unchanged.
Now, fliplr(x(t<0)) also returns a column vector.
So you now have [CV1 CV2]. [] with space between the elements is horzcat(). But you can only horzat two column vectors if they have the same number of elements. Which probably is not the case.
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!