Is it possible to save audio sample values from alteration while using wavwrite function of matlab?

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)

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

My original audio object is 'y':
>>y=wavread('C:\Users\HIM\Desktop\audio stegno\strings.wav');
>>y(1:7)
ans =
1.0e-003 *
Columns 1 through 6
0 0 -0.213623046875000 0.091552734375000 0.305175781250000 0.305175781250000
Column 7
0.213623046875000
After manipulating it, i get new audio object 'y_enc' with values:
>>y_enc(1:7)
ans =
1.0e-003 *
Columns 1 through 6
0 0 -0.212620000000000 0.091453000000000 0.304180000000000 0.304180000000000
Column 7
0.212620000000000
Now i use wavwrite to create an audio file from this 'y_enc' like this:
>>wavwrite(y_enc,44100,'s.wav');
Now make another object from this "s.wav" file:
>>d=wavread('s.wav');
And i get sample values of 'd' as:
>> d(1:7)
ans =
1.0e-003 *
Columns 1 through 6
0 0 -0.213623046875000 0.091552734375000 0.305175781250000 0.305175781250000
Column 7
0.213623046875000
These values are not matching with those i have written using 'y_enc' but matching with original object 'y'.
Please tell me where i'm lacking?
Thanks in advance....
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?
I'm having problem.Probably because i'm working with large number of digits after decimal in samples.
Please try this:
My original audio object is:
>> y=wavread('C:\Users\HIM\Desktop\audio stegno\strings.wav');
>> y(1:7)
ans =
1.0e-003 *
0
0
-0.2136
0.0916
0.3052
0.3052
0.2136
New audio object created:
>> y2=y;
>> y2(1:7)=0.0005;
>> y2(1:7)
ans =
1.0e-003 *
0.5000
0.5000
0.5000
0.5000
0.5000
0.5000
0.5000
>> wavwrite(y2,44100,'k.wav') >> s=wavread('k.wav'); >> s(1:7)
ans =
1.0e-003 *
0.4883
0.4883
0.4883
0.4883
0.4883
0.4883
0.4883
Values of samples changed in object 's'.
I want that values of samples in 's' should remain same like in 'y2'.
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?
As you asked i tried it at different frequencies like 88200,10000,1000 and so on. But it still causing problem.
I have no idea what to do next.Please help if you can.
Thanks...
Okay finally i got the way to do it.This time i have chosen the bits in wavwrite as '32' like this:
>>wavwrite(y_enc,44100,32,'new_audio.wav')
It is working for me.
I think this can be helpful for others having the same problem.

Sign in to comment.

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Products

Asked:

on 21 Apr 2015

Commented:

on 23 Apr 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!