Skip to content

Commit

Permalink
restyle.sh applied
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkoftinoff committed Aug 28, 2010
1 parent 038fba7 commit d002a58
Show file tree
Hide file tree
Showing 65 changed files with 12,973 additions and 13,548 deletions.
100 changes: 48 additions & 52 deletions examples/jdksmidi_rewrite_midifile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,62 +36,58 @@

int main ( int argc, char **argv )
{
int return_code=-1;
if ( argc>2 )
{
const char *infile_name = argv[1];
const char *outfile_name = argv[2];
int return_code = -1;

// the stream used to read the input file
jdksmidi::MIDIFileReadStreamFile rs ( infile_name );

// the object which will hold all the tracks
jdksmidi::MIDIMultiTrack tracks;

// the object which loads the tracks into the tracks object
jdksmidi::MIDIFileReadMultiTrack track_loader ( &tracks );

// the object which parses the midifile and gives it to the multitrack loader
jdksmidi::MIDIFileRead reader ( &rs, &track_loader );

// load the midifile into the multitrack object
reader.Parse();

// create the output stream
jdksmidi::MIDIFileWriteStreamFileName out_stream ( outfile_name );

if ( out_stream.IsValid() )
if ( argc > 2 )
{
// the object which takes the midi tracks and writes the midifile to the output stream
jdksmidi::MIDIFileWriteMultiTrack writer (
&tracks,
&out_stream
);

// extract the original multitrack division and number of tracks

int num_tracks = reader.GetNumberTracks();
int division = reader.GetDivision();

// write the output file
if ( writer.Write ( num_tracks, division ) )
{
return_code = 0;
}
else
{
fprintf ( stderr, "Error writing file '%s'\n", outfile_name );
}
const char *infile_name = argv[1];
const char *outfile_name = argv[2];
// the stream used to read the input file
jdksmidi::MIDIFileReadStreamFile rs ( infile_name );
// the object which will hold all the tracks
jdksmidi::MIDIMultiTrack tracks;
// the object which loads the tracks into the tracks object
jdksmidi::MIDIFileReadMultiTrack track_loader ( &tracks );
// the object which parses the midifile and gives it to the multitrack loader
jdksmidi::MIDIFileRead reader ( &rs, &track_loader );
// load the midifile into the multitrack object
reader.Parse();
// create the output stream
jdksmidi::MIDIFileWriteStreamFileName out_stream ( outfile_name );

if ( out_stream.IsValid() )
{
// the object which takes the midi tracks and writes the midifile to the output stream
jdksmidi::MIDIFileWriteMultiTrack writer (
&tracks,
&out_stream
);
// extract the original multitrack division and number of tracks
int num_tracks = reader.GetNumberTracks();
int division = reader.GetDivision();

// write the output file
if ( writer.Write ( num_tracks, division ) )
{
return_code = 0;
}

else
{
fprintf ( stderr, "Error writing file '%s'\n", outfile_name );
}
}

else
{
fprintf ( stderr, "Error opening file '%s'\n", outfile_name );
}
}

else
{
fprintf ( stderr, "Error opening file '%s'\n", outfile_name );
fprintf ( stderr, "usage:\n\tjdksmidi_rewrite_midifile INFILE.mid OUTFILE.mid\n" );
}
}
else
{
fprintf ( stderr, "usage:\n\tjdksmidi_rewrite_midifile INFILE.mid OUTFILE.mid\n" );
}

return return_code;

return return_code;
}
88 changes: 40 additions & 48 deletions examples/jdksmidi_test_drv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,64 +36,56 @@ using namespace jdksmidi;

