/*********************************************************************
*
*  manyplay             01 Aug 88            Copyright (c) 1988 cMIDI 
*
*  cMIDI function library demonstration.  File 9 of 20.
*
*********************************************************************/
#include <stdio.h>
#include <cmidi.h>

main( int argc, char *argv[] )
   {
   int i, copies, transposition;

   /* Open cmidi, and prepare the track(s). */
   CmidiOpen();
   TrackPtrRegister( 1, TRACK_PTR_PLAY );
   TrackReadCmidiData( argv[1], 1 );
   TrackPtrPlayListInsert( 1 );
   if ((argc!=4) || ERRORQUEUED())
      {
      printf( "Proper command line format: \n\n"
   "  manyplay filename copies transposition \n\n"
   "  where \"filename\" specifies name of file containing track data\n"
   "        \"copies\" specifies number of times track data is copied\n"
   "        \"transposition\" specifies transposition of track copies\n");
      CmidiClose(CLOSE_RESET_MPU);
      exit( 1 );
      }

   copies = atoi( argv[2] );
   transposition = atoi( argv[3] );
   for (i=2; i<=(copies+1); i++)
      {
      TrackPtrRegister( i , TRACK_PTR_PLAY );
      TrackPtrCopy( i, 1 );
      TrackPtrPlayListInsert( i );
      TrackPtrTranspose( i, (i-1)*transposition );
      }

   TrackPlay();
   /* Wait until playing has finished, then close cmidi. */
   while ( PLAYING() );
   CmidiClose( CLOSE_RESET_MPU | CLOSE_PRINT_ERRORS );
   }
