Why is my program not being coverted into an application properly specifically the sound doesn't start playing in the converted program
1 次查看(过去 30 天)
显示 更早的评论
So I created a program that uses various sound manipulation functions. I want to convert this code into a MATLAB application using the MATLAB compier. The compiler actually converts the code into a program, but the program doesn't actually work because I doesn't play the sound or give the numeric output. I will add the ZIP file with the functions that I am using if that will help solve this problem. Thank you.
0 个评论
回答(1 个)
OCDER
2018-12-4
Seems like you are using relative paths. When using deployed application, the paths are different. Use absolute paths.
function haHAA = SongDetails
prompt = {'Enter Name of Song:', 'Enter Volume:', 'Enter Frequency:', 'Enter The Duration of Song:'};
title = 'Sound Information';
dims = [1 35];
definput = {'matlabaudio.flac','25','1','10'};
answer = inputdlg(prompt, title, dims, definput);
haHAA.name = answer{1};
haHAA.vol = str2double(answer{2});
haHAA.freq = str2double(answer{3});
haHAA.time = str2double(answer{4});
%Check if your file name exists
if isempty(dir(haHAA.name))
[filename, pathname] = uigetfile(haHAA.name, 'Find audio file');
if isnumeric %canceled file search
warning('Could not file the file name "%s". Use absolute path.', haHAA.name);
return
end
haHAA.name = fullfile(pathname, filename); %Use full path.
end
end
Do the same for the other function
function [death] = SoundFunct(haHAA)
vol = haHAA.vol;
freq = haHAA.freq;
name = haHAA.name;
time = haHAA.time;
[volFinal, freqFinal] = audioread(name);
filepath = fileparts(name); %get the dir
filename = 'matlabaudio.flac'; %get the name. combine using fullfile
audiowrite(fullfile(filepath, filename),volFinal,freqFinal);
...
Also, I recommend changing RunFunction.m into a function
function RunFunction
haHAA = SongDetails;
death = SoundFunct(haHAA);
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!