Audiowrite clipping warning issue..

12 views (last 30 days)
Edmund Paul Malinowski
Edmund Paul Malinowski on 24 Nov 2015
Answered: Walter Roberson on 25 Nov 2015
Hey all,
Part of my program is creating a melody of various sine waves and this all works as it should. It also saves the melody as a wav using audiowrite. When it saves, in the command line, i get orange warnings saying the signal clipped a bit.
Here's part of my code for the melody creation:
% CREATE A LOW PASS FILTER TO AVOID CLICKS IN THE FULL MELODY..
LPfiltX=designfilt('lowpassfir', 'PassbandFrequency', 1000, 'StopbandFrequency', 1100, 'PassbandRipple', 1, 'StopbandAttenuation', 60, 'SampleRate', Fs);
% FOR: LOOP THROUGH THE 7 USER CHOSEN NOTES..
for i = 1:7;
tX = 0:1/Fs:1; % TIME..
f = out(i); % FREQUENCY..
SineZ{i} = sin(2*pi*f*tX); % CREATE SINE WAVE..
end
% END FOR..
% CONCATENATE SINEZ ARRAY INTO ONE VARIABLE..
Wave = cell2mat(SineZ); % CONCATENATE VECTORS..
t_p = linspace(0, length(Wave), length(Wave)); % CREATE MATCHING TIME VECTOR..
% FILTER THE MELODY WITH THE LP FILTER..
MyOPfiltCREATE=filter(LPfiltX,Wave);
Here's the orange warning text:
Warning: Data clipped when writing file.
> In audiowrite>clipInputData (line 396)
In audiowrite (line 176)
In EPM_gui_form>btSAVEWAV_Callback (line 269)
In gui_mainfcn (line 95)
In EPM_gui_form (line 33)
In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)EPM_gui_form('btSAVEWAV_Callback',hObject,eventdata,guidata(hObject))
Is there any way to stop it clipping. Can i assign a maximum amplitude to the melody (signal) or apply a filter or something at the creation stage to keep the signals below a certain level?
Any ideas?
Thanks,
Paul..

Answers (1)

Walter Roberson
Walter Roberson on 25 Nov 2015
The valid range for the data in y depends on the data type of y.
double -1.0 ≤ y ≤ +1.0
If you data is out of that range you should divide it by max( abs(YourData(:)) )

Categories

Find more on Introduction to Installation and Licensing 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!