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.

답변 (1개)

OCDER
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
  댓글 수: 1
Vijay Krishnamoorthy
Vijay Krishnamoorthy 2018년 12월 5일
Thank you for the help. I changed my code to fit with what you reccommended. However (even with runtime, matlab, and the compiler) the program still refuses to actually play the sound when compiled. Is there something that I am missing that needs to be downloaded to make the sound play?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by