PianoGeek (6) [Avatar] Offline
#1
I would like to display notes over lyrics to a window like this:


A3 G3 F3 E3 D3 E3 E3
Mar-ry had a lit-tle lamb.

I was using the open midi file routine in connection with MyMidiIn from the MidiSpy program. I placed the open routine within the C(classname)Doc.cpp and the MyMidiIn routine within the C(classname)View.cpp area.
I also don't want to open the midi file from my keyboard but to retrieve it from my hard drive. That was no problem. The problem is accessing the individual midi events from
pTrackList->GetMidiEvent
(CMaxMidiTrack** pTrackList).
When it's defined like that within C(class name)Doc.h the compiler says it cannot translate CMaxMidiTrack** to CMaxMidiTrack*. It's getting very monotonous.

I am using REXX Script like suggested which is accessing the data beautifully. Only problem is I can't get the data to a window. The only way is creating a text file and seeing it within notepad. But I want the ability to interact with the data. So I can create staves and being able to edit the staves from the screen.

Please help!

Thanks for your attention!

PianoGeek
KUMA (56) [Avatar] Offline
#2
Re: Displaying midievents to a window
You'll be able to access the ith event of track n by pTrackList[n]->GetEvent(i).
PianoGeek (6) [Avatar] Offline
#3
Re: Displaying midievents to a window
Thanks KUMA for responding! Yes I agree with you. That line of code you wrote should work. I am using that very code. I saw it in an earlier post within this forum. I also saw it in the book within the MaxSeq program. Specifically under the OnOpenDocument(LPCSTR lpszPathName function in the Document Class of MaxSeq. I believe it's page number 425 towards the bottom of the page.

The problem I'm experiencing is within the definition of pTrackList. The line of code looks like this

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

The error happens within the loop of getting the event under:

pTrackList[i]=new CMaxMidiTrack;

the error states it cannot reinterpret CMaxMidiTrack** to CMaxMidiTrack* or visa versa.

I declared CMaxMidiTrack** in the header file of the Document Class like this:

CMaxMidiTrack** pTrackList;

but I didn't use the single asterik :

CMaxMidiTrack* pRecTrack;

because I want to use the midi file from the hard disk not from my external midi piano.

By the way what is the purpose of the double asterik anyways? I believe the only pointers I know of are these:

->
*
&
classname=new classname

Any help would be appreciated. I tested to see if the file is being opened by printing out the filename at the time of opening. The same for the number of tracks. And I got good output on both conditions. It's when I hit that loop for getting the event. Mr. Messick has MaxSeq and the other programs designed to be integrated with the external midi, not with files already on the computer. For example CMaxMidiIn Class. If you notice in MyMidiIn under MidiSpy it's specifically using most of CMaxMidiIn class for a lot of it's header file.

Please advise. Any help would be appreciated! Thankyou!

PianoGeek
PianoGeek (6) [Avatar] Offline
#4
Re: Displaying midievents to a window
I forgot to ask within my last post....If I don't use:

CMaxMidiTrack* pRecTrack;

how should I input this line then:

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

Also, on occaision I noticed when there's no compiling error when the program I created runs at the time of getting the midi event the program will crash. Is that due to my original definitions of my events?

Thanks again!

PianoGeek
PianoGeek (6) [Avatar] Offline
#5
Re: Displaying midievents to a window
Also another quick question. In the line of code

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

why is the programmer using the actual class name and not the pointer pTrackList? Meaning in the header file pTrackList is declared like this:

CMaxMidiTrack** pTrackList;

and CMaxMidiTrack* is declared as:

CMaxMidiTrack* pRecTrack;

now as I'm a new C++ programmer I've come to the understanding usually the pointer has the * and the class it points to doesn't. Why do they use the actual class name with an asterik in the line of code above? Instead of the pointer names *pTrackList and *pRecTrack?

Is there a good book that covers these questions? I purchased C++ in 24 hours by Jesse Liberty. But I believe these questions are for a book a little further advanced. Do you agree?
KUMA (56) [Avatar] Offline
#6
Re: Displaying midievents to a window
The double asterisk means a pointer to a pointer.
The line:

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

allocates a buffer. (CMaxMidiTrack**) is added to make a so-called cast.
You'd better reffer to some introductory book on Windows programmig.

I don't understand what you mean by such phrases as:

> but I didn't use the single asterik :
>
> CMaxMidiTrack* pRecTrack;
>
> because I want to use the midi file from the hard
> disk not from my external midi piano.

By the way, why don't you try to add a editor to MaxSeq?
The ruoutines to load standard midi file and to access the events are already there in MaxSeq.
PianoGeek (6) [Avatar] Offline
#7
Re: Displaying midievents to a window
Thanks for responding KUMA. I'm using Jesse Liberty's book Learn C++ in 24 hours. But since it's a introductory book it won't show advanced techniques of methods used by Paul Messick. For all I know it does, but in the book the example code is designed for it's own small method. Then I have to figure out how Paul uses his code and then try to find how to use it in Jesse Liberty's book. It's been tough doing so.

Back to that line of code we're discussing with CMaxMidiTrack, the code so far I'm familiar with is used like this:

class *classobject

then use that pointer to access methods and variables with the arrow symbol ->. I haven't seen the actual class being used in the method definitions with it's actual name and then the indirection pointer * used along with it. That's why I was so confused.

The reason I said about being hesitant in using pRecTrack, was that I assumed that pRecTrack meant midievents coming from the keyboard and recorded from MaxSeq. And the whole purpose of the open function was for retrieving from the record operation. But thinking about it I realize that can't be so, because I can open midi files using MaxSeq and have them played. So then my logic said if that's true it has to be using that particular open function within MaxSeq. All I would have to do is cut the section of MyMidiIn from MidiSpy, which points to the midi data and prints to screen. And attach to the open function of MaxSeq. But the problem with that is MyMidiIn uses CMaxMidiIn as a base class. Meaning to me that the data will be pointed from my external piano synth and not from the actual midi file on hard disk. So I took out the base class which looks like this in MyMidiIn:

class MyMidiIn : public CMaxMidiIn

after taking out the base class leaving it like this:

class MyMidiIn

and then reintegrated MyMidiIn witihin CMaxSeqView.
But it crashes when I execute it. Meaning I get the windows error screen with a choice to send to microsoft or not.

I also purchased Jim Conger's book on Progamming Midi In C, but in order for that book to make sense you need his companion book Midi Sequencing In C. Both book primarily use Assembler with C code. So that means you need an Assembler book as well. ARRRRGGGGG!

In Paul's code I see CMaxMidiIn and Out used constantly. But he doesn't really explain clearly in his book how to
use a midi file with output to a screen. He just shows how to have the computer play it. And not how to create a buffer and place it on the heap so a programmer could create a composing program and display the events like sheet music to the screen. I do realize that staff and note symbols is a whole other story. But at least I need to be able to create a memory area to store the data and be able to retrieve the data from within my program.

Please help. And if you know of any book titles to help me please write them on your next post so I can start to translate Paul's code. Thanks!
KUMA (56) [Avatar] Offline
#8
Re: Displaying midievents to a window
It seems that you need to learn many more about C/C++ and Windows programming before starting out on your task.
As I remember Paul recommended:

Programming Windows 95 by Charles Petzold

for example, see:

http://www.manning-sandbox.com/thread.jspa?threadID=5455&tstart=900