Why is my program not being coverted into an application properly specifically the sound doesn't start playing in the converted program
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
OCDER
on 4 Dec 2018
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
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!