Error Message: ??? Undefined function or method 'SimpleSurround' for input arguments of type 'char'.

1 view (last 30 days)
new to matlab. please help! heres my code:
% takes 2 channel stereo wav file and converts to 4 channel surround for
% virtual surround. KEMAR HRTFs used.
function SimpleSurrond( filename, OUTfile )
% filename check, make sure your files are strings
if ischar(filename) == 0
error('filename must be a string')
end
if ischar(OUTfile) == 0
error('OUTfile must be a string')
end
% The function reads the input .wav file
y = wavread(filename);
RChannel = y(:,1);
LChannel = y(:,2);
% Function makes sure the sampling rates match up. (The sampling rates of
% the files I provided and the KEMAR impulse responses line up at 44100.
% If user chooses to use different 3D input file, and or different HRTF IRs,
% please make sure they are of the same sampling rate.
if Fs ~= 44100
error('HRTF IR and signal sampling rates dont match');
end
% Check length of the signal channels to make sure they are the same
if length(LChannel) > length(RChannel);
zeropad = length(LChannel) - length(RChannel);
RChannel = [RChannel; zeros(zeropad, 1)];
end
if length(RChannel) > length(LChannel);
zeropad = length(RChannel) - length(LChannel);
LChannel = [LChannel; zeros(zeropad, 1)];
end
% Reads compact data file of + and - 30 degrees HRTF IRs from KEMAR.
% 30
fp = fopen('L0e030a.dat','r','ieee-be');
data = fread(fp, 256, 'short');
fclose(fp);
L30 = data(1:256);
L30Length = length(L30);
fp = fopen('R0e030a.dat','r','ieee-be');
data = fread(fp, 256, 'short');
fclose(fp);
R30 = data(1:256);
R30Length = length(R30);
% 110
fp = fopen('L0e110a.dat','r','ieee-be');
data = fread(fp, 256, 'short');
fclose(fp);
L110 = data(1:256);
L110Length = length(L110);
fp = fopen('R0e110a.dat','r','ieee-be');
data = fread(fp, 256, 'short');
fclose(fp);
R110 = data(1:256);
R110Length = length(R110);
% 250
fp = fopen('L0e250a.dat','r','ieee-be');
data = fread(fp, 256, 'short');
fclose(fp);
L250 = data(1:256);
L250Length = length(L250);
fp = fopen('R0e250a.dat','r','ieee-be');
data = fread(fp, 256, 'short');
fclose(fp);
R250 = data(1:256);
R250Length = length(R250);
% 330
fp = fopen('L0e330a.dat','r','ieee-be');
data = fread(fp, 256, 'short');
fclose(fp);
L330 = data(1:256);
L330Length = length(L330);
fp = fopen('R0e110a.dat','r','ieee-be');
data = fread(fp, 256, 'short');
fclose(fp);
R330 = data(1:256);
R330Length = length(R330);
% CONVOLVE SIGNALS WITH HRTFs
L30 = conv(L30, LChannel);
R30 = conv(R30, RChannel);
L110 = conv(L110, LChannel);
R110 = conv(R110, RChannel);
L250 = conv(L250, LChannel);
R250 = conv(R250, RChannel);
L330 = conv(L330, LChannel);
R330 = conv(R330, RChannel);
% Allocate left and right channel matrices.
MTXleft = zeros(length(L30), 4);
MTXright = zeros(length(R30), 4);
% Place vectors in channel matrices.
MTXleft(:,1) = L30;
MTXleft(:,2) = L110;
MTXleft(:,3) = L250;
MTXleft(:,4) = L330;
MTXright(:,1) = R30;
MTXright(:,2) = R110;
MTXright(:,3) = R250;
MTXright(:,4) = R330;
% add rows of the matrices to get 2 channels for VIRTUAL surround sound.
% BUT FIRST... allocate some vectors and output matrix.
leftVEC = zeros(length(MTXleft), 1);
rightVEC = zeros(length(MTXright), 1);
outputMTX = zeros(length(leftVEC), 2);
% sum rows of MTXleft and place into leftVEC, same for MTXright into rightVEC
MTXleft = leftMTX';
MTXright = rightMTX';
sumLEFTrow = (sum(leftMTX))/5;
sumRIGHTrow = (sum(rightMTX))/5;
leftVEC = sumLEFTrow';
rightVEC = sumRIGHTrow';
% then put together into outputMTX
outputMTX(:,1) = leftVEC;
outputMTX(:,2) = rightVEC;
% normalize
vectorMAX = 1.001 * (max(abs(outputMTX)));
outputMTX = outputMTX / max(vectorMAX);
% wavwrite
wavwrite (outputMTX, 44100, OUTfile);
end

Accepted Answer

Thomas
Thomas on 1 May 2012
You have named your function call 'SimpleSurrond' and not 'SimpleSurround'..
function SimpleSurrond( filename, OUTfile )
it should read
function SimpleSurround( filename, OUTfile )
and save it as SimpleSurround.m and call it from the same directory

More Answers (2)

Walter Roberson
Walter Roberson on 1 May 2012
You have
function SimpleSurrond
without the second "u" of "Surround"

Geoff
Geoff on 1 May 2012
1. Your function must be stored in a file called SimpleSurround.m.
2. That file must be in a directory that is on the MatLab search path.
Make sure you have the right file name.
Check that the 'Current Folder' window is showing the contents of the directory in which that file resides.
If you need the current folder to be somewhere else, then you need to add your function's folder to the MatLab path:
File -> Set Path... -> Add Folder... -> Save
[EDIT]
Actually, scratch that... Did you notice you called your function SimpleSurrond, not SimpleSurround?

Categories

Find more on Measurements and Spatial Audio 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!