Receiving "too many output arguments" error in this code
Show older comments
I am trying to make a effects panel on Matlab App Designer using switch-case logic in order to check which filters are toggled and which are not.
function applyActiveTransformations(app)
audio = app.origFXAudioData;
for i = 1:length(app.activeTransformations)
switch app.activeTransformations{i}
case 'highpass'
cutoffFreq = (app.FxFs/2) - 100;
normalizedCutoff = cutoffFreq/(app.FxFs/2);
[b,a]=butter(4, normalizedCutoff, ...
'high');
audio = filtfilt(b,a,audio);
case 'lowpass'
cutoffFreq = (app.FxFs/2) - 5;
[b,a] = butter(4, cutoffFreq / (app.FxFs/2), 'low');
audio = filtfilt(b,a,audio) ;
case 'bandpass'
lowCutoff=(app.FxFs/2) - 10;
highCutoff = (app.FxFs/2) - 500;
[b,a]= butter(4, [lowCutoff, highCutoff]/(app.FxFs/2),'bandpass');
audio = filtfilt(b,a,audio);
case 'chipmunk filter'
nsemitones = 9;
audio = shiftPitch(audio,nsemitones);
case 'normalize'
audio = audio/max(abs(audio(:)));
end
end
app.procFxAudioData = audio;
end
Here is the callback function for one of the filters. The others follow the same logic:
function highpassButtonPushed(app, event)
if app.highpassButtonPushed.Value == 1
app.activeTransformations{end+1} = 'highpass';
else
app.activeTransformations = setdiff(app.activeTransformations, {'highpass'},'stable');
end
app.applyActiveTransformations();
end
10 Comments
Walter Roberson
on 7 Dec 2024
Which line is it complaining about, thinking that it has too many outputs ?
Stephen23
on 7 Dec 2024
Please show us the complete error message. That means all of the red text.
Rik
on 7 Dec 2024
That is not the complete message.
Walter Roberson
on 7 Dec 2024
The implication is that somehow app.highpassButtonPushed has become non-scalar, so app.highpassButtonPushed.Value is structure expansion (or object expansion) resulting in multiple parameters passed to disp()
However: the highpassButtonPushed code that you posted does not contain any disp() in it, so either you did not post the correct code or else the wrong version of the code is (somehow) executing.
Ria
on 7 Dec 2024
Edited: Walter Roberson
on 7 Dec 2024
Walter Roberson
on 7 Dec 2024
For the purposes of testing, on the line before
disp(app.highpassButtonPushed.Value)
insert
HIGHBUTTONPUSHED = app.highpassButtonPushed;
whos HIGHBUTTONPUSHED
and tell us what the result is at the time of the error.
Ria
on 7 Dec 2024
Walter Roberson
on 7 Dec 2024
Hmmm, change
HIGHBUTTONPUSHED = app.highpassButtonPushed;
whos HIGHBUTTONPUSHED
to
whos app event
for testing purposes.
At the moment, it appears that app is non-scalar and might possibly not be an app at all.
Ria
on 7 Dec 2024
Accepted Answer
More Answers (0)
Categories
Find more on Audio I/O and Waveform Generation 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!