現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Encoding the signal with 14 bits
6 ビュー (過去 30 日間)
古いコメントを表示
Pat
2012 年 9 月 14 日
[f1,Fs1] = wavread('bird.wav');
sound(f1, Fs1);
i tried using
D=int14(f1* 8192)
I get error
Undefined function 'int14' for input arguments of type 'double'.
please help
1 件のコメント
回答 (1 件)
Star Strider
2012 年 9 月 14 日
編集済み: Star Strider
2012 年 9 月 14 日
I cannot find any reference to int14 in the online MATLAB documentation. If you want to truncate to 14 bit precision, there are two ways to do it with f1 being defined as a column vector. In my experience, .wav files are read as a [N x 2] matrix (one column for each stereo channel), so you will have to encode each column of f1 as 14-bit integers as separate operations. For column 1:
D = dec2bin( (f1(:,1) * 8192), 14);
or if D results a binary string longer than 14 bits, and since binary numbers are defined as strings:
D = dec2bin(f1(:,1) * 8192);
D = D(:,1:14);
then if you want to:
D = int16(bin2dec(D));
They will all be stored as 16-bit signed integers, but truncated in precision to 14 bits.
27 件のコメント
Walter Roberson
2012 年 9 月 14 日
Pat wants to encode the signal itself in 14 bits per sample, not in 14 bits precision per sample. Perhaps Pat is running on a machine with a 7 bit byte.
Star Strider
2012 年 9 月 14 日
That's possible, but a 7-bit byte is not something I can emulate on my machine. I have no idea how MATLAB would deal with that situation.
Anyway, in the absence of Fixed Point Toolbox functions (that I do not have access to and so have no experience with), this is the only way I can envision to produce something similar to what Pat wants.
At least it may provide Pat with some ideas to experiment with. It's the best I can do.
Pat
2012 年 9 月 15 日
Thanks a lot if not possible to encode the signal directly,is it possible to scale the wavelet coefficients in range[-(2^13-1),(2^13-1) ]
i have decomposed the sound sinal by dwt,so i have wavelet coefficients now
please help
Star Strider
2012 年 9 月 15 日
What do you want with the wavelet coefficients?
Why are you restricting your data to 14 bit resolution?
Pat
2012 年 9 月 18 日
i get error
Error using ==> dec2bin at 33 D must be a non-negative integer smaller than 2^52.
Error in ==> sample1 at 68 D = dec2bin( (ys(:,1) * 8192), 14);
Star Strider
2012 年 9 月 18 日
I do not know what ys(:,1) is, so be sure ys(:,1) > 0 and ys(:,1) < 2^52/8192.
Pat
2012 年 9 月 21 日
[f1,Fs1] = wavread('bird.wav');
ys = DWT2(f1, 100, 1)
ys=(ys*8192)%%%COnverting to 14 bits
now if take minimum value i get
min(ys)=-10495000
max(ys)=10965000
why i am gettin these values ,i need to represent as 14 bits only
Walter Roberson
2012 年 9 月 21 日
Sorry, I do not know how to determine what the theoretical maximum and minimum values returned by DWT2 would be, and I do not have that toolbox to test with.
Looking at that data range, it appears to me that possibly you should take the output of DWT2() and just round() it; it appears that would give you a signed integer with 14 bits needed for its representation (i.e., in the range -2048 to +2047). I cannot make any promises that that pattern will hold.
You would then have to decide which binary representation of negative numbers that you wanted to use when you converted the signed value to unsigned representation.
Walter Roberson
2012 年 9 月 21 日
Yes, that is consistent with what I wrote.
The range of values (-1281 to 1339) is 2620, which needs 14 bits to represent.
You will need to choose how you want to encode the signed integer values into the "14 bits" that are required for your purposes.
Pat
2012 年 9 月 21 日
Walter can u provide with an example plz,because i have no idea regarding encoding the signed integer values into the "14 bits"
Walter Roberson
2012 年 9 月 21 日
MATLAB does not have a 14 bit representation, except by using the Fixed Point Toolbox.
If you want the data stored within a larger variable (such as 16 bits) please indicate the representation you want to use.
Pat
2012 年 9 月 22 日
Sorry walter can you tell what you mean by "representation you want to use" as stated by you,because i still i dont have any idea regarding this
Walter Roberson
2012 年 9 月 22 日
Separate sign? One's compliment? Two's compliment? Extra bits within the larger word needed to store the 14 bits can be anything, or must be 0, or must be 1, or must be "sign extension" ?
Walter Roberson
2012 年 9 月 22 日
And the extra bits in the larger word? The smallest word that MATLAB can use to store 14 bits of information is a 16 bit word: how do you want the two extra bits to be treated?
ys = DWT2(f1, 100, 1);
ys = bitand( typecast(int16(ys),'uint16'), 2^14-1 );
Pat
2012 年 9 月 22 日
編集済み: Walter Roberson
2012 年 9 月 22 日
Walter as i said i donthave idea on this as i am new to signals ,can u please what are the ways in which the two extra bits to be treated,please
In
ys = bitand( typecast(int16(ys),'uint16'), 2^14-1 ),the last value must be 2^13-1,dont know it is correct ,please tell
Walter Roberson
2012 年 9 月 22 日
2^14-1 is correct in that code.
The above code zeros the extra two bits. It's as valid an approach as any other.
Really, things depend on what you are going to do with the 14 bit value.
Walter Roberson
2012 年 9 月 24 日
In 16 bit you do not need those manipulations as datatype int16() or uint16() are already the correct size for that purpose.
参考
カテゴリ
Help Center および File Exchange で Discrete Multiresolution Analysis についてさらに検索
タグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
