フィルターのクリア

Convert the wave file to a 16 bit signed binary format

29 ビュー (過去 30 日間)
Nishant Prakash
Nishant Prakash 2014 年 8 月 13 日
編集済み: dpb 2014 年 8 月 17 日
Hi, I am working with the audio codecs and I need to give an input to the encoder which mentions that the input should be 16 bit signed binary files. I have the wave files with me and am using wavread function to read it into an array. Once I read it into the array I am not sure how to convert it into signed 16 bit binary file.

採用された回答

dpb
dpb 2014 年 8 月 13 日
編集済み: dpb 2014 年 8 月 17 日
Would seem simplest to just use the optional FMT input argument to wavread and set the format of the returned values...
[Y,...]=wavread(...,FMT) specifies the data type format of Y used
to represent samples read from the file.
If FMT='double', Y contains double-precision normalized samples.
If FMT='native', Y contains samples in the native data type
found in the file. Interpretation of FMT is case-insensitive,
and partial matching is supported. If omitted, FMT='double'.
...
Output Scaling
The range of values in Y depends on the data format FMT specified.
Some examples of output scaling based on typical bit-widths found
in a WAV file are given below for both 'double' and 'native' formats.
FMT='native'
#Bits MATLAB data type Data range
----- ------------------------- -------------------
8 uint8 (unsigned integer) 0 <= Y <= 255
16 int16 (signed integer) -32768 <= Y <= +32767
Presumes, of course, your .wav file is 16-bit.
Otherwise,
doc int16
which also presumes the data will fit into a 16-bit integer.
  2 件のコメント
Nishant Prakash
Nishant Prakash 2014 年 8 月 15 日
Just a quick question: You are correct and I have tried it too and my wave file is 16 bit so if I use 'native' argument in the wavread then it will automatically store it as 16 bit signed integer or do I need to scale it in that range.
dpb
dpb 2014 年 8 月 17 日
編集済み: dpb 2014 年 8 月 17 日
Then should be 16-bit automagically. You can check by the result of
whos
at the command line on the variable when you read a file just to be certain -- or programmatically by
isa('int16',varname)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStandard File Formats についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by