Gün Karagöz
Gün Karagöz

Reputation: 765

How to change endianness of a file?

I used MATLAB to change endiannness of a file. It works but endianness does not change. What's wrong with this code?

    f = fopen('139o.wav','r+');
    litEndFile=fread(f);

    fwrite(f,litEndFile,'int16',0,'ieee-be');
    fclose(f);

Upvotes: 0

Views: 956

Answers (1)

Juhl
Juhl

Reputation: 473

It should be working as long as the data file is indeed little endian, how did you check your result? With that construct I think you are appending the big endian data to the file. If you want to overwrite the file, call frewind(f) before fwrite(...).

Upvotes: 1

Related Questions