import-bot (20212) [Avatar] Offline
#1
[Originally posted by dsmey]

Hi all,

I'm trying to write programs that will generate short snippets of music in
tracks. I'm using the CBuilder port of MaxMIDI. I am having the darndest
time getting the events in the track to sound in time -- this simple prog
should create a chromatic line, but instead all I get is a cluster. I'm sure
I'm not understanding some basic thing w/ the sync, or something. Can anybody
help?

__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// MaxMidi, Out, & Sync are all created and hooked up at design time.

MaxMidiOut->Open(0);
MaxMidiSync->Open();

Score = new TMaxMidiScore(1);
MaxMidiOut->Attach (Score);

FillScore();
}
//---------------------------------------------------------------------------
void TForm1::FillScore(void)
{
MidiEvent bonk;

//initial event
bonk.status = 144;
bonk.data1 = 60;
bonk.data2 = 60;
bonk.data3 = 0;
bonk.time = 0;

Score->Tracks[0]->InsertEvent(&bonk, -1);
// oddly, I can't get Score->Tracks[0]->Write(&bonk); to work at all.

// 10 more notes
for (int i=0; i<10; i++)
{
bonk.status = 144;
bonk.data1 = 60 + i + 1;
bonk.data2 = 60;
bonk.data3 = 0;
bonk.time = 1000 * (i+1);

Score->Tracks[0]->InsertEvent(&bonk, -1);
}
}
//======================================================
void __fastcall TForm1::Button1Click(TObject *Sender)
{
MaxMidiSync->Start();
Score->StartOut(MaxMidiOut);
}
import-bot (20212) [Avatar] Offline
#2
Re: problem creating tracks, using CBuilder
[Originally posted by dsmey]

ugh, finally figured it out. Apparently I should not open the Sync &
MaxMidiOut before attaching the score? Changing the opening code to

Score = new TMaxMidiScore(1);
MaxMidiOut->Attach (Score);

MaxMidiSync->Open();
MaxMidiOut->Open(0);

FillScore();

fixed the problem.