필터 지우기
필터 지우기

uiputfile dont work anymore

조회 수: 7 (최근 30일)
Darko Kulic
Darko Kulic 2019년 4월 29일
댓글: Walter Roberson 2019년 5월 6일
Hello Matlab Community I have following problem, I wrote a little app and now i want to save some .wav files and the user choose the directory. I choosed uiputfile for this problem, and it worked perfect the first 20 test runs. I have a bunch of audiofiles created by uiputfile, but now it doesent creates anything. The weird thing is, the backup cloud, does a backup, after saving, but there is no data.... please help, there is no error message, no problem, no bug.... I dont know what to do!
if true
%% Button pushed function: applyButton
function applyButtonPushed(app, event)
toggleValue = app.toggleSwitch.Value; %% gets toggle switch value %% part of the code
if ( strcmpi(toggleValue,'Fuzz') ) %%checks value, string comparing
if(app.valc==4)
app.in_fuzz=app.audio_norm_custom; %%get user normalized audio
app.audioout=fuzz(app,app.in_fuzz);
elseif (app.valc==3)
app.in_fuzz=app.audio_norm; %%get first input normalized audio
app.audioout=fuzz(app,app.in_fuzz); %%create fuzz sound
end
audiowrite((uiputfile('fuzz_out.wav')),app.audioout,app.Fs); %%create . wav audiofile and save it
[app.in_fuzz,app.fuzz_path]=uigetfile('.wav'); %%get audio back
app.UIFigure.Visible='off'; %%keep app displayed
app.UIFigure.Visible='on';
app.straudiopth=fullfile(app.fuzz_path,app.in_fuzz); %%create string
app.audioout2_fuzz=audioread(app.straudiopth); %%read audio
app.audioout3=audioplayer(app.audioout2_fuzz,app.Fs);
app.valc=1; %%control var for play/stop
app.audioin=audioplayer(app.audio_norm,app.Fs); %%load audio in player
app.dt_plot_out = 1/app.Fs; %%create plot values/datas
app.t_plot_out= 0:app.dt_plot_out:(length(app.audioout2_fuzz)*app.dt_plot_out)-app.dt_plot_out;
plot(app.plot_out,app.t_plot_out,app.audioout); %%plot audio
title(app.plot_out,'Fuzz')
elseif ( strcmpi(toggleValue,'Overdrive') ) %%same process for overdrive as described for fuzz
if(app.valc==4)
app.in_ovd=app.audio_norm_custom;
app.audioout_ovd=overdrive(app,app.in_ovd,app.Fs);
elseif(app.valc==3)
app.in_ovd=app.audio_norm;
app.audioout_ovd=overdrive(app,app.in_ovd,app.Fs);
end
audiowrite((uiputfile('o_out.wav')),app.audioout_ovd,app.Fs) ;
[app.in_ovd,app.ovd_path]=uigetfile('.wav');
app.UIFigure.Visible='off';
app.UIFigure.Visible='on';
app.straudiopth1=fullfile(app.ovd_path,app.in_ovd);
app.audioout2_ovd=audioread(app.straudiopth1);
app.audioout4=audioplayer(app.audioout2_ovd,app.Fs);
app.valc=2;
app.dt_plot_out = 1/app.Fs;
app.t_plot_out= 0:app.dt_plot_out:(length(app.audioout2_ovd)*app.dt_plot_out)-app.dt_plot_out;
plot(app.plot_out,app.t_plot_out,app.audioout_ovd);
title(app.plot_out,'Overdrive')
end
end
% code
end
  댓글 수: 1
Jan
Jan 2019년 5월 5일
What exactly do you observe? "but now it doesent creates anything" is not clear enough. I do not understand thius also: "the backup cloud, does a backup, after saving, but there is no data".
Matlab's uiputfile fails, when the High Contrast mode of Windows is enabled. But this does not match your explanations.

댓글을 달려면 로그인하십시오.

답변 (2개)

Darko Kulic
Darko Kulic 2019년 5월 5일
  1. uiputfile doesnt create the file what I want to create with the function. Read carefully. The sentence says: I have created a bunch of audiofiles with uiputfile and now it doesn't create anything. So thats the problem, it worked the first 20 test runs perfectly and then it stopped creating files. See also the posted code.
  2. I have a backup cloud which always creates a new back up if i create a new file on my hdd(harddiskdrive.
But its fine if you cant help. I will find a solution.
I'm using mac os.
  댓글 수: 3
Jan
Jan 2019년 5월 6일
편집: Jan 2019년 5월 6일
@Darko Kulic: Please post comments in the section for comments, not as an answer.
Walter Roberson
Walter Roberson 2019년 5월 6일
You are passing the result of uiputfile() directly to audiowrite() . That can only work if the user happened to select a file name in the current directory. uiputfile does not return complete file names: just like uigetfile, it returns the last part of the name in the first output, and the directory in the second output. You should be sending the output of uiputfile() into two variables and putting them together with fullfile()

댓글을 달려면 로그인하십시오.


Jan
Jan 2019년 5월 6일
"it doesn't create anything" could mean, that you get an error message or that existing files are overwritten. Even if you repeat this and ask me to read it carefully again, you do not reveal what actually happens. You mention, that there are files copied to a backup. Does this mean that the files are created but empty?
As Walter has said already, uiputfile determines the file name and path only, so you cannot "create files" with it. I assume using the debugger will show you, what exactly happens. I guess, that your app.audioout_ovd is empty in the failing cases.
Your code contains:
if(app.valc==4)
app.in_ovd=app.audio_norm_custom;
app.audioout_ovd=overdrive(app,app.in_ovd,app.Fs);
elseif(app.valc==3)
app.in_ovd=app.audio_norm;
app.audioout_ovd=overdrive(app,app.in_ovd,app.Fs);
end
It is a safe programming style to define an else for all if's. What happens, if app.valc is neitehr 3 or 4?
By the way, what is the purpose of:
app.UIFigure.Visible='off'; %%keep app displayed
app.UIFigure.Visible='on';

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by