student (9) [Avatar] Offline
#1
Hello,
I am trying to build a midi sequencer with a graphic editor for my final year project. The problem I have at the moment is that when I open a Midi file and try to read the contents of the track to get notes etc. I always get the same values, no matter which midi file I open.
Which are:
data1 = 6
data2 = 138
data3 = 27
I am using SMF.Load() to load the file. Certainly I'm missing some big point over here...Is this the header chunk I'm viewing? Also I get only one midievent in the buffer.

My deadline is getting really shorter so any help would be appreciated

Another, irrelevant question: I'm interested in getting a job in the music software industry, especially sound synthesis and effects. Does anyone have any suggestions, guidelines in what step I should take after finishing my degree, which is Computer Science, mostly programming in C++. Any master degrees that would help, schools etc. In any country...
KUMA (56) [Avatar] Offline
#2
Re: Read Midi Event
Have you done it following the example on p.201 of the book?
What function did you use to read the content of the track?
student (9) [Avatar] Offline
#3
Re: Read Midi Event
I didn't do that example. But I used the code that the MaxSeq exapmle uses which is the same.
Amnf other funcrtions I also the SMF.Load(). But I used the debugger to see the memory contents, went in the Load() function and so on, so I suppose its not the function that creates the problem... Is there any way it can be the midi file?
Thanks for ur time
KUMA (56) [Avatar] Offline
#4
Re: Read Midi Event
What pointer did you specify to view the data?
What the status of the event?

Header chunk and other non-MIDI data are not put in tracks attached; SMF.Load function ignores any Meta Events except Set Tempo, Track Name, and End of Track; track names are not put in tracks attached.
So the 1st event of track 0 is usually containing 3 bytes tempo data with status 0.

By the way, can you open and read your SMFs using directly OpenSMF and ReadSMF function?
student (9) [Avatar] Offline
#5
Re: Read Midi Event
this is the code to open and load the midi file:
/////////////////////////////////////////////////
MidiEvent* event;
int NumEvents = 0;
BYTE status, data1, data2, data3;
int i,i2;

POSITION pos = GetFirstViewPosition();
COpenMidiView* pView = (COpenMidiView*)GetNextView(pos);

if(pTrackList)
{
for(i=0; i<nTracks; i++) >
if(pTrackList[i])
delete pTrackList[i];

GlobalFree(pTrackList);
pTrackList = NULL;
}

SMF.Open(lpszPathName, READ);



nTracks = SMF.NumTracks();
pTrackList = (CMaxMidiTrack**)GlobalAlloc(GPTR, sizeof(CMaxMidiTrack*) * nTracks);


for(i=0; i<nTracks; i++) >
{
pTrackList[i] = new CMaxMidiTrack;
SMF.Attach(pTrackList[i]);
pView->MidiOut.Attach(pTrackList[i]);
}

SMF.Load();
NumEvents = pTrackList[0]->GetNumEvents();
for(i=0; i<NumEvents; i++) >
{
event = pTrackList[0]->GetEvent(i);
status = event->status;
data1 = event->data1;
data2 = event->data2;
data3 = event->data3;

}
///////////////////////////////////////////////////////
I only have one track hence the pTrackList[0], This works alright now. Although I don't clearly understand why when I open a midi file with only one note I get 3 midievents...
again thanx a lot for ur help
KUMA (56) [Avatar] Offline
#6
Re: Read Midi Event
I think the point is for loop.
Pointer 'event' points ith event in the track as i increases and finally points the last event in the track.
If you use this pointer to make, for example, event list, you will get the list of all the events in the track.