You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How come I keep getting "Data Clipped" in my Command Window?
1 view (last 30 days)
Show older comments
Accepted Answer
Star Strider
on 29 Apr 2014
Edited: Star Strider
on 29 Apr 2014
You need to scale fur so that the maximum value is between [-1 +1] with wavwrite. Nice choice, BTW!
22 Comments
Edgar
on 29 Apr 2014
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
on 29 Apr 2014
Edited: Star Strider
on 29 Apr 2014
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
on 29 Apr 2014
When I added the code. I still get the data clipped message. See attached. Any suggestions?
Star Strider
on 29 Apr 2014
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.
Edgar
on 29 Apr 2014
Ahaha wow this is something else. I am still getting the same clipped message :(
Star Strider
on 29 Apr 2014
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
on 29 Apr 2014
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
on 29 Apr 2014
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
on 30 Apr 2014
Edited: Star Strider
on 30 Apr 2014
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
on 30 Apr 2014
Edited: Star Strider
on 30 Apr 2014
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
on 30 Apr 2014
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
on 30 Apr 2014
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
on 30 Apr 2014
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
on 30 Apr 2014
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
on 30 Apr 2014
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
on 30 Apr 2014
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
on 30 Apr 2014
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);
More Answers (0)
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)