Why is my program not being coverted into an application properly specifically the sound doesn't start playing in the converted program
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
OCDER
am 4 Dez. 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
Siehe auch
Kategorien
Mehr zu Audio and Video Data finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!