How come I keep getting "Data Clipped" in my Command Window?
2 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Star Strider
2014-4-29
编辑:Star Strider
2014-4-29
You need to scale fur so that the maximum value is between [-1 +1] with wavwrite. Nice choice, BTW!
22 个评论
Edgar
2014-4-29
Could you show me the end result of how the line of code should look like that can resolve my issue? And where do I paste it?
Star Strider
2014-4-29
编辑:Star Strider
2014-4-29
I no longer have wavwrite ( MATLAB R2014a has audioread and audoiwrite ) but the easiest way to scale fur to [-1 +1] is simply:
fur = fur/max(abs(fur));
Put it just before your wavwrite statement.
Edgar
2014-4-29
When I added the code. I still get the data clipped message. See attached. Any suggestions?
Star Strider
2014-4-29
As Walter Roberson noted in a similar answer, it may be necessary to scale it so that it’s never exactly [-1 +1].
Change the statement to :
fur = fur/max(abs(fur)+eps);
There’s a similar thread that started a few minutes ago.
Star Strider
2014-4-29
Your code doesn’t look very long. Post it as an attachment to your original question (use the ‘paperclip’ icon above the window). I'll run it and see if I can reproduce the error, and if all goes well, suggest a fix for the problem.
Star Strider
2014-4-29
I would appreciate your formatting it. I makes it easier to read and copy. Highlight your code, then click the [{}Code] button above the window.
Edgar
2014-4-29
Do you have an email address I could send you my code? I tried to post it, but .docx file is unsupported here for some odd reason.
Star Strider
2014-4-30
编辑:Star Strider
2014-4-30
It works perfectly for me.
I experimented, and changing the scaling line to:
fur = fur/max(abs(fur)+1E-4);
doesn’t change the sound, and no longer generates the ‘clipping’ warning! (Even adding 1E-5 generated the ‘clipping’ warning. Strange.)
Also, I suggest you change the fft plot to:
plot(f,abs(z))
to plot the amplitude of the fft. Otherwise, the plot only plots the real part, and gives a warning about ignoring the imaginary part. You might also consider:
axis([-750 750 ylim])
just after the plot statement. There doesn’t seem to be anything of significance outside those limits.
Star Strider
2014-4-30
编辑:Star Strider
2014-4-30
It’s not your version of MATLAB, it’s some sort of idiosyncrasy in wavwrite. I’m getting it too in R2014a. That’s probably the reason audiowrite and audioread are replacing the others.
Edgar
2014-4-30
I see, well my data clipping issue is resolved it doesn't popup anymore. Except my song doesnt work for some odd reasons because of format problems. I tried using windows media player and vlc media player and won't play the format for some reason. Any ideas?
Star Strider
2014-4-30
It plays perfectly for me.
Add:
soundsc(x)
after the wavread statement to hear it. Playing x rather than fur verifies that it saved and read successfully.
Edgar
2014-4-30
Yes! Its playing! Thanks so much! Now where can I control the song, meaning pause, play, stop, etc? It plays within matlab rather than an external app.
Star Strider
2014-4-30
Great!
I haven’t experimented much with audioplayer, but apparently it has those capabilities. I know that sound and soundsc don’t. If you have audioplayer, experiment with it to see if it will do what you want.
Image Analyst
2014-4-30
Just rename the function calls. But I believe audioplayer() is with the latest, or very recent versions only. At least that's when I started to get warnings to use audioplayer() instead of sound(). If you have R2014a you should be okay.
Star Strider
2014-4-30
If you save the files to a format compatible with Windows Media Player or some such, you should be able to play them through it. I don’t have access to the wavwrite documentation, so you will have to explore that to see. I remember that it was possible to save to different formats, but I don’t have recent experience with wavwrite, so I don’t remember the details. You may also have to ask Windows Media Player what it likes. Earlier versions played ‘.wav’ files.
Walter Roberson
2014-4-30
1E-5 might be lower than eps(abs(fur)). Instead of
fur/max(abs(fur)+eps);
should use
fur/max(abs(fur)*(1+eps));
or alternately
fur/max(abs(fur)+eps) * (1-eps);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 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 (한국어)