void DumpTrackNames ( MIDISequencer *seq )
{
fprintf ( stdout, "TEMPO = %f\n",
seq->GetTrackState ( 0 )->tempobpm
);

for ( int i=0; i<seq->GetNumTracks(); ++i )
{
fprintf ( stdout, "TRK #%2d : NAME = '%s'\n",
i,
seq->GetTrackState ( i )->track_name
fprintf ( stdout, "TEMPO = %f\n",
seq->GetTrackState ( 0 )->tempobpm
);
}

for ( int i = 0; i < seq->GetNumTracks(); ++i )
{
fprintf ( stdout, "TRK #%2d : NAME = '%s'\n",
i,
seq->GetTrackState ( i )->track_name
);
}
}


void PlayDumpManager ( MIDIManager *mgr )
{
MIDISequencer *seq = mgr->GetSeq();
double pretend_clock_time = 0.0;

seq->GoToTime ( ( unsigned long ) pretend_clock_time );

mgr->SeqPlay();

// simulate a clock going forward with 10ms resolution for 1 minute

for ( pretend_clock_time=0.0; pretend_clock_time<60.0*1000.0; pretend_clock_time+=100 )
{
mgr->GetDriver()->TimeTick ( ( unsigned long ) pretend_clock_time );
}

mgr->SeqStop();
mgr->GetDriver()->AllNotesOff();

MIDISequencer *seq = mgr->GetSeq();
double pretend_clock_time = 0.0;
seq->GoToTime ( ( unsigned long ) pretend_clock_time );
mgr->SeqPlay();
// simulate a clock going forward with 10ms resolution for 1 minute

for ( pretend_clock_time = 0.0; pretend_clock_time < 60.0 * 1000.0; pretend_clock_time += 100 )
{
mgr->GetDriver()->TimeTick ( ( unsigned long ) pretend_clock_time );
}

mgr->SeqStop();
mgr->GetDriver()->AllNotesOff();
}


int main ( int argc, char **argv )
{
if ( argc>1 )
{
MIDIFileReadStreamFile rs ( argv[1] );
MIDIMultiTrack tracks ( 64 );
MIDIFileReadMultiTrack track_loader ( &tracks );
MIDIFileRead reader ( &rs, &track_loader );
MIDISequencerGUIEventNotifierText gui ( stdout );
MIDISequencer seq ( &tracks, &gui );
MIDIDriverDump driver ( 128,stdout );
MIDIManager mgr ( &driver, &gui );

reader.Parse();

seq.GoToZero();
mgr.SetSeq ( &seq );

DumpTrackNames ( &seq );
if ( argc > 1 )
{
MIDIFileReadStreamFile rs ( argv[1] );
MIDIMultiTrack tracks ( 64 );
MIDIFileReadMultiTrack track_loader ( &tracks );
MIDIFileRead reader ( &rs, &track_loader );
MIDISequencerGUIEventNotifierText gui ( stdout );
MIDISequencer seq ( &tracks, &gui );
MIDIDriverDump driver ( 128, stdout );
MIDIManager mgr ( &driver, &gui );
reader.Parse();
seq.GoToZero();
mgr.SetSeq ( &seq );
DumpTrackNames ( &seq );
PlayDumpManager ( &mgr );
}

PlayDumpManager ( &mgr );
}

return 0;
return 0;
}
105 changes: 46 additions & 59 deletions examples/jdksmidi_test_multitrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,91 +37,78 @@ using namespace jdksmidi;

void DumpMIDITimedBigMessage ( MIDITimedBigMessage *msg )
{
if ( msg )
{
char msgbuf[1024];

fprintf ( stdout, "%8ld : %s\n", msg->GetTime(), msg->MsgToText ( msgbuf ) );
if ( msg->IsSysEx() )
if ( msg )
{
fprintf ( stdout, "\tSYSEX length: %d\n", msg->GetSysEx()->GetLength() );
char msgbuf[1024];
fprintf ( stdout, "%8ld : %s\n", msg->GetTime(), msg->MsgToText ( msgbuf ) );

if ( msg->IsSysEx() )
{
fprintf ( stdout, "\tSYSEX length: %d\n", msg->GetSysEx()->GetLength() );
}
}

}

}

void DumpMIDITrack ( MIDITrack *t )
{
MIDITimedBigMessage *msg;

for ( int i=0; i<t->GetNumEvents(); ++i )
{
msg = t->GetEventAddress ( i );
DumpMIDITimedBigMessage ( msg );
MIDITimedBigMessage *msg;

}

for ( int i = 0; i < t->GetNumEvents(); ++i )
{
msg = t->GetEventAddress ( i );
DumpMIDITimedBigMessage ( msg );
}
}

void DumpAllTracks ( MIDIMultiTrack *mlt )
{

fprintf ( stdout , "Clocks per beat: %d\n\n", mlt->GetClksPerBeat() );

for ( int i=0; i<mlt->GetNumTracks(); ++i )
{
if ( mlt->GetTrack ( i )->GetNumEvents() > 0 )
fprintf ( stdout , "Clocks per beat: %d\n\n", mlt->GetClksPerBeat() );

for ( int i = 0; i < mlt->GetNumTracks(); ++i )
{
fprintf ( stdout, "DUMP OF TRACK #%2d:\n", i );
DumpMIDITrack ( mlt->GetTrack ( i ) );
fprintf ( stdout, "\n" );
if ( mlt->GetTrack ( i )->GetNumEvents() > 0 )
{
fprintf ( stdout, "DUMP OF TRACK #%2d:\n", i );
DumpMIDITrack ( mlt->GetTrack ( i ) );
fprintf ( stdout, "\n" );
}
}

}

}


void DumpMIDIMultiTrack ( MIDIMultiTrack *mlt )
{
MIDIMultiTrackIterator i ( mlt );
MIDITimedBigMessage *msg;

fprintf ( stdout , "Clocks per beat: %d\n\n", mlt->GetClksPerBeat() );

i.GoToTime ( 0 );

do
{
int trk_num;
MIDIMultiTrackIterator i ( mlt );
MIDITimedBigMessage *msg;
fprintf ( stdout , "Clocks per beat: %d\n\n", mlt->GetClksPerBeat() );
i.GoToTime ( 0 );

if ( i.GetCurEvent ( &trk_num, &msg ) )
do
{
fprintf ( stdout, "#%2d - ", trk_num );
DumpMIDITimedBigMessage ( msg );
int trk_num;

if ( i.GetCurEvent ( &trk_num, &msg ) )
{
fprintf ( stdout, "#%2d - ", trk_num );
DumpMIDITimedBigMessage ( msg );
}
}
}
while ( i.GoToNextEvent() );

while ( i.GoToNextEvent() );
}



int main ( int argc, char **argv )
{
if ( argc>1 )
{
MIDIFileReadStreamFile rs ( argv[1] );
MIDIMultiTrack tracks;
MIDIFileReadMultiTrack track_loader ( &tracks );
MIDIFileRead reader ( &rs, &track_loader );

reader.Parse();

DumpMIDIMultiTrack ( &tracks );
if ( argc > 1 )
{
MIDIFileReadStreamFile rs ( argv[1] );
MIDIMultiTrack tracks;
MIDIFileReadMultiTrack track_loader ( &tracks );
MIDIFileRead reader ( &rs, &track_loader );
reader.Parse();
DumpMIDIMultiTrack ( &tracks );
}

}

return 0;
return 0;
}
Loading

0 comments on commit d002a58

Please sign in to comment.