码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2021-07-07 17:48:53      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:struct   this   not   check   code   push   invalid   wait   round   

一、简介

基于matlab GUI音乐时钟设计

二、源代码

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

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

标签:struct   this   not   check   code   push   invalid   wait   round   

原文地址:https://www.cnblogs.com/homeofmatlab/p/14978339.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!