【游戏】基于matlab GUI音乐时钟设计【含Matlab源码 1104期】

举报
海神之光 发表于 2022/05/29 02:08:56 2022/05/29
【摘要】 一、获取代码方式 获取代码方式1: 完整代码已上传我的资源:【游戏】基于matlab GUI音乐时钟设计【含Matlab源码 1104期】 获取代码方式2: 通过订阅紫极神光博客付费专栏,凭支付凭证,...

一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【游戏】基于matlab GUI音乐时钟设计【含Matlab源码 1104期】

获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、部分源代码

function varargout = untitled(varargin)
% UNTITLED M-file for untitled.fig
%      UNTITLED, by itself, creates a new UNTITLED or raises the existing
%      singleton*.
%
%      H = UNTITLED returns the handle to a new UNTITLED or the handle to
%      the existing singleton*.
%
%      UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in UNTITLED.M with the given input arguments.
%
%      UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
%      existing singleton*.  Starting from the left, property value pairs ar
%      applied to the GUI before untitled_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to untitled_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help untitled

% Last Modified by GUIDE v2.5 02-Jun-2021 00:03:55

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @untitled_OpeningFcn, ...
                   'gui_OutputFcn',  @untitled_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled is made visible.
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to untitled (see VARARGIN)
if ~isempty(timerfindall), stop(timerfindall);  delete(timerfindall);end
set(handles.radiobutton2,'value',handles.clockSaveData(3));
temp=get(handles.uipanel3,'Units');
set(handles.uipanel3,'Units','pixels');
position=get(handles.uipanel3,'position');
position(4)=position(2)-17;
position(2)=12;
position(3)=position(3)+position(1)-49;
handles.sound_player= actxcontrol('wmplayer.ocx.7',position ,handles.figure1);
handles.sound_player.settings.volume=100;
set(handles.uipanel3,'Units',temp);
ha=axes('units','normalized','position',[0 0 1 1]); 
uistack(ha,'down') 
II=imread('backgroud_picture.jpg'); 
image(II) 
colormap gray 	
set(ha,'handlevisibility','off','visible','off');
handles.timer=timer;
set(handles.timer,'TimerFcn',{@timer_action,handles});
start_timer(handles);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%start_timer_solid_hour(handles);**************************************************
if (get(handles.checkbox1,'Value')==1)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    start_timer_solid_hour(handles);
else
    start_timer(handles);
end
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
filename='alarm_icon.jpg';
javaFrame=get(hObject,'javaFrame');
set(javaFrame,'FigureIcon',javax.swing.ImageIcon(filename));

% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename,pathname]=uigetfile(...
    {'*.mp3;*.wav;*.mkv','可播放';},'选择定时播放','MultiSelect','off');
handles.musicSaveData=fullfile(pathname,filename);
 
set(handles.edit_musicFile,'String',handles.musicSaveData);
musicSaveData=handles.musicSaveData;
save('musicSaveData.txt','-ascii','musicSaveData');
handles.pushbutton1=hObject;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
guidata(hObject,handles);
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1
handles.clockSaveData(1)=get(hObject,'Value');
clockSaveData=handles.clockSaveData;
save('clockSaveData.txt','-ascii','clockSaveData');
guidata(hObject,handles);
start_timer(handles);

% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
set(hObject,'Value',handles.clockSaveData(1));
handles.popupmenu1=hObject;
guidata(hObject,handles);
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2
handles.clockSaveData(2)=get(hObject,'Value');
clockSaveData=handles.clockSaveData;
save('clockSaveData.txt','-ascii','clockSaveData');
guidata(hObject,handles);
start_timer(handles);
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
set(hObject,'Value',handles.clockSaveData(2));
handles.popupmenu2=hObject;
guidata(hObject,handles);
function edit_musicFile_Callback(hObject, eventdata, handles)
% hObject    handle to edit_musicFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_musicFile as text
%        str2double(get(hObject,'String')) returns contents of edit_musicFile as a double
handles.musicSaveData=get(hObject,'String');
musicSaveData=handles.musicSaveData;
save('musicSaveData.txt','-ascii','musicSaveData');
guidata(hObject,handles);
% --- Executes during object creation, after setting all properties.
function edit_musicFile_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_musicFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
set(hObject,'String',handles.musicSaveData); 
handles.edit_musicFile=hObject;
guidata(hObject,handles);
% --- Executes during object creation, after setting all properties.
function pushbutton1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
handles.pushbutton1=hObject;
guidata(hObject,handles);
  
 

三、运行结果

在这里插入图片描述

四、备注

版本:2014a

文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。

原文链接:qq912100926.blog.csdn.net/article/details/118526878

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。