我需要在progress
内显示四条text_h
条消息,但只有第一条' 正在加载音频... ',第二个' 计算价格特征...... '和最后一个' 完成!!! '正在展示。第三条消息' 计算唤醒功能...... '似乎在这个过程中迷失了方向。我还想知道如何让每封邮件留在text_h
内,并在下面一行打印一条新邮件,这样我就可以看到所有流程了吗?
function guiUpload(upload_button_h, evt, text_h, list_h, tracks, models)
global predict_arousal
global predict_valence
%% print to progress monitor
progress = 'Loading Audio...';
set(text_h, 'String', progress);
%% get reference to wave file
[filename, pathname] = uigetfile({'.wav'}, 'File Selector'); % {} filter file type
complete_path = strcat(pathname,filename); % concat both strings together
%% convert complete_path to WAV with samp freq
[x,fs] = audioread(complete_path);
x = sum(x, 2); % convert to monophonic by averaging
%% trim leading and trailing zeros from WAV vector
x = x(find(x,1,'first'):find(x,1,'last'));
%% print to progress monitor
progress = 'Computing Valence Features...';
set(text_h, 'String', progress);
%% get short-term spread [2xN], then convert to [1xN]
st_spread = stSpread(x, fs, 0.02, 0.01);
st_spread = st_spread(2,:); % get spread (2), not centroid (1)!
%% get mid-term statistics spread [2xN] 1 mean, 2 median
v_stat = {'mean', 'median'};
mt_spread = mtFeatureExtraction(st_spread, 3, 3, v_stat);
%% get global mean of spread statistics
mean_spread = mean(mt_spread(1,:));
median_spread = mean(mt_spread(2,:));
%% get global spectral flatnesss statistic - MIR TOOLBOX 1.6.1
flatness = mirflatness(complete_path);
flatness = get(flatness, 'Data');
flatness = flatness{1,1}{1,1};
%% get valence predictions for spread and flatness
predict_spread = models.valence.spread(mean_spread);
predict_med_spread = models.valence.med_spread(median_spread);
predict_flatness = models.valence.flatness(flatness);
%% test valence predictions to see if they are greater or less than -4, 4
predict_spread = guiTestPrediction(predict_spread);
predict_med_spread = guiTestPrediction(predict_med_spread);
predict_flatness = guiTestPrediction(predict_flatness);
%% average all valence predictions
valence = mean([predict_spread predict_med_spread predict_flatness]);
%% add valence statistic to predictions structure
predict_valence(end+1) = valence;
%% print to progress monitor
progress = 'Computing Arousal Features...';
set(text_h, 'String', progress);
%% get short-term energy [1xN]
st_energy = stEnergy(x, fs, 0.02, 0.01);
%% get mid-term statistics energy [3xN] 1 mean, 2 std, 3 median
a_stat = {'mean', 'std', 'median'};
mt_energy = mtFeatureExtraction(st_energy, 3, 3, a_stat);
%% get global mean of energy statistics
mean_energy = mean(mt_energy(1,:));
std_energy = mean(mt_energy(2,:));
median_energy = mean(mt_energy(3,:));
%% get arousal predictions for energy
predict_energy = models.arousal.energy(mean_energy);
predict_std_energy = models.arousal.std_energy(std_energy);
predict_med_energy = models.arousal.med_energy(median_energy);
%% test arousal predictions to see if they are greater or less than -4, 4
predict_energy = guiTestPrediction(predict_energy);
predict_std_energy = guiTestPrediction(predict_std_energy);
predict_med_energy = guiTestPrediction(predict_med_energy);
%% average all arousal predictions
arousal = mean([predict_energy predict_std_energy predict_med_energy]);
%% add arousal statistic to predictions structure
predict_arousal(end+1) = arousal;
%% add new filename to the end of the tracks array
tracks{end+1} = filename;
%% re-populate list_h with new songs array
set(list_h, 'String', tracks);
%% print to progress monitor
progress = 'Done!!!';
set(text_h, 'String', progress);
end
我text_h
的代码如下:
text_position = [0.025 0.05 0.95 0.90];
text_h = uicontrol('Parent', text_panel_h, 'Style', 'text','FontSize', 12,'HorizontalAlignment', 'Left','BackgroundColor','white','units', 'normalized', 'position', text_position, 'String', '');
答案 0 :(得分:0)
如果您的text_h
足以容纳所有邮件,您可以尝试使用新邮件更新其String
,而不是重写它以保留所有邮件:
% example of initialized text
set(text_h, 'String', 'test 1');
% update its String property
set(text_h, 'String', [get(text_h, 'String'); 'here is the new message']);
请注意,如果您使用多行,get(text_h, 'String')
将返回字符串的单元格数组。