Is it possible to save audio sample values from alteration while using wavwrite function of matlab?
Show older comments
Hello, I am manipulating values of audio samples for audio steganography.When i have my manipulated audio sample object, i want to write it as a new audio file using wavwrite. But when i create object of this newly created audio file, i find sample values different from the previous values of samples which i had manipulated.
Is there any method to control wavwrite function in order to keep my sample values as same as these were before wavwrite?
Answers (1)
Image Analyst
on 21 Apr 2015
0 votes
You're either writing out the same, original audio data, not the altered data like you thought, or you're reading in the same original audio data, not the altered file.
6 Comments
manisha sharma
on 22 Apr 2015
Image Analyst
on 22 Apr 2015
This works just fine for me:
y=wavread('guitartune.wav');
y(1000:1007)
% Make y_enc
y_enc = y;
y_enc(1000:1007) = 0.5;
y_enc(1000:1007)
% Write it out.
wavwrite(y_enc,44100,'s.wav');
% Now make another object from this "s.wav" file:
d=wavread('s.wav');
d(1000:1007)
delete('s.wav');
ans =
-0.010437
-0.010132
-0.0099792
-0.010193
-0.010223
-0.009552
-0.0086365
-0.007843
ans =
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
ans =
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
What did you do differently?
manisha sharma
on 22 Apr 2015
Image Analyst
on 22 Apr 2015
I don't know that much about it. I wouldn't think doubles would have much of a problem out in the 5th decimal place but maybe it does. Or maybe it has something to do with encoding it at 44100. Can you try other rates?
manisha sharma
on 22 Apr 2015
manisha sharma
on 23 Apr 2015
Categories
Find more on Audio I/O and Waveform Generation 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!