jdkmidi class library documentation

Copyright © 2004 J.D. Koftinoff Software, Ltd.

Released under the GNU General Public License (GPL)




Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

tests/jdkmidi_test_parse.cpp File Reference

#include "jdkmidi/world.h"
#include "jdkmidi/midi.h"
#include "jdkmidi/msg.h"
#include "jdkmidi/sysex.h"
#include "jdkmidi/parser.h"

Go to the source code of this file.

Functions

void PrintSysEx (FILE *f, MIDISystemExclusive *ex)
void PrintMsg (FILE *f, MIDIMessage *m)
int main (int argc, char **argv)


Function Documentation

int main int  argc,
char **  argv
 

Definition at line 81 of file jdkmidi_test_parse.cpp.

References jdkmidi::MIDIParser::GetSystemExclusive(), jdkmidi::MIDIMessage::IsSysEx(), jdkmidi::MIDIParser::Parse(), PrintMsg(), PrintSysEx(), and uchar.

00082 {
00083   fprintf( stdout, "mdparse:\n" );
00084   
00085   MIDIParser p(32*1024);
00086   MIDIMessage m;
00087   FILE *f = stdin;
00088   
00089   while( !feof(f) )
00090   {
00091     int c = fgetc(f); 
00092     
00093     if( c==EOF )
00094       break;
00095     
00096     if( p.Parse( (uchar)c, &m ) )
00097     {     
00098       if( m.IsSysEx() )
00099       {
00100         PrintSysEx( stdout, p.GetSystemExclusive() );
00101       }     
00102       else
00103       {
00104         PrintMsg( stdout, &m );
00105       }         
00106     }     
00107   }
00108   
00109   return 0;
00110 }

void PrintMsg FILE *  f,
MIDIMessage m
 

Definition at line 53 of file jdkmidi_test_parse.cpp.

References jdkmidi::MIDIMessage::GetByte1(), jdkmidi::MIDIMessage::GetByte2(), jdkmidi::MIDIMessage::GetLength(), jdkmidi::MIDIMessage::GetStatus(), and jdkmidi::MIDIMessage::MsgToText().

00054 {
00055   int l = m->GetLength();
00056   
00057   fprintf( f, "Msg : " );
00058   
00059   if( l==1 )
00060   {
00061     fprintf( f, " %02x \t=", m->GetStatus() );
00062   }
00063   else if( l==2 )
00064   {
00065     fprintf( f, " %02x %02x \t=", m->GetStatus(), m->GetByte1() );  
00066   }
00067   else if( l==3 )
00068   {
00069     fprintf( f, " %02x %02x %02x \t=", m->GetStatus(), m->GetByte1(), m->GetByte2() );
00070   }
00071   
00072   char buf[129];
00073   
00074   m->MsgToText( buf );
00075   
00076   fprintf( f, "%s\n", buf );
00077   fflush(f);
00078 }

void PrintSysEx FILE *  f,
MIDISystemExclusive ex
 

Definition at line 34 of file jdkmidi_test_parse.cpp.

References jdkmidi::MIDISystemExclusive::GetData(), and jdkmidi::MIDISystemExclusive::GetLength().

00035 {
00036   int l = ex->GetLength();
00037   
00038   fprintf( f, "Sysex Len=%d", l );
00039   
00040   for( int i=0; i<l; ++i )
00041   {
00042     if( ((i)%20) == 0 )
00043     {
00044       fprintf( f, "\n" );
00045     }   
00046     fprintf( f, "%02x ", (int)ex->GetData( i ) );   
00047   }
00048   fprintf( f, "\n" );
00049   fflush(f);
00050 }