I want to plot audio files in Vertically
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
i want to plot audio files in vertically...please refer the attachment.....please help me to solve this...
채택된 답변
Star Strider
2021년 10월 27일
.
댓글 수: 9
Deepu S S
2021년 10월 28일
Thank you so much
Star Strider
2021년 10월 28일
As always, my pleasure!
.
Deepu S S
2021년 11월 1일
Hi, may i get one more help......I have 30 audio files in a folder. There for i want to plot them all in vertically(strips)
Then use strips with each one. Unless they are short files, I do not recommend putting all of them in one strips plot, since the resulting plot will be unreadable.
However if putting them all in one plot is the objective, it would be easiest to vertically concatenate them first, then do the plot, assuming that they are all using the same sampling frequency. If they use different sampling frequencies, first use the resample function to create a matrix with a uniform sampling frequency for all the files.
.
Deepu S S
2021년 11월 2일
@Star Strider This is my code, can you guide me to clear the correction in my code please....
disp('entered')
disp(' Test run')
disp('Entered');
workspace; % Make sure the workspace panel is showing.
fontSize = 13;
% Specify the folder where the files live (unless a valid folder is hard coded in).
CHDFolder = '-'; %'D:\My Music\My Albums\Led Zeppelin\Early Days- The Best of Led Zeppelin, Vol. 1'; % Most awesome rock band of all time.
% Check to make sure that folder actually exists. Tell user to pick a folder if the folder doesn't exist.
disp('Entered');
if ~isfolder(CHDFolder)
promptMessage = sprintf('On the next window, please specify your folder of CHD Audio files.');
titleBarCaption = 'Folder?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if contains(buttonText, 'Quit')
return;
end
CHDFolder = uigetdir(CHDFolder);
if CHDFolder == 0
% User clicked Cancel.
return;
end
end
% Create a figure for the plots with the folder name at the top middle.
hFig = figure;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.1, 1, 0.9]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'This program was written by ImageAnalyst', 'NumberTitle', 'Off')
textLabel = uicontrol('Style','text', 'Units', 'normalized', 'Position', [0, 0.95, 1, 0.05], 'FontSize', 16, ...
'String', CHDFolder, 'HorizontalAlignment', 'center');
% Get a list of all files in the folder with the desired file name pattern.
% First define the extension you want to use.
extension = '*.mp3','*.wav';
filePattern = fullfile(CHDFolder, extension); % Change to whatever pattern you need.
theFiles = dir(filePattern);
% Bail out, with an error message, if there are no music files in that folder.
numberOfFiles = length(theFiles);
if numberOfFiles == 0
errorMessage = sprintf('Error: No %s CHD Audo files were found in folder:\n%s', extension, CHDFolder);
uiwait(errordlg(errorMessage));
close(hFig);
return;
end
% Now loop over all files, reading them in and plotting their audio waveforms.
rows = ceil(sqrt(numberOfFiles));
fprintf(1,'please wait', 'Now reading from folder %s\n', CHDFolder);
for k = 1 : numberOfFiles
% Get the filename of the audio waveforms.
baseFileName = theFiles(k).name;
fullFileName = fullfile(CHDFolder, baseFileName);
fprintf(1, ' Now reading "%s"\n','please wait', baseFileName);
% Read the audio waveforms.
[y, fs] = audioread(fullFileName);
numfiles = 20;
mydata = cell(1, numfiles);
for k = 1:numfiles
myfilename = sprintf('file%d.mp3', k);
mydata{k} = importdata(myfilename);
end
% To read all files that match *.jpg with imread:
audioFiles = dir('*.mp3');
numfiles = length(audioFiles);
mydata = cell(1, numfiles);
for k = 1:numfiles
mydata{k} = imread(audioFiles(k).name);
end
end
What is wrong with it?
I cannot run it to test it.
Deepu S S
2021년 11월 3일
function multiple_chd_Callback(hObject, eventdata, handles)
% hObject handle to multiple_chd (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Plots the audio waveforms of all the songs in a folder.
% By Image Analyst
% Defaults to MP3 extension files, but you can adapt it to handle any extension you want. Or even multiple extensions if you add code to do that.
% Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
fontSize = 13;
% Specify the folder where the files live (unless a valid folder is hard coded in).
CHDFolder = '-'; %'D:\My Music\My Albums\Led Zeppelin\Early Days- The Best of Led Zeppelin, Vol. 1'; % Most awesome rock band of all time.
% Check to make sure that folder actually exists. Tell user to pick a folder if the folder doesn't exist.
disp('Entered');
if ~isfolder(CHDFolder)
promptMessage = sprintf('On the next window, please specify your folder of CHD Audio files.');
titleBarCaption = 'Folder?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if contains(buttonText, 'Quit')
return;
end
CHDFolder = uigetdir(CHDFolder);
if CHDFolder == 0
% User clicked Cancel.
return;
end
end
% Create a figure for the plots with the folder name at the top middle.
hFig = figure;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.1, 1, 0.9]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'This program was written by DEEPU', 'NumberTitle', 'Off')
textLabel = uicontrol('Style','text', 'Units', 'normalized', 'Position', [0, 0.95, 1, 0.05], 'FontSize', 16, ...
'String', CHDFolder, 'HorizontalAlignment', 'center');
% Get a list of all files in the folder with the desired file name pattern.
% First define the extension you want to use.
extension = '*.mp3','*.wav';
filePattern = fullfile(CHDFolder, extension); % Change to whatever pattern you need.
theFiles = dir(filePattern);
% Bail out, with an error message, if there are no music files in that folder.
numberOfFiles = length(theFiles);
if numberOfFiles == 0
errorMessage = sprintf('Error: No %s CHD Audo files were found in folder:\n%s', extension, CHDFolder);
uiwait(errordlg(errorMessage));
close(hFig);
return;
end
% Now loop over all files, reading them in and plotting their audio waveforms.
rows = ceil(sqrt(numberOfFiles));
fprintf(1,'please wait', 'Now reading from folder %s\n', CHDFolder);
for k = 1 : numberOfFiles
% Get the filename of the audio waveforms.
baseFileName = theFiles(k).name;
fullFileName = fullfile(CHDFolder, baseFileName);
fprintf(1, ' Now reading "%s"\n','please wait', baseFileName);
% Read the audio waveforms.
[y, fs] = audioread(fullFileName);
%------------------------------------------------------------------------------
% Plot the waveform.
subplot(rows, rows, k);
tDouble = (1 : length(y)) / fs; % Get time axis as a double. Convert number of elements into actual seconds (still a double though).
tDouble = tDouble / 60; % Convert to minutes (still a double though).
tMin = datetime(0,0,0) + minutes(tDouble); % Convert variable class from "double" to "duration".
plot(tMin, y(:, 1)); % Display waveform.
%------------------------------------------------------------------------------
% Make the plot fancy.
% Make the time axis show up in mm:ss format
ax = gca;
% xt = datetime(0,0,0) + minutes(0 : 0.5 : max(tDouble)); % Tick marks every 30 seconds.
xt = datetime(0,0,0) + minutes(0 : 1 : max(tDouble)); % Tick marks every 1 minute.
xticks(xt);
xtickformat('m:ss');
ax.XTickLabel = ax.XTickLabel;
xlabel('Time');
grid on;
title(baseFileName, 'FontSize', fontSize);
% Have it end on the last element, not necessarily on minute boundaries.
xlim([datetime(0,0,0), tMin(end)]);
ylim([-1, 1]);
drawnow; % Force display to update immediately.
end
Deepu S S
2021년 11월 3일
@Star Strider please check.....
As I wrote previously —
‘What is wrong with it?’
‘I cannot run it to test it.’
If it throws an error, please copy and paste all the red text from the Command Window to a Comment here.
If it does not throw an error, please describe what it is doing that it should not do, or what it is not doing that it should do, and the part of the code that is causing those problems.
The code is too long and too complicated for me to read it and determine if there are any problems (I might miss them because my experience with App Designer is extremely limited since I have no reason to build Apps), and I cannot run it to test it because I do not have access to your computer, where the files that it works with are located.
I will be glad to help as much as I can, however I need to know what the problem is with the code.
.
추가 답변 (1개)
Deepu S S
2021년 11월 9일
function C_Test_Callback(hObject, eventdata, handles)
% hObject handle to C_Test (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
disp('entered')
disp(' Test run')
disp('Entered');
workspace; % Make sure the workspace panel is showing.
fontSize = 13;
% Specify the folder where the files live (unless a valid folder is hard coded in).
CHDFolder = '-'; %'D:\My Music\My Albums\Led Zeppelin\Early Days- The Best of Led Zeppelin, Vol. 1'; % Most awesome rock band of all time.
% Check to make sure that folder actually exists. Tell user to pick a folder if the folder doesn't exist.
disp('Entered');
if ~isfolder(CHDFolder)
promptMessage = sprintf('On the next window, please specify your folder of CHD Audio files.');
titleBarCaption = 'Folder?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if contains(buttonText, 'Quit')
return;
end
CHDFolder = uigetdir(CHDFolder);
if CHDFolder == 0
% User clicked Cancel.
return;
end
end
% Create a figure for the plots with the folder name at the top middle.
hFig = figure;
% c =uicontrol(VerticalAlignment);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.1, 1, 0.9]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
% vAlignObj = VAlign()
set(gcf, 'Name', 'This program was written by DEEPU', 'NumberTitle', 'Off')
textLabel = uicontrol('Style','text', 'Units', 'normalized', 'Position', [0, 0.95, 1, 0.05], 'FontSize', 16, ...
'String', CHDFolder, 'verticalalignment', 'center');
% Get a list of all files in the folder with the desired file name pattern.
% First define the extension you want to use.
extension = '*.mp3','*.wav';
filePattern = fullfile(CHDFolder, extension); % Change to whatever pattern you need.
theFiles = dir(filePattern);
% Bail out, with an error message, if there are no music files in that folder.
numberOfFiles = length(theFiles);
if numberOfFiles == 0
errorMessage = sprintf('Error: No %s CHD Audo files were found in folder:\n%s', extension, CHDFolder);
uiwait(errordlg(errorMessage));
close(hFig);
return;
end
% Now loop over all files, reading them in and plotting their audio waveforms.
rows = ceil(sqrt(numberOfFiles));
fprintf(1,'please wait', 'Now reading from folder %s\n', CHDFolder);
for k = 1 : numberOfFiles
% Get the filename of the audio waveforms.
baseFileName = theFiles(k).name;
fullFileName = fullfile(CHDFolder, baseFileName);
fprintf(1, ' Now reading "%s"\n','please wait', baseFileName);
% Read the audio waveforms.
[y, fs] = audioread(fullFileName);
%------------------------------------------------------------------------------
% Plot the waveform.
subplot(rows, rows, k);
tDouble = (1 : length(y)) / fs; % Get time axis as a double. Convert number of elements into actual seconds (still a double though).
tDouble = tDouble / 60; % Convert to minutes (still a double though).
tMin = datetime(0,0,0) + minutes(tDouble); % Convert variable class from "double" to "duration".
plot(tMin, y(:, 1)); % Display waveform.
%------------------------------------------------------------------------------
% Make the plot fancy.
% Make the time axis show up in mm:ss format
ax = gca;
% xt = datetime(0,0,0) + minutes(0 : 0.5 : max(tDouble)); % Tick marks every 30 seconds.
xt = datetime(0,0,0) + minutes(0 : 1 : max(tDouble)); % Tick marks every 1 minute.
xticks(xt);
xtickformat('m:ss');
ax.XTickLabel = ax.XTickLabel;
xlabel('Time');
grid on;
title(baseFileName, 'FontSize', fontSize);
% Have it end on the last element, not necessarily on minute boundaries.
xlim([datetime(0,0,0), tMin(end)]);
ylim([-1, 1]);
drawnow; % Force display to update immediately.
end
entered
Test run
Entered
Entered
Error using uicontrol
There is no verticalalignment property on the UIControl class.
Error in EEG_SCT>C_Test_Callback (line 10603)
textLabel = uicontrol('Style','text', 'Units', 'normalized', 'Position', [0, 0.95, 1, 0.05], 'FontSize', 16, ...
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in EEG_SCT (line 37)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)EEG_SCT('C_Test_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating Menu Callback.
카테고리
도움말 센터 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)
