Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

MEX-file error matlab please help

Status
Not open for further replies.

kingh12

New Member
Can't you download the midi2nmat.m and nmat2midi.m files and use them instead of readmidi, etc.? Just download the files and put them in the miditoolbox directory
 
I tried that like you said but nothing changed. I downloaded both files and put them into that directory. After that, I tried the same code but the same error appeared. Do I have to do something more in matlab? I just did copy-paste..
 
I believe you have to call midi2nmat instead of readmidi
 
dougy83, thank you very much! I am new at matlab and I didn't know that I had to call another command..I was trying to use readmidi command...now I tried midi2nmat command and it is ok! one more question.. these midi2nmat and nmat2midi are just for readmidi command? Will I meet with another problem on using another codes?
 
midi2nmat replaces the readmidi command. The writemidi command should be replaced with nmat2midi if you need to use it.
 
Hi dougy83,
Everything is ok, but the same problem is shown in "playmidi" command again. The massage is:

>> playmidi(deneme,145);
Invalid MEX-file 'C:\Program Files\MATLAB\R2013a\toolbox\miditoolbox\t2mf.dll': The specified procedure could not be found.

Error in mft2mf (line 36)
t2mf(ifname,ofname); % mex converter, works in Windows, but see next

Error in playmidi (line 44)
mft2mf(ifn,ofn);

Is there any solution to fix this?
I have to correct this problem because this is also very important for me. I would be very glad to hearing from you.
Thanks...

Sincerely,
Huseyin
If you're using windows, to play the midi file, just use the following code. 'nmat' is your midi information nmat variable
Code:
nmat2midi(nmat, 'test.mid'); 
system('test.mid');
 
I've just tried to "write" a midi file basicly. First I read a midi file and then tried to write it with another name to the directory. The code I wrote is;

"
>> nmat=midi2nmat('laksin.mid');
>> nmat2midi(nmat,'test.mid');
Tracks: 1 Format: 0
track chunks... "

What does "track chunks" mean? format=0 ?
I think I am missing something that the written midi file doesn't work. Both I double-clicked the created new test.mid file in the directory or used the code "system('test.mid') in matlab; but it didn't play. I am sure that the problem is in written midi file because when I try to play another midi files, there isn't any problem.

By the way thanks for your "playmidi" comment
 
Last edited:
The problem is the output file is written incorrectly. The author forgot to include the end of track message.

Please find modified file attached.
 

Attachments

  • nmat2midi.zip
    2.7 KB · Views: 153
The problem is the output file is written incorrectly. The author forgot to include the end of track message.

Please find modified file attached.
midi2nmat is not working for some midi files. Giving as error:
Attempted to access tmp2(1); index out of bounds because numel(tmp2)=0.

Error in midi2nmat (line 68)
tmp2=tmp2(1);
 
midi2nmat is not working for some midi files. Giving as error:
Attempted to access tmp2(1); index out of bounds because numel(tmp2)=0.

Error in midi2nmat (line 68)
tmp2=tmp2(1);

Hi,
I added guard that prevent empty vector that caused troubles. However this function was originally written by someone else, so I can only hope it will help. Please tell me if it does.
Code:
if all(~time_index)
    time_index(end) = true;
end
% next line for reference
timeratio = tempos(i)/tempos(1);
 

Attachments

  • midi2nmat2.m.zip
    9 KB · Views: 105
Can't you download the midi2nmat.m and nmat2midi.m files and use them instead of readmidi, etc.? Just download the files and put them in the miditoolbox directory

midi2nmat (and nmat2midi) includes old versions of functions copied and pasted from matlab-midi repository (by Ken Schutte). It is much better to comment out this part of midi2nmat, and download recent versions of Ken Schutte code, and place it where Matlab can see it (meaning midi2nmat can make use of it).
Best of luck.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top