classdef app < matlab.apps.AppBase % Properties that correspond to app components…
- User
classdef app < matlab.apps.AppBase
% Properties that correspond to app components properties (Access = public) UIFigure matlab.ui.Figure Lamp matlab.ui.control.Lamp SaveorNoSwitch matlab.ui.control.Switch ResetButton matlab.ui.control.Button tuadi matlab.ui.control.DropDown tuave matlab.ui.control.DropDown Image2_4 matlab.ui.control.Image Image2_5 matlab.ui.control.Image Menu matlab.ui.container.TabGroup Tab matlab.ui.container.Tab Image7_2 matlab.ui.control.Image Image7_3 matlab.ui.control.Image Image7 matlab.ui.control.Image FadeinFadeoutTab matlab.ui.container.Tab Image_2 matlab.ui.control.Image FadeoutLabel matlab.ui.control.Label Image matlab.ui.control.Image FadeinLabel matlab.ui.control.Label EditField_fadeout matlab.ui.control.NumericEditField EditField_fadein matlab.ui.control.NumericEditField cancelButton matlab.ui.control.Button applyButton matlab.ui.control.Button CutMusicTab matlab.ui.container.Tab CancelButton matlab.ui.control.Button Image6_2 matlab.ui.control.Image Image6 matlab.ui.control.Image CutButton matlab.ui.control.Button edit_end_cut matlab.ui.control.NumericEditField EndEditFieldLabel matlab.ui.control.Label edit_star_cut matlab.ui.control.NumericEditField StartEditFieldLabel matlab.ui.control.Label GhpMusicTab matlab.ui.container.Tab DeleteButton matlab.ui.control.Button DOWNButton matlab.ui.control.Button UPButton matlab.ui.control.Button craft_ListBox matlab.ui.control.ListBox LoadMultipleMP3Button matlab.ui.control.Button MergeButton matlab.ui.control.Button chnnhcTab matlab.ui.container.Tab VoGiyLabel matlab.ui.control.Label ChnButton matlab.ui.control.Button chen_EditField matlab.ui.control.NumericEditField LoadsecondmusicButton matlab.ui.control.Button UIAxes2 matlab.ui.control.UIAxes KhTab matlab.ui.container.Tab Button matlab.ui.control.Button PlayButton_khucam_2 matlab.ui.control.Button CancelButton_khu matlab.ui.control.Button PlayButton_khucam matlab.ui.control.Button PlayButton_khunhieu matlab.ui.control.Button Cut20Tab matlab.ui.container.Tab CancelButton_2 matlab.ui.control.Button CutButton_2 matlab.ui.control.Button nEditField_5 matlab.ui.control.NumericEditField TEditField_5 matlab.ui.control.NumericEditField nEditField_4 matlab.ui.control.NumericEditField TEditField_4 matlab.ui.control.NumericEditField nEditField_3 matlab.ui.control.NumericEditField TEditField_3 matlab.ui.control.NumericEditField nEditField_2 matlab.ui.control.NumericEditField TEditField_2 matlab.ui.control.NumericEditField nEditField matlab.ui.control.NumericEditField nEditFieldLabel matlab.ui.control.Label TEditField matlab.ui.control.NumericEditField TEditFieldLabel matlab.ui.control.Label TcniTab matlab.ui.container.Tab PlayButton_giamtoc matlab.ui.control.Button CancelButton_tocdo matlab.ui.control.Button PlayButton_tangtoc matlab.ui.control.Button TngTcEditField matlab.ui.control.NumericEditField TngTcEditFieldLabel matlab.ui.control.Label GimTcEditField matlab.ui.control.NumericEditField GimTcEditFieldLabel matlab.ui.control.Label oNgcTab matlab.ui.container.Tab daonguoc_button matlab.ui.control.Button CancelButton_daonguoc matlab.ui.control.Button Tuai1sButton matlab.ui.control.Button TuavButton matlab.ui.control.Button RestartButton matlab.ui.control.Button PlayButton matlab.ui.control.Button saveButton matlab.ui.control.Button LoadButton matlab.ui.control.Button Image2 matlab.ui.control.Image Image2_2 matlab.ui.control.Image UIAxes matlab.ui.control.UIAxes end properties (Access = private) AudioData % Dữ liệu âm thanh AudioSegments % Cell array chứa các dữ liệu âm thanh SampleRate % Tần số mẫu SampleRates % Danh sách các tần số mẫu ProcessedAudio % Dữ liệu âm thanh sau xử lý Player % Đối tượng phát âm thanh % Description PlayPauseButton IsPlaying = false; % Trạng thái phát âm thanh Timer % Đối tượng timer để cập nhật đồ thị Line % Đối tượng đường để cập nhật vị trí phát OriginalAudioData % Dữ liệu âm thanh gốc % Description FileList % Description SecondSampleRate SecondAudioData% Description SecondOriginalAudioData % Dữ liệu âm thanh gốc % Description ProcessedAudio2 % Description Player2 % Description time % Description speedFactor = 2 % Description saveorno % Description end methods (Access = private) function updatePlot(app) if isvalid(app.Player) && isvalid(app.Line) currentSample = app.Player.CurrentSample; numSamples = length(app.ProcessedAudio); % Cập nhật vị trí đường thẳng trên đồ thị set(app.Line, 'XData', [currentSample currentSample]); end end function start_line(app) % Khởi tạo đường thẳng để hiện vị trí phát âm thanh app.Line = line(app.UIAxes, 'XData', [1 1], 'YData', ylim(app.UIAxes), 'Color', 'k', 'LineWidth', 2); end function kiemtranhac(app) if isempty(app.OriginalAudioData) uialert(app.UIFigure, 'Chưa có file nhạc??.', 'Error'); return; end end function cancelhieuung(app) if isempty(app.OriginalAudioData) uialert(app.UIFigure, 'No audio loaded.', 'Error'); return; end % Khôi phục âm thanh về trạng thái gốc app.ProcessedAudio = app.OriginalAudioData; % Cập nhật đồ thị cla(app.UIAxes); plot(app.UIAxes, app.OriginalAudioData, 'b'); title(app.UIAxes, 'Hiệu ứng đã bị hủy bỏ'); legend(app.UIAxes, 'Original'); % Khởi tạo lại đối tượng audioplayer với âm thanh gốc app.Player = audioplayer(app.OriginalAudioData, app.SampleRate); % Đặt lại đường hiện vị trí phát app.start_line end function velaidothi(app) numSamples = length(app.AudioData); totalTimeInSeconds = numSamples / app.SampleRate; % Thiết lập các vị trí tick trên trục X app.UIAxes.XLim = [0 numSamples]; xticks = linspace(0, numSamples, 30); % Chia thành 10 đoạn app.UIAxes.XTick = xticks; % Gán nhãn cho ticks trên trục X sao cho hiển thị thời gian app.UIAxes.XTickLabel = arrayfun(@(x) sprintf('%.1f', x / app.SampleRate), xticks, 'UniformOutput', false); end % ko cần thiết có thể % function firtmain(app) % value11 = app.SaveorNoSwitch.Value; % if strcmp(value11, 'No') % app.saveorno = 'No'; % % else % app.saveorno = 'Yes'; % % end % end end % Callbacks that handle component events methods (Access = private) % Code that executes after component creation function startupFcn(app) end % Button pushed function: LoadButton function LoadButtonPushed(app, event) [file, path] = uigetfile('*.mp3', 'Select an MP3 file'); if isequal(file, 0) return; % Người dùng nhấn hủy end try [app.AudioData, app.SampleRate] = audioread(fullfile(path, file)); catch ME uialert(app.UIFigure, 'Failed to load audio file. Please select a valid MP3 file.', 'Error'); return; end app.Image2_5.Visible = "off" % Lưu dữ liệu gốc app.OriginalAudioData = app.AudioData; % Đặt lại các biến khi tải tệp mới app.ProcessedAudio = []; app.Player = []; app.IsPlaying = false; app.PlayPauseButton.Text = 'Play'; app.velaidothi app.ProcessedAudio = app.AudioData ; hold(app.UIAxes, 'on'); plot(app.UIAxes, app.ProcessedAudio, 'r'); title(app.UIAxes, 'Processed Audio'); legend(app.UIAxes, 'Original', 'Processed'); hold(app.UIAxes, 'off'); % Khởi tạo đối tượng audioplayer app.Player = audioplayer(app.ProcessedAudio, app.SampleRate); app.start_line end % Button pushed function: saveButton function saveButtonPushed(app, event) app.kiemtranhac [file, path] = uiputfile('*.mp3', 'Save Processed MP3'); if isequal(file, 0) return; % Người dùng nhấn hủy end audiowrite(fullfile(path, file), app.ProcessedAudio, app.SampleRate); uialert(app.UIFigure, 'File saved successfully!', 'Save'); end % Button pushed function: PlayButton function playandpauseButtonPushed(app, event) app.kiemtranhac if isempty(app.Player) app.Player = audioplayer(app.ProcessedAudio, app.SampleRate); end if app.IsPlaying % Tạm dừng phát pause(app.Player); app.IsPlaying = false; app.PlayButton.Text = 'Phát'; if ~isempty(app.Timer) stop(app.Timer); end else % Kiểm tra nếu là lần đầu tiên phát, sử dụng play % để bắt đầu phát từ đầu. Sử dụng resume nếu đã có. if strcmp(app.Player.Running, 'off') play(app.Player); else resume(app.Player); end app.IsPlaying = true; app.PlayButton.Text = 'Dừng'; % Khởi động hoặc tiếp tục timer if isempty(app.Timer) app.Timer = timer('ExecutionMode', 'fixedRate', ... 'Period', 0.1, ... 'TimerFcn', @(~,~) updatePlot(app)); start(app.Timer); elseif strcmp(app.Timer.Running, 'off') start(app.Timer); end end end % Button pushed function: RestartButton function RestartButtonPushed(app, event) % Kiểm tra nếu dữ liệu âm thanh gốc tồn tại if isempty(app.OriginalAudioData) uialert(app.UIFigure, 'No original audio data to reset.', 'Warning'); return; end % Khôi phục dữ liệu âm thanh về bản gốc app.ProcessedAudio = app.OriginalAudioData; % Cập nhật lại giao diện đồ thị cla(app.UIAxes); % Xóa đồ thị cũ plot(app.UIAxes, app.OriginalAudioData); title(app.UIAxes, 'Original Audio'); xlabel(app.UIAxes, 'Samples'); ylabel(app.UIAxes, 'Amplitude'); % Khởi tạo lại đối tượng audioplayer với dữ liệu gốc app.Player = audioplayer(app.OriginalAudioData, app.SampleRate); % Đặt lại các thuộc tính của ứng dụng như trạng thái phát app.IsPlaying = false; app.PlayButton.Text = 'Phát'; app.start_line; end % Button pushed function: TuavButton function TuaveButtonPushed(app, event) if ~isempty(app.Player) currentSample = app.Player.CurrentSample; % Chuyển đổi giá trị từ chuỗi sang số jumpSeconds = str2double(app.tuave.Value); % Tính số mẫu nhảy jumpSamples = jumpSeconds * app.SampleRate; newSample = max(currentSample - jumpSamples, 1); stop(app.Player); play(app.Player, newSample); end end % Button pushed function: Tuai1sButton function TuadiButtonPushed(app, event) if ~isempty(app.Player) currentSample = app.Player.CurrentSample; % Chuyển đổi giá trị từ chuỗi sang số jumpSeconds = str2double(app.tuadi.Value); % Tính số mẫu nhảy jumpSamples = jumpSeconds * app.SampleRate; newSample = min(currentSample + jumpSamples, length(app.AudioData)); stop(app.Player); play(app.Player, newSample); end end % Button pushed function: applyButton function applyfadeButtonPushed(app, event) app.kiemtranhac % Lấy giá trị từ các trường nhập fadeInDuration = app.EditField_fadein.Value; fadeOutDuration = app.EditField_fadeout.Value; % Tính toán số mẫu cho fade-in và fade-out fadeInSamples = round(fadeInDuration * app.SampleRate); fadeOutSamples = round(fadeOutDuration * app.SampleRate); % Tạo hiệu ứng fade-in và fade-out numSamples = length(app.AudioData); fadeIn = linspace(0, 1, fadeInSamples)'; fadeOut = linspace(1, 0, fadeOutSamples)'; steadyState = ones(numSamples - fadeInSamples - fadeOutSamples, 1); % Áp dụng phong bì âm lượng envelope = [fadeIn; steadyState; fadeOut]; app.ProcessedAudio = app.AudioData .* envelope; % Cập nhật đồ thị cla(app.UIAxes); hold(app.UIAxes, 'on'); plot(app.UIAxes, app.AudioData, 'b'); plot(app.UIAxes, app.ProcessedAudio, 'r'); legend(app.UIAxes, 'Original', 'Processed'); title(app.UIAxes, 'Chỉnh hiệu ứng fade in - fade out'); hold(app.UIAxes, 'off'); % Khởi tạo lại đối tượng audioplayer với âm thanh đã qua xử lý app.Player = audioplayer(app.ProcessedAudio, app.SampleRate); app.start_line end % Button pushed function: cancelButton function cancefadelButtonPushed(app, event) app.cancelhieuung end % Button pushed function: CutButton function CutButtonPushed(app, event) if isempty(app.OriginalAudioData) uialert(app.UIFigure, 'No audio data loaded.', 'Error'); return; end % Lấy thời gian bắt đầu và kết thúc từ người dùng startTime = app.edit_end_cut.Value; % Thời gian bắt đầu endTime = app.edit_star_cut.Value; % Thời gian kết thúc % Chuyển đổi từ thời gian (giây) sang mẫu startSample = round(startTime * app.SampleRate); endSample = round(endTime * app.SampleRate); % Kiểm tra tính hợp lệ của các giá trị if startSample < 1 || startSample >= endSample || endSample > length(app.OriginalAudioData) uialert(app.UIFigure, 'Invalid start or end time.', 'Error'); return; end % Cắt đoạn âm thanh app.ProcessedAudio = app.OriginalAudioData(startSample:endSample); app.velaidothi plot(app.UIAxes, app.ProcessedAudio); title(app.UIAxes, 'Đã Cắt'); % Tạo đối tượng audioplayer mới với âm thanh đã cắt app.Player = audioplayer(app.ProcessedAudio, app.SampleRate); app.start_line end % Button pushed function: CancelButton function CancelButtonPushed(app, event) app.cancelhieuung end % Button pushed function: LoadMultipleMP3Button function LoadMultipleMP3ButtonPushed(app, event) % app.Image2_5.Visible = "off" [files, path] = uigetfile('*.mp3', 'Select Multiple MP3 Files', 'MultiSelect', 'on'); if isequal(files, 0) return; % Người dùng nhấn hủy end if ischar(files) files = {files}; % Chuyển đổi thành cell array nếu chỉ có một file end % Khởi tạo danh sách chứa các dữ liệu âm thanh và tần số mẫu app.AudioSegments = {}; app.SampleRates = []; app.FileList = {}; % Khởi tạo danh sách tên file for i = 1:length(files) [audioData, sampleRate] = audioread(fullfile(path, files{i})); app.AudioSegments{end+1} = audioData; app.FileList{end+1} = files{i}; % Lưu tên file if isempty(app.SampleRates) app.SampleRates = sampleRate; elseif app.SampleRates ~= sampleRate uialert(app.UIFigure, 'Sample rates do not match across files', 'Error'); app.AudioSegments = {}; app.SampleRates = []; app.FileList = {}; return; end end % Cập nhật `ListBox` app.craft_ListBox.Items = app.FileList; app.craft_ListBox.ItemsData = 1:length(app.FileList); end % Button pushed function: UPButton function UPButtonPushed(app, event) idx = app.craft_ListBox.Value; if idx > 1 app.AudioSegments([idx-1, idx]) = app.AudioSegments([idx, idx-1]); app.craft_ListBox.Items([idx-1, idx]) = app.craft_ListBox.Items([idx, idx-1]); app.craft_ListBox.Value = idx - 1; end end % Button pushed function: DOWNButton function DOWNButtonPushed(app, event) idx = app.craft_ListBox.Value; if idx < length(app.AudioSegments) app.AudioSegments([idx, idx+1]) = app.AudioSegments([idx+1, idx]); app.craft_ListBox.Items([idx, idx+1]) = app.craft_ListBox.Items([idx+1, idx]); app.craft_ListBox.Value = idx + 1; end end % Button pushed function: MergeButton function MergeButtonPushed(app, event) app.Image2_5.Visible = "off" if isempty(app.SampleRates) uialert(app.UIFigure, 'Sample rate data is missing.', 'Error'); return; end % Ghép các đoạn âm thanh app.ProcessedAudio = vertcat(app.AudioSegments{:}); app.SampleRate = app.SampleRates(1); % Tần số mẫu chung app.velaidothi % Cập nhật đồ thị với âm thanh đã ghép cla(app.UIAxes); plot(app.UIAxes, app.ProcessedAudio); title(app.UIAxes, 'Merged Audio'); xlabel(app.UIAxes, 'Samples'); ylabel(app.UIAxes, 'Amplitude'); % Tạo đối tượng audioplayer mới với âm thanh đã ghép if ~isempty(app.ProcessedAudio) app.Player = audioplayer(app.ProcessedAudio, app.SampleRate); else uialert(app.UIFigure, 'No audio to play.', 'Error'); end app.start_line end % Button pushed function: DeleteButton function DeleteButtonPushed(app, event) % Lấy giá trị được chọn từ craft_ListBox selectedData = app.craft_ListBox.Value; % Xem lại nếu `Value` là một phần tử duy nhất % Đảm bảo rằng ItemsData không rỗng và chứa dữ liệu phù hợp if isempty(app.craft_ListBox.ItemsData) uialert(app.UIFigure, 'ItemsData is empty.', 'Warning'); return; end % Tìm chỉ số của selectedData trong ItemsData selectedIndex = find([app.craft_ListBox.ItemsData] == selectedData); % Kiểm tra chỉ số có hợp lệ không if isempty(selectedIndex) uialert(app.UIFigure, 'Invalid selection to delete.', 'Warning'); return; end % Xóa phần tử khỏi danh sách âm thanh và tên file app.AudioSegments(selectedIndex) = []; app.FileList(selectedIndex) = []; % Cập nhật craft_ListBox app.craft_ListBox.Items(selectedIndex) = []; app.craft_ListBox.ItemsData(selectedIndex) = []; % Cập nhật giá trị chọn default if ~isempty(app.FileList) app.craft_ListBox.Value = app.craft_ListBox.ItemsData(1); else app.craft_ListBox.Value = []; end end % Button pushed function: CancelButton_2 function CancelButton_2Pushed(app, event) app.cancelhieuung end % Button pushed function: CutButton_2 function CutButton_2Pushed(app, event) app.kiemtranhac% Lấy dữ liệu âm thanh gốc audioData = app.OriginalAudioData; sampleRate = app.SampleRate; % Đảm bảo tần số mẫu được chọn đúng % Tạo danh sách để chứa các đoạn âm thanh đã cắt cutSegments = {}; % Lấy thời gian bắt đầu và kết thúc từ các EditField startTimes = [app.TEditField.Value, app.TEditField_2.Value]; % Thêm/giảm nếu cần thêm endTimes = [app.TEditField_2.Value, app.nEditField_2.Value]; % Thêm/giảm nếu cần thêm % Cắt các đoạn âm thanh dựa trên thời gian được nhập for i = 1:length(startTimes) startTime = startTimes(i); endTime = endTimes(i); % Chuyển đổi từ giây sang mẫu startSample = round(startTime * sampleRate); endSample = round(endTime * sampleRate); % Kiểm tra tính hợp lệ của chỉ số mẫu if startSample < 1 || startSample >= endSample || endSample > length(audioData) uialert(app.UIFigure, sprintf('Invalid time interval [%d, %d]', startTime, endTime), 'Error'); continue; end % Cắt đoạn âm thanh trong khoảng được chỉ định cutSegment = audioData(startSample:endSample); cutSegments{end+1} = cutSegment; end % Hiển thị nhiều đoạn đã cắt trên `UIAxes` cla(app.UIAxes); hold(app.UIAxes, 'on'); colors = lines(length(cutSegments)); for i = 1:length(cutSegments) plot(app.UIAxes, (1:length(cutSegments{i})) / sampleRate, cutSegments{i}, 'Color', colors(i, :)); end hold(app.UIAxes, 'off'); title(app.UIAxes, 'Cropped Audio Segments'); xlabel(app.UIAxes, 'Time (s)'); ylabel(app.UIAxes, 'Amplitude'); end % Button pushed function: ResetButton function ResetButtonPushed(app, event) % Xác nhận xóa âm thanh gốc selection = uiconfirm(app.UIFigure, 'Bạn có chắc chắn muốn xóa âm thanh gốc và khởi động lại?', ... 'Xác nhận Xóa', ... 'Options', {'Có', 'Không'}, ... 'DefaultOption', 2); if strcmp(selection, 'Không') return; end % Xóa dữ liệu âm thanh gốc và xử lý app.OriginalAudioData = []; app.ProcessedAudio = []; app.AudioData = []; % Xóa Player nếu đang có if ~isempty(app.Player) stop(app.Player); app.Player = []; end % Cập nhật lại UIAxes cla(app.UIAxes); % Xóa mọi đồ họa hiện tại title(app.UIAxes, 'No Audio Loaded'); xlabel(app.UIAxes, 'Samples'); ylabel(app.UIAxes, 'Amplitude'); % Cập nhật giao diện điều khiển khác app.PlayButton.Text = 'Phát'; app.IsPlaying = false; % Xóa line phát (nếu có) if isvalid(app.Line) delete(app.Line); app.Line = []; end end % Button pushed function: LoadsecondmusicButton function LoadsecondmusicButtonPushed(app, event) % Hỏi người dùng chọn file âm thanh thứ hai [file, path] = uigetfile('*.mp3', 'Select a Secondary MP3 File'); if isequal(file, 0) return; % Người dùng nhấn hủy end try % Tải dữ liệu âm thanh thứ hai [app.SecondAudioData, app.SecondSampleRate] = audioread(fullfile(path, file)); % Kiểm tra tần số mẫu nếu cần if ~isempty(app.OriginalAudioData) && app.SecondSampleRate ~= app.SampleRate uialert(app.UIFigure, 'Sample rates do not match. Please choose a file with the same sample rate.', 'Error'); app.SecondAudioData = []; return; end % uialert(app.UIFigure, 'Secondary MP3 file loaded successfully!', 'Success'); app.SecondOriginalAudioData = app.SecondAudioData; app.ProcessedAudio2 = []; cla(app.UIAxes2); plot(app.UIAxes2, app.SecondAudioData); title(app.UIAxes2, 'HuuDO Music 2'); % Xác định độ dài âm thanh theo giây numSamples = length(app.SecondAudioData); totalTimeInSeconds = numSamples / app.SampleRate; % Thiết lập các vị trí tick trên trục X app.UIAxes2.XLim = [0 numSamples]; xticks = linspace(0, numSamples, 10); % Chia thành 10 đoạn app.UIAxes2.XTick = xticks; % Gán nhãn cho ticks trên trục X sao cho hiển thị thời gian app.UIAxes2.XTickLabel = arrayfun(@(x) sprintf('%.1f', x / app.SampleRate), xticks, 'UniformOutput', false); app.ProcessedAudio2 = app.SecondAudioData ; hold(app.UIAxes2, 'on'); plot(app.UIAxes2, app.ProcessedAudio2, 'r'); title(app.UIAxes2, 'Processed Audio'); legend(app.UIAxes2, 'Original', 'Processed'); hold(app.UIAxes2, 'off'); end end % Button pushed function: ChnButton function ChenButtonPushed(app, event) % Kiểm tra nếu cả hai âm thanh đều đã tải if isempty(app.AudioData) || isempty(app.SecondAudioData) uialert(app.UIFigure, 'Both audio files must be loaded to insert an audio segment.', 'Error'); return; end % Lấy tần số mẫu sampleRate = app.SampleRate; % Nhập thời gian chèn từ người dùng (theo giây) % insertTime = app.chen_EditField.Value; % insertSample = round(insertTime * sampleRate); % Lấy dữ liệu từ hai tệp âm thanh audio1 = app.AudioData; audio2 = app.SecondAudioData; % Chèn audio2 vào audio1 tại vị trí chỉ định % newAudio = [audio1(1:insertSample-1); audio2; audio1(insertSample:end)]; if(length(audio1)>length(audio2)) audio1=audio1(1:length(audio2),:); else audio2=audio2(1:length(audio1),:) end audiotong=audio1+0.5*audio2; % Cập nhật ProcessedAudio với dữ liệu mới app.ProcessedAudio = audiotong; % Cập nhật đồ thị cla(app.UIAxes); plot(app.UIAxes, app.ProcessedAudio); title(app.UIAxes, 'Audio with Inserted Segment'); xlabel(app.UIAxes, 'Samples'); ylabel(app.UIAxes, 'Amplitude'); % Khởi tạo lại audioplayer app.Player = audioplayer(app.ProcessedAudio, sampleRate); app.start_line end % Button pushed function: PlayButton_khunhieu function PlayButton_khunhieuPushed(app, event) app.kiemtranhac data = app.AudioData; fs = app.SampleRate; % Load the sample rate time_duration = 0.05; % Duration for each frame in seconds n = floor(time_duration * fs); % Number of samples per frame N_frame = floor(length(data) / n); nguong = 0.005; % Threshold value to determine noise new_sig = zeros(length(data), 1); % Noise reduction process for i = 1:N_frame frame = data((i-1)*n+1:i*n); val = max(frame); if val > nguong new_sig((i-1)*n+1:i*n) = frame; end end % Update ProcessedAudio with noise-reduced signal app.ProcessedAudio = new_sig; % Plot the original and noise-reduced signals app.velaidothi hold(app.UIAxes, 'on'); plot(app.UIAxes, (1:length(data)) / fs, data, 'b'); plot(app.UIAxes, (1:length(new_sig)) / fs, new_sig, 'r'); hold(app.UIAxes, 'off'); title(app.UIAxes, 'Original and Noise Reduced Audio'); xlabel(app.UIAxes, 'Time (s)'); ylabel(app.UIAxes, 'Amplitude'); legend(app.UIAxes, 'Original', 'Noise Reduced'); % Create a new audioplayer instance for the processed audio app.Player = audioplayer(app.ProcessedAudio, fs); app.start_line end % Button pushed function: CancelButton_khu function CancelButton_khuPushed(app, event) app.cancelhieuung end % Button pushed function: PlayButton_khucam function PlayButton_khucamPushed(app, event) app.kiemtranhac % Lấy tần số mẫu và dữ liệu âm thanh data = app.AudioData; fs = app.SampleRate; % Đọc cài đặt từ giao diện time = 0.05 % Độ dài khung nguong = 0.05 % Ngưỡng % Tính toán số mẫu mỗi khung n = floor(time * fs); Nframe = floor(length(data) / n); newdata = zeros(length(data), 1); newdata1 = []; % Quá trình khử nhiễu for i = 1:Nframe frame = data((i-1)*n+1:i*n); giatri = max(frame); if giatri > nguong newdata((i-1)*n+1:i*n) = frame; newdata1 = [newdata1; frame]; % Chắc chắn rằng frame là vector cột end end % Đảm bảo rằng newdata1 là một hoặc hai kênh if size(newdata1, 1) < size(newdata1, 2) newdata1 = newdata1'; % Chuyển về vector cột nếu cần end if size(newdata1, 2) > 2 newdata1 = mean(newdata1, 2); % Chuyển thành mono nếu có nhiều hơn hai kênh end % Cập nhật dữ liệu đã xử lý mới app.ProcessedAudio = newdata1; % Vẽ lại đồ thị sóng âm thanh app.velaidothi % Cập nhật audioplayer app.Player = audioplayer(app.ProcessedAudio, fs); app.start_line end % Button pushed function: PlayButton_khucam_2 function PlayButton_khucam_2Pushed(app, event) app.kiemtranhac au = app.AudioData; % Dữ liệu âm thanh gốc fs = app.SampleRate; % Tần số mẫu out = au; % Khởi tạo biến output N = 5000; % Delay in samples heso = 0.6; % Echo attenuation factor [x, y] = size(au); % Lấy kích thước âm thanh % Áp dụng echo dựa trên số kênh if y == 2 % Stereo for n = N+1:length(au) out(n,1) = heso * out(n-N,1) + au(n,1); out(n,2) = heso * out(n-N,2) + au(n,2); end else % Mono for n = N+1:length(au) out(n) = heso * out(n-N) + au(n); end end % Cập nhật ProcessedAudio app.ProcessedAudio = out; % Cập nhật đồ thị app.velaidothi cla(app.UIAxes); xlabel(app.UIAxes, 'Time (s)'); ylabel(app.UIAxes, 'Amplitude'); legend(app.UIAxes, 'Original', 'Echoed'); % Tạo audioplayer mới cho audio đã echo và phát app.Player = audioplayer(app.ProcessedAudio, fs); app.start_line end % Button pushed function: Button function ButtonPushed(app, event) % speedFactor > 1 để tăng tốc, speedFactor < 1 để giảm tốc newFs = app.SampleRate * app.speedFactor; % Tạo một audioplayer với tần số mẫu mới app.Player = audioplayer(app.AudioData, newFs); play(app.Player); end % Button pushed function: PlayButton_giamtoc function PlayButton_giamtocPushed(app, event) app.kiemtranhac % Lấy giá trị từ EditField speedt = app.GimTcEditField.Value; if speedt <= 0 uialert(app.UIFigure, 'Speed factor must be greater than zero.', 'Error'); return; end % Sử dụng lcm để chuyển đổi speedt thành tỉ lệ mẫu nguyên L = lcm(1, round(1/speedt * 1000)); P = round(L * speedt); Q = L; % Resample audio data resampledAudio = resample(app.AudioData, P, Q); % Cập nhật và lưu dữ liệu âm thanh đã xử lý app.OriginalAudioData = resampledAudio; % Cập nhật giao diện đồ thị với tốc độ mới hold(app.UIAxes, 'on'); plot(app.UIAxes, (1:length(app.AudioData)) / app.SampleRate, app.AudioData, 'b'); % Original hold(app.UIAxes, 'off'); title(app.UIAxes, 'Đã áp dụng giảm tốc'); xlabel(app.UIAxes, 'Time (s)'); ylabel(app.UIAxes, 'Amplitude'); legend(app.UIAxes, 'Original'); % Khởi tạo đối tượng audioplayer với tần số mẫu mới app.Player = audioplayer(app.OriginalAudioData, newFs); app.start_line end % Button pushed function: PlayButton_tangtoc function PlayButton_tangtocPushed(app, event) app.kiemtranhac % Lấy giá trị từ EditField speedt = app.TngTcEditField.Value; % Tạo tần số mẫu mới, dựa trên tốc độ phát mong muốn newFs = app.SampleRate * speedt; % Điều chỉnh âm thanh resampledAudio1 = resample(app.AudioData, 1, speedt); % Lưu âm thanh đã điều chỉnh tốc độ vào Origin để sử dụng sau app.OriginalAudioData = resampledAudio1; % Cập nhật giao diện đồ thị với tốc độ mới hold(app.UIAxes, 'on'); plot(app.UIAxes, (1:length(app.AudioData)) / app.SampleRate, app.AudioData, 'b'); % Original hold(app.UIAxes, 'off'); title(app.UIAxes, 'Đã áp dụng giảm tốc'); xlabel(app.UIAxes, 'Time (s)'); ylabel(app.UIAxes, 'Amplitude'); legend(app.UIAxes, 'Original'); % Khởi tạo đối tượng audioplayer với tần số mẫu mới app.Player = audioplayer(app.OriginalAudioData, newFs); app.start_line end % Button pushed function: CancelButton_daonguoc function CancelButton_daonguocPushed(app, event) app.cancelhieuung end % Button pushed function: daonguoc_button function daonguoc_buttonButtonPushed(app, event) if strcmp(app.saveorno,'No') app.kiemtranhac reversedAudio = flipud(app.AudioData); app.ProcessedAudio = reversedAudio; % Lưu âm thanh đảo ngược vào Origin để có thể chỉnh sửa sau % app.OriginalAudioData = reversedAudio; % Cập nhật đồ thị app.velaidothi cla(app.UIAxes); plot(app.UIAxes, reversedAudio); title(app.UIAxes, 'Reversed Audio'); legend(app.UIAxes, 'Original', 'Reversed Audio'); app.Player = audioplayer(app.ProcessedAudio, app.SampleRate); app.start_line else app.kiemtranhac reversedAudio = flipud(app.AudioData); app.ProcessedAudio = reversedAudio; % Lưu âm thanh đảo ngược vào Origin để có thể chỉnh sửa sau app.OriginalAudioData = reversedAudio; % Cập nhật đồ thị app.velaidothi cla(app.UIAxes); plot(app.UIAxes, app.OriginalAudioData); title(app.UIAxes, 'Reversed Audio'); legend(app.UIAxes, 'Original', 'Reversed Audio'); app.Player = audioplayer(app.OriginalAudioData, app.SampleRate); app.start_line end end % Value changed function: SaveorNoSwitch function SaveorNoSwitchValueChanged(app, event) value = app.SaveorNoSwitch.Value; if strcmp(value, 'No') app.Lamp.Color = [0, 0, 0]; % Màu đen else app.Lamp.Color = [0, 1, 0]; % Màu xanh lá end end end % Component initialization methods (Access = private) % Create UIFigure and components function createComponents(app) % Get the file path for locating images pathToMLAPP = fileparts(mfilename('fullpath')); % Create UIFigure and hide until all components are created app.UIFigure = uifigure('Visible', 'off'); app.UIFigure.Color = [1 1 1]; app.UIFigure.Position = [100 100 913 617]; app.UIFigure.Name = 'MATLAB App'; app.UIFigure.WindowStyle = 'modal'; % Create UIAxes app.UIAxes = uiaxes(app.UIFigure); app.UIAxes.XColor = [0 1 1]; app.UIAxes.XTick = []; app.UIAxes.XTickLabel = {'1'; '2'; '0'; '1'; '2'; '3'; '0'; '1'; '2'}; app.UIAxes.YColor = [0 1 0]; app.UIAxes.YTick = []; app.UIAxes.YTickLabel = ''; app.UIAxes.ZColor = [0 0 0]; app.UIAxes.ZTick = []; app.UIAxes.ZTickLabel = ''; app.UIAxes.LineWidth = 0.1; app.UIAxes.Color = 'none'; app.UIAxes.Box = 'on'; app.UIAxes.Position = [169 325 583 293]; % Create Image2_2 app.Image2_2 = uiimage(app.UIFigure); app.Image2_2.ScaleMethod = 'none'; app.Image2_2.HandleVisibility = 'off'; app.Image2_2.HorizontalAlignment = 'left'; app.Image2_2.VerticalAlignment = 'top'; app.Image2_2.Position = [124 247 713 79]; app.Image2_2.ImageSource = fullfile(pathToMLAPP, 'icon', '—Pngtree—anime girl listening to music_3381911.jpg'); % Create Image2 app.Image2 = uiimage(app.UIFigure); app.Image2.ScaleMethod = 'fill'; app.Image2.HandleVisibility = 'off'; app.Image2.VerticalAlignment = 'bottom'; app.Image2.Position = [2 247 175 372]; app.Image2.ImageSource = fullfile(pathToMLAPP, 'icon', '—Pngtree—anime girl listening to music_3381911.jpg'); % Create LoadButton app.LoadButton = uibutton(app.UIFigure, 'push'); app.LoadButton.ButtonPushedFcn = createCallbackFcn(app, @LoadButtonPushed, true); app.LoadButton.Icon = fullfile(pathToMLAPP, 'icon', 'loading.gif'); app.LoadButton.BackgroundColor = [1 0.9647 0.8314]; app.LoadButton.FontSize = 18; app.LoadButton.FontColor = [0.0745 0.6235 1]; app.LoadButton.Position = [22 534 123 47]; app.LoadButton.Text = 'Load'; % Create saveButton app.saveButton = uibutton(app.UIFigure, 'push'); app.saveButton.ButtonPushedFcn = createCallbackFcn(app, @saveButtonPushed, true); app.saveButton.Icon = fullfile(pathToMLAPP, 'icon', 'save.gif'); app.saveButton.BackgroundColor = [1 0.9647 0.8314]; app.saveButton.FontSize = 18; app.saveButton.FontColor = [0.0745 0.6235 1]; app.saveButton.Position = [23 475 123 44]; app.saveButton.Text = 'Lưu '; % Create PlayButton app.PlayButton = uibutton(app.UIFigure, 'push'); app.PlayButton.ButtonPushedFcn = createCallbackFcn(app, @playandpauseButtonPushed, true); app.PlayButton.Icon = fullfile(pathToMLAPP, 'icon', 'play.gif'); app.PlayButton.BackgroundColor = [1 0.9647 0.8314]; app.PlayButton.FontSize = 18; app.PlayButton.FontColor = [0.0745 0.6235 1]; app.PlayButton.Position = [411 261 93 49]; app.PlayButton.Text = 'Phát'; % Create RestartButton app.RestartButton = uibutton(app.UIFigure, 'push'); app.RestartButton.ButtonPushedFcn = createCallbackFcn(app, @RestartButtonPushed, true); app.RestartButton.Icon = fullfile(pathToMLAPP, 'icon', 'hourglass.gif'); app.RestartButton.BackgroundColor = [1 0.9647 0.8314]; app.RestartButton.FontSize = 18; app.RestartButton.FontColor = [0.0745 0.6235 1]; app.RestartButton.Position = [23 405 123 51]; app.RestartButton.Text = 'Restart'; % Create TuavButton app.TuavButton = uibutton(app.UIFigure, 'push'); app.TuavButton.ButtonPushedFcn = createCallbackFcn(app, @TuaveButtonPushed, true); app.TuavButton.Icon = fullfile(pathToMLAPP, 'icon', 'arrows (1).gif'); app.TuavButton.BackgroundColor = [1 0.9647 0.8314]; app.TuavButton.FontSize = 18; app.TuavButton.FontColor = [0.0745 0.6235 1]; app.TuavButton.Position = [209 258 111 52]; app.TuavButton.Text = 'Tua về'; % Create Tuai1sButton app.Tuai1sButton = uibutton(app.UIFigure, 'push'); app.Tuai1sButton.ButtonPushedFcn = createCallbackFcn(app, @TuadiButtonPushed, true); app.Tuai1sButton.Icon = fullfile(pathToMLAPP, 'icon', 'arrows.gif'); app.Tuai1sButton.BackgroundColor = [1 0.9647 0.8314]; app.Tuai1sButton.FontSize = 18; app.Tuai1sButton.FontColor = [0.0745 0.6235 1]; app.Tuai1sButton.Position = [518 258 110 52]; app.Tuai1sButton.Text = {'Tua đi'; '1s'}; % Create Menu app.Menu = uitabgroup(app.UIFigure); app.Menu.Position = [1 1 913 258]; % Create Tab app.Tab = uitab(app.Menu); % Create Image7 app.Image7 = uiimage(app.Tab); app.Image7.ScaleMethod = 'none'; app.Image7.HorizontalAlignment = 'left'; app.Image7.VerticalAlignment = 'top'; app.Image7.Position = [-7 10 355 223]; app.Image7.ImageSource = fullfile(pathToMLAPP, 'icon', '—Pngtree—anime girl listening to music_3381911.jpg'); % Create Image7_3 app.Image7_3 = uiimage(app.Tab); app.Image7_3.ScaleMethod = 'none'; app.Image7_3.HorizontalAlignment = 'left'; app.Image7_3.VerticalAlignment = 'top'; app.Image7_3.Position = [577 10 355 223]; app.Image7_3.ImageSource = fullfile(pathToMLAPP, 'icon', '—Pngtree—anime girl listening to music_3381911.jpg'); % Create Image7_2 app.Image7_2 = uiimage(app.Tab); app.Image7_2.ScaleMethod = 'fill'; app.Image7_2.HorizontalAlignment = 'left'; app.Image7_2.VerticalAlignment = 'top'; app.Image7_2.Position = [234 11 375 223]; app.Image7_2.ImageSource = fullfile(pathToMLAPP, 'icon', '—Pngtree—anime girl listening to music_3381911.jpg'); % Create FadeinFadeoutTab app.FadeinFadeoutTab = uitab(app.Menu); app.FadeinFadeoutTab.Title = 'Fade-in / Fade-out'; app.FadeinFadeoutTab.BackgroundColor = [0.9686 0.6863 0.5725]; % Create applyButton app.applyButton = uibutton(app.FadeinFadeoutTab, 'push'); app.applyButton.ButtonPushedFcn = createCallbackFcn(app, @applyfadeButtonPushed, true); app.applyButton.Icon = fullfile(pathToMLAPP, 'icon', 'checked.png'); app.applyButton.BackgroundColor = [1 0.9647 0.8314]; app.applyButton.FontName = 'Microsoft JhengHei UI'; app.applyButton.FontSize = 24; app.applyButton.FontColor = [0 0 1]; app.applyButton.Position = [384 140 178 68]; app.applyButton.Text = 'Áp Dụng'; % Create cancelButton app.cancelButton = uibutton(app.FadeinFadeoutTab, 'push'); app.cancelButton.ButtonPushedFcn = createCallbackFcn(app, @cancefadelButtonPushed, true); app.cancelButton.Icon = fullfile(pathToMLAPP, 'icon', 'cancel.gif'); app.cancelButton.BackgroundColor = [1 0.9647 0.8314]; app.cancelButton.FontName = 'Microsoft JhengHei UI'; app.cancelButton.FontSize = 24; app.cancelButton.FontColor = [0 0 1]; app.cancelButton.Position = [384 56 178 72]; app.cancelButton.Text = {'Hủy Bỏ'; 'Hiệu Ứng'}; % Create EditField_fadein app.EditField_fadein = uieditfield(app.FadeinFadeoutTab, 'numeric'); app.EditField_fadein.Limits = [0 100]; app.EditField_fadein.FontSize = 48; app.EditField_fadein.BackgroundColor = [1 0.9647 0.8314]; app.EditField_fadein.Position = [258 95 77 73]; % Create EditField_fadeout app.EditField_fadeout = uieditfield(app.FadeinFadeoutTab, 'numeric'); app.EditField_fadeout.Limits = [0 100]; app.EditField_fadeout.FontSize = 48; app.EditField_fadeout.BackgroundColor = [1 0.9647 0.8314]; app.EditField_fadeout.Position = [609 95 83 73]; % Create FadeinLabel app.FadeinLabel = uilabel(app.FadeinFadeoutTab); app.FadeinLabel.BackgroundColor = [1 0.9647 0.8314]; app.FadeinLabel.FontSize = 24; app.FadeinLabel.FontColor = [1 0.0745 0.651]; app.FadeinLabel.Position = [258 180 108 48]; app.FadeinLabel.Text = 'Fade-in'; % Create Image app.Image = uiimage(app.FadeinFadeoutTab); app.Image.BackgroundColor = [1 0.9647 0.8314]; app.Image.Position = [213 180 46 46]; app.Image.ImageSource = fullfile(pathToMLAPP, 'icon', 'import.gif'); % Create FadeoutLabel app.FadeoutLabel = uilabel(app.FadeinFadeoutTab); app.FadeoutLabel.BackgroundColor = [1 0.9647 0.8314]; app.FadeoutLabel.FontSize = 24; app.FadeoutLabel.FontColor = [0.0588 1 1]; app.FadeoutLabel.Position = [622 188 100 46]; app.FadeoutLabel.Text = 'Fade-out'; % Create Image_2 app.Image_2 = uiimage(app.FadeinFadeoutTab); app.Image_2.Position = [577 188 46 46]; app.Image_2.ImageSource = fullfile(pathToMLAPP, 'icon', 'export.gif'); % Create CutMusicTab app.CutMusicTab = uitab(app.Menu); app.CutMusicTab.Title = 'Cut Music'; app.CutMusicTab.BackgroundColor = [0.9961 0.6588 0.5216]; % Create StartEditFieldLabel app.StartEditFieldLabel = uilabel(app.CutMusicTab); app.StartEditFieldLabel.BackgroundColor = [1 0.9647 0.8314]; app.StartEditFieldLabel.HorizontalAlignment = 'right'; app.StartEditFieldLabel.FontSize = 18; app.StartEditFieldLabel.Position = [230 141 43 23]; app.StartEditFieldLabel.Text = 'Start'; % Create edit_star_cut app.edit_star_cut = uieditfield(app.CutMusicTab, 'numeric'); app.edit_star_cut.FontSize = 18; app.edit_star_cut.BackgroundColor = [1 0.9647 0.8314]; app.edit_star_cut.Position = [586 140 97 24]; % Create EndEditFieldLabel app.EndEditFieldLabel = uilabel(app.CutMusicTab); app.EndEditFieldLabel.BackgroundColor = [1 0.9647 0.8314]; app.EndEditFieldLabel.HorizontalAlignment = 'right'; app.EndEditFieldLabel.FontSize = 18; app.EndEditFieldLabel.Position = [541 141 37 23]; app.EndEditFieldLabel.Text = 'End'; % Create edit_end_cut app.edit_end_cut = uieditfield(app.CutMusicTab, 'numeric'); app.edit_end_cut.FontSize = 18; app.edit_end_cut.BackgroundColor = [1 0.9647 0.8314]; app.edit_end_cut.Position = [282 140 84 24]; % Create CutButton app.CutButton = uibutton(app.CutMusicTab, 'push'); app.CutButton.ButtonPushedFcn = createCallbackFcn(app, @CutButtonPushed, true); app.CutButton.Icon = fullfile(pathToMLAPP, 'icon', 'scissors.gif'); app.CutButton.BackgroundColor = [1 0.9647 0.8314]; app.CutButton.FontSize = 24; app.CutButton.FontColor = [0 1 1]; app.CutButton.Position = [364 163 154 54]; app.CutButton.Text = 'Cut'; % Create Image6 app.Image6 = uiimage(app.CutMusicTab); app.Image6.ScaleMethod = 'fill'; app.Image6.Position = [1 11 199 223]; app.Image6.ImageSource = fullfile(pathToMLAPP, 'icon', 'e473eae163b492f788ee0f06fd022d96_icon.png'); % Create Image6_2 app.Image6_2 = uiimage(app.CutMusicTab); app.Image6_2.ScaleMethod = 'fill'; app.Image6_2.Position = [713 11 199 223]; app.Image6_2.ImageSource = fullfile(pathToMLAPP, 'icon', 'e473eae163b492f788ee0f06fd022d96_icon.png'); % Create CancelButton app.CancelButton = uibutton(app.CutMusicTab, 'push'); app.CancelButton.ButtonPushedFcn = createCallbackFcn(app, @CancelButtonPushed, true); app.CancelButton.Icon = fullfile(pathToMLAPP, 'icon', 'cancel.gif'); app.CancelButton.BackgroundColor = [1 0.9647 0.8314]; app.CancelButton.FontSize = 24; app.CancelButton.FontColor = [0 1 1]; app.CancelButton.Position = [364 65 154 54]; app.CancelButton.Text = 'Cancel'; % Create GhpMusicTab app.GhpMusicTab = uitab(app.Menu); app.GhpMusicTab.Title = 'Ghép Music'; app.GhpMusicTab.BackgroundColor = [0.9961 0.6588 0.5216]; % Create MergeButton app.MergeButton = uibutton(app.GhpMusicTab, 'push'); app.MergeButton.ButtonPushedFcn = createCallbackFcn(app, @MergeButtonPushed, true); app.MergeButton.Icon = fullfile(pathToMLAPP, 'icon', 'merge (1).gif'); app.MergeButton.BackgroundColor = [1 0.9647 0.8314]; app.MergeButton.FontSize = 18; app.MergeButton.FontColor = [0 1 1]; app.MergeButton.Position = [21 64 154 50]; app.MergeButton.Text = 'Merge '; % Create LoadMultipleMP3Button app.LoadMultipleMP3Button = uibutton(app.GhpMusicTab, 'push'); app.LoadMultipleMP3Button.ButtonPushedFcn = createCallbackFcn(app, @LoadMultipleMP3ButtonPushed, true); app.LoadMultipleMP3Button.Icon = fullfile(pathToMLAPP, 'icon', 'work-in-progress.gif'); app.LoadMultipleMP3Button.BackgroundColor = [1 0.9608 0.8196]; app.LoadMultipleMP3Button.FontSize = 18; app.LoadMultipleMP3Button.FontColor = [0 1 1]; app.LoadMultipleMP3Button.Position = [25 127 151 96]; app.LoadMultipleMP3Button.Text = {'Load'; 'Multiple'; 'MP3'}; % Create craft_ListBox app.craft_ListBox = uilistbox(app.GhpMusicTab); app.craft_ListBox.Items = {}; app.craft_ListBox.Tooltip = {''}; app.craft_ListBox.FontColor = [0 0 1]; app.craft_ListBox.BackgroundColor = [0.902 0.902 0.902]; app.craft_ListBox.Position = [199 23 168 194]; app.craft_ListBox.Value = {}; % Create UPButton app.UPButton = uibutton(app.GhpMusicTab, 'push'); app.UPButton.ButtonPushedFcn = createCallbackFcn(app, @UPButtonPushed, true); app.UPButton.Icon = fullfile(pathToMLAPP, 'icon', 'up (1).gif'); app.UPButton.BackgroundColor = [1 0.9608 0.8196]; app.UPButton.FontSize = 18; app.UPButton.FontColor = [0.0588 1 1]; app.UPButton.Position = [400 180 103 46]; app.UPButton.Text = 'UP'; % Create DOWNButton app.DOWNButton = uibutton(app.GhpMusicTab, 'push'); app.DOWNButton.ButtonPushedFcn = createCallbackFcn(app, @DOWNButtonPushed, true); app.DOWNButton.Icon = fullfile(pathToMLAPP, 'icon', 'down.gif'); app.DOWNButton.BackgroundColor = [1 0.9608 0.8196]; app.DOWNButton.FontSize = 18; app.DOWNButton.FontColor = [0.0588 1 1]; app.DOWNButton.Position = [400 22 103 53]; app.DOWNButton.Text = 'DOWN'; % Create DeleteButton app.DeleteButton = uibutton(app.GhpMusicTab, 'push'); app.DeleteButton.ButtonPushedFcn = createCallbackFcn(app, @DeleteButtonPushed, true); app.DeleteButton.Icon = fullfile(pathToMLAPP, 'icon', 'trash-bin.gif'); app.DeleteButton.BackgroundColor = [1 0.9608 0.8196]; app.DeleteButton.FontSize = 18; app.DeleteButton.FontColor = [0.0588 1 1]; app.DeleteButton.Position = [402 108 107 46]; app.DeleteButton.Text = 'Delete'; % Create chnnhcTab app.chnnhcTab = uitab(app.Menu); app.chnnhcTab.Title = 'chèn nhạc'; app.chnnhcTab.BackgroundColor = [0.9804 0.7647 0.7647]; % Create UIAxes2 app.UIAxes2 = uiaxes(app.chnnhcTab); app.UIAxes2.XTick = []; app.UIAxes2.YTick = []; app.UIAxes2.ZTick = []; app.UIAxes2.Position = [278 48 300 185]; % Create LoadsecondmusicButton app.LoadsecondmusicButton = uibutton(app.chnnhcTab, 'push'); app.LoadsecondmusicButton.ButtonPushedFcn = createCallbackFcn(app, @LoadsecondmusicButtonPushed, true); app.LoadsecondmusicButton.Icon = fullfile(pathToMLAPP, 'icon', 'up (1).gif'); app.LoadsecondmusicButton.BackgroundColor = [1 0.9608 0.8196]; app.LoadsecondmusicButton.FontSize = 18; app.LoadsecondmusicButton.FontColor = [0 1 1]; app.LoadsecondmusicButton.Position = [107 103 128 76]; app.LoadsecondmusicButton.Text = {'Load'; 'second'; 'music'}; % Create chen_EditField app.chen_EditField = uieditfield(app.chnnhcTab, 'numeric'); app.chen_EditField.Editable = 'off'; app.chen_EditField.FontSize = 48; app.chen_EditField.Position = [760 83 91 58]; % Create ChnButton app.ChnButton = uibutton(app.chnnhcTab, 'push'); app.ChnButton.ButtonPushedFcn = createCallbackFcn(app, @ChenButtonPushed, true); app.ChnButton.Icon = fullfile(pathToMLAPP, 'icon', 'modeling-tool.gif'); app.ChnButton.BackgroundColor = [1 0.9647 0.8314]; app.ChnButton.FontSize = 30; app.ChnButton.FontColor = [0 1 1]; app.ChnButton.Position = [678 147 136 72]; app.ChnButton.Text = 'Chèn'; % Create VoGiyLabel app.VoGiyLabel = uilabel(app.chnnhcTab); app.VoGiyLabel.FontSize = 36; app.VoGiyLabel.Position = [598 93 153 47]; app.VoGiyLabel.Text = 'Vào Giây'; % Create KhTab app.KhTab = uitab(app.Menu); app.KhTab.Title = 'Khử'; app.KhTab.BackgroundColor = [0.9882 0.8235 0.8235]; % Create PlayButton_khunhieu app.PlayButton_khunhieu = uibutton(app.KhTab, 'push'); app.PlayButton_khunhieu.ButtonPushedFcn = createCallbackFcn(app, @PlayButton_khunhieuPushed, true); app.PlayButton_khunhieu.Icon = fullfile(pathToMLAPP, 'icon', 'reduction.png'); app.PlayButton_khunhieu.BackgroundColor = [1 0.9647 0.8314]; app.PlayButton_khunhieu.FontSize = 18; app.PlayButton_khunhieu.FontColor = [0.0745 0.6235 1]; app.PlayButton_khunhieu.Position = [47 152 163 49]; app.PlayButton_khunhieu.Text = 'Khử Nhiễu'; % Create PlayButton_khucam app.PlayButton_khucam = uibutton(app.KhTab, 'push'); app.PlayButton_khucam.ButtonPushedFcn = createCallbackFcn(app, @PlayButton_khucamPushed, true); app.PlayButton_khucam.Icon = fullfile(pathToMLAPP, 'icon', 'silence.gif'); app.PlayButton_khucam.BackgroundColor = [1 0.9647 0.8314]; app.PlayButton_khucam.FontSize = 18; app.PlayButton_khucam.FontColor = [0.0745 0.6235 1]; app.PlayButton_khucam.Position = [230 151 163 49]; app.PlayButton_khucam.Text = 'Khử Câm'; % Create CancelButton_khu app.CancelButton_khu = uibutton(app.KhTab, 'push'); app.CancelButton_khu.ButtonPushedFcn = createCallbackFcn(app, @CancelButton_khuPushed, true); app.CancelButton_khu.Icon = fullfile(pathToMLAPP, 'icon', 'cancel.gif'); app.CancelButton_khu.BackgroundColor = [1 0.9647 0.8314]; app.CancelButton_khu.FontSize = 24; app.CancelButton_khu.FontColor = [0 1 1]; app.CancelButton_khu.Position = [365 51 154 54]; app.CancelButton_khu.Text = 'Cancel'; % Create PlayButton_khucam_2 app.PlayButton_khucam_2 = uibutton(app.KhTab, 'push'); app.PlayButton_khucam_2.ButtonPushedFcn = createCallbackFcn(app, @PlayButton_khucam_2Pushed, true); app.PlayButton_khucam_2.Icon = fullfile(pathToMLAPP, 'icon', 'echo-dot.png'); app.PlayButton_khucam_2.BackgroundColor = [1 0.9647 0.8314]; app.PlayButton_khucam_2.FontSize = 18; app.PlayButton_khucam_2.FontColor = [0.0745 0.6235 1]; app.PlayButton_khucam_2.Position = [400 147 163 52]; app.PlayButton_khucam_2.Text = {'Tạo Tiếng '; 'Vang'}; % Create Button app.Button = uibutton(app.KhTab, 'push'); app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true); app.Button.Position = [75 97 100 22]; % Create Cut20Tab app.Cut20Tab = uitab(app.Menu); app.Cut20Tab.Title = 'Cut 2.0'; app.Cut20Tab.BackgroundColor = [0.6 0.9686 0.9686]; % Create TEditFieldLabel app.TEditFieldLabel = uilabel(app.Cut20Tab); app.TEditFieldLabel.HorizontalAlignment = 'right'; app.TEditFieldLabel.Position = [143 178 25 22]; app.TEditFieldLabel.Text = 'Từ'; % Create TEditField app.TEditField = uieditfield(app.Cut20Tab, 'numeric'); app.TEditField.Position = [183 178 100 22]; % Create nEditFieldLabel app.nEditFieldLabel = uilabel(app.Cut20Tab); app.nEditFieldLabel.HorizontalAlignment = 'right'; app.nEditFieldLabel.Position = [383 178 27 22]; app.nEditFieldLabel.Text = 'Đến'; % Create nEditField app.nEditField = uieditfield(app.Cut20Tab, 'numeric'); app.nEditField.Position = [425 178 100 22]; % Create TEditField_2 app.TEditField_2 = uieditfield(app.Cut20Tab, 'numeric'); app.TEditField_2.Position = [184 140 100 22]; % Create nEditField_2 app.nEditField_2 = uieditfield(app.Cut20Tab, 'numeric'); app.nEditField_2.Position = [426 140 100 22]; % Create TEditField_3 app.TEditField_3 = uieditfield(app.Cut20Tab, 'numeric'); app.TEditField_3.Position = [184 106 100 22]; % Create nEditField_3 app.nEditField_3 = uieditfield(app.Cut20Tab, 'numeric'); app.nEditField_3.Position = [426 106 100 22]; % Create TEditField_4 app.TEditField_4 = uieditfield(app.Cut20Tab, 'numeric'); app.TEditField_4.Position = [184 74 100 22]; % Create nEditField_4 app.nEditField_4 = uieditfield(app.Cut20Tab, 'numeric'); app.nEditField_4.Position = [426 74 100 22]; % Create TEditField_5 app.TEditField_5 = uieditfield(app.Cut20Tab, 'numeric'); app.TEditField_5.Position = [181 37 100 22]; % Create nEditField_5 app.nEditField_5 = uieditfield(app.Cut20Tab, 'numeric'); app.nEditField_5.Position = [423 37 100 22]; % Create CutButton_2 app.CutButton_2 = uibutton(app.Cut20Tab, 'push'); app.CutButton_2.ButtonPushedFcn = createCallbackFcn(app, @CutButton_2Pushed, true); app.CutButton_2.Icon = fullfile(pathToMLAPP, 'icon', 'scissors.gif'); app.CutButton_2.BackgroundColor = [1 0.9647 0.8314]; app.CutButton_2.FontSize = 24; app.CutButton_2.FontColor = [0 1 1]; app.CutButton_2.Position = [621 147 154 54]; app.CutButton_2.Text = 'Cut'; % Create CancelButton_2 app.CancelButton_2 = uibutton(app.Cut20Tab, 'push'); app.CancelButton_2.ButtonPushedFcn = createCallbackFcn(app, @CancelButton_2Pushed, true); app.CancelButton_2.Icon = fullfile(pathToMLAPP, 'icon', 'cancel.gif'); app.CancelButton_2.BackgroundColor = [1 0.9647 0.8314]; app.CancelButton_2.FontSize = 24; app.CancelButton_2.FontColor = [0 1 1]; app.CancelButton_2.Position = [621 42 154 54]; app.CancelButton_2.Text = 'Cancel'; % Create TcniTab app.TcniTab = uitab(app.Menu); app.TcniTab.Title = 'Tốc Độ nói'; app.TcniTab.BackgroundColor = [1 0.9882 0.9098]; % Create GimTcEditFieldLabel app.GimTcEditFieldLabel = uilabel(app.TcniTab); app.GimTcEditFieldLabel.HorizontalAlignment = 'right'; app.GimTcEditFieldLabel.FontSize = 24; app.GimTcEditFieldLabel.Position = [73 144 109 31]; app.GimTcEditFieldLabel.Text = 'Giảm Tốc'; % Create GimTcEditField app.GimTcEditField = uieditfield(app.TcniTab, 'numeric'); app.GimTcEditField.Editable = 'off'; app.GimTcEditField.Visible = 'off'; app.GimTcEditField.Position = [197 153 100 22]; app.GimTcEditField.Value = 0.5; % Create TngTcEditFieldLabel app.TngTcEditFieldLabel = uilabel(app.TcniTab); app.TngTcEditFieldLabel.HorizontalAlignment = 'right'; app.TngTcEditFieldLabel.FontSize = 24; app.TngTcEditFieldLabel.Visible = 'off'; app.TngTcEditFieldLabel.Position = [571 139 106 31]; app.TngTcEditFieldLabel.Text = 'Tăng Tốc'; % Create TngTcEditField app.TngTcEditField = uieditfield(app.TcniTab, 'numeric'); app.TngTcEditField.Editable = 'off'; app.TngTcEditField.Visible = 'off'; app.TngTcEditField.Position = [692 148 100 22]; app.TngTcEditField.Value = 2; % Create PlayButton_tangtoc app.PlayButton_tangtoc = uibutton(app.TcniTab, 'push'); app.PlayButton_tangtoc.ButtonPushedFcn = createCallbackFcn(app, @PlayButton_tangtocPushed, true); app.PlayButton_tangtoc.Icon = fullfile(pathToMLAPP, 'icon', 'reduction.png'); app.PlayButton_tangtoc.BackgroundColor = [1 0.9647 0.8314]; app.PlayButton_tangtoc.FontSize = 18; app.PlayButton_tangtoc.FontColor = [0.0745 0.6235 1]; app.PlayButton_tangtoc.Position = [626 79 163 49]; app.PlayButton_tangtoc.Text = 'Apple'; % Create CancelButton_tocdo app.CancelButton_tocdo = uibutton(app.TcniTab, 'push'); app.CancelButton_tocdo.Icon = fullfile(pathToMLAPP, 'icon', 'cancel.gif'); app.CancelButton_tocdo.BackgroundColor = [1 0.9647 0.8314]; app.CancelButton_tocdo.FontSize = 24; app.CancelButton_tocdo.FontColor = [0 1 1]; app.CancelButton_tocdo.Position = [364 12 154 54]; app.CancelButton_tocdo.Text = 'Cancel'; % Create PlayButton_giamtoc app.PlayButton_giamtoc = uibutton(app.TcniTab, 'push'); app.PlayButton_giamtoc.ButtonPushedFcn = createCallbackFcn(app, @PlayButton_giamtocPushed, true); app.PlayButton_giamtoc.Icon = fullfile(pathToMLAPP, 'icon', 'reduction.png'); app.PlayButton_giamtoc.BackgroundColor = [1 0.9647 0.8314]; app.PlayButton_giamtoc.FontSize = 18; app.PlayButton_giamtoc.FontColor = [0.0745 0.6235 1]; app.PlayButton_giamtoc.Position = [134 74 163 49]; app.PlayButton_giamtoc.Text = 'Apple'; % Create oNgcTab app.oNgcTab = uitab(app.Menu); app.oNgcTab.Title = 'Đảo Ngược'; app.oNgcTab.BackgroundColor = [0.9765 0.9098 1]; % Create CancelButton_daonguoc app.CancelButton_daonguoc = uibutton(app.oNgcTab, 'push'); app.CancelButton_daonguoc.ButtonPushedFcn = createCallbackFcn(app, @CancelButton_daonguocPushed, true); app.CancelButton_daonguoc.Icon = fullfile(pathToMLAPP, 'icon', 'cancel.gif'); app.CancelButton_daonguoc.BackgroundColor = [1 0.9647 0.8314]; app.CancelButton_daonguoc.FontSize = 24; app.CancelButton_daonguoc.FontColor = [0 1 1]; app.CancelButton_daonguoc.Position = [364 12 154 54]; app.CancelButton_daonguoc.Text = 'Cancel'; % Create daonguoc_button app.daonguoc_button = uibutton(app.oNgcTab, 'push'); app.daonguoc_button.ButtonPushedFcn = createCallbackFcn(app, @daonguoc_buttonButtonPushed, true); app.daonguoc_button.Icon = fullfile(pathToMLAPP, 'icon', 'down.gif'); app.daonguoc_button.BackgroundColor = [1 0.9608 0.8196]; app.daonguoc_button.FontSize = 18; app.daonguoc_button.FontColor = [0 1 1]; app.daonguoc_button.Position = [378 112 131 76]; app.daonguoc_button.Text = {'Đảo '; 'Ngược'}; % Create Image2_5 app.Image2_5 = uiimage(app.UIFigure); app.Image2_5.ScaleMethod = 'none'; app.Image2_5.HandleVisibility = 'off'; app.Image2_5.HorizontalAlignment = 'left'; app.Image2_5.VerticalAlignment = 'top'; app.Image2_5.Position = [176 325 586 296]; app.Image2_5.ImageSource = fullfile(pathToMLAPP, 'icon', '—Pngtree—anime girl listening to music_3381911.jpg'); % Create Image2_4 app.Image2_4 = uiimage(app.UIFigure); app.Image2_4.ScaleMethod = 'fill'; app.Image2_4.HandleVisibility = 'off'; app.Image2_4.VerticalAlignment = 'bottom'; app.Image2_4.Position = [761 259 153 369]; app.Image2_4.ImageSource = fullfile(pathToMLAPP, 'icon', '—Pngtree—anime girl listening to music_3381911.jpg'); % Create tuave app.tuave = uidropdown(app.UIFigure); app.tuave.Items = {'1 Giây', '2 Giây', '5 Giây', '10 Giây', '30 Giây'}; app.tuave.ItemsData = {'1', '2', '5', '10', '30'}; app.tuave.FontColor = [0.302 0.7451 0.9333]; app.tuave.BackgroundColor = [1 0.9647 0.8314]; app.tuave.Position = [325 262 77 49]; app.tuave.Value = '1'; % Create tuadi app.tuadi = uidropdown(app.UIFigure); app.tuadi.Items = {'1 Giây', '2 Giây', '5 Giây', '10 Giây', '30 Giây'}; app.tuadi.FontColor = [0.302 0.7451 0.9333]; app.tuadi.BackgroundColor = [1 0.9647 0.8314]; app.tuadi.Position = [641 260 80 49]; app.tuadi.Value = '1 Giây'; % Create ResetButton app.ResetButton = uibutton(app.UIFigure, 'push'); app.ResetButton.ButtonPushedFcn = createCallbackFcn(app, @ResetButtonPushed, true); app.ResetButton.Icon = fullfile(pathToMLAPP, 'icon', 'reset.gif'); app.ResetButton.BackgroundColor = [1 0.9647 0.8314]; app.ResetButton.FontSize = 18; app.ResetButton.FontColor = [0.0745 0.6235 1]; app.ResetButton.Position = [23 340 123 51]; app.ResetButton.Text = 'Reset'; % Create SaveorNoSwitch app.SaveorNoSwitch = uiswitch(app.UIFigure, 'slider'); app.SaveorNoSwitch.Items = {'No', 'Yes'}; app.SaveorNoSwitch.ItemsData = {'No', 'Yes'}; app.SaveorNoSwitch.ValueChangedFcn = createCallbackFcn(app, @SaveorNoSwitchValueChanged, true); app.SaveorNoSwitch.FontWeight = 'bold'; app.SaveorNoSwitch.FontColor = [0 1 1]; app.SaveorNoSwitch.Position = [64 299 45 20]; app.SaveorNoSwitch.Value = 'No'; % Create Lamp app.Lamp = uilamp(app.UIFigure); app.Lamp.Position = [76 274 20 20]; app.Lamp.Color = [0 0 0]; % Show the figure after all components are created app.UIFigure.Visible = 'on'; end end % App creation and deletion methods (Access = public) % Construct app function app = app % Create UIFigure and components createComponents(app) % Register the app with App Designer registerApp(app, app.UIFigure) % Execute the startup function runStartupFcn(app, @startupFcn) if nargout == 0 clear app end end % Code that executes before app deletion function delete(app) % Delete UIFigure when app is deleted delete(app.UIFigure) end end - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.