home *** CD-ROM | disk | FTP | other *** search
/ Sound Sensations! / sound_sensations.iso / demos / midif / echoplay.c < prev    next >
Text File  |  1988-09-03  |  2KB  |  50 lines

  1. /*********************************************************************
  2. *
  3. *  echoplay             01 Aug 88            Copyright (c) cMIDI 1988
  4. *
  5. *  cMIDI function library demonstration.  File 8 of 20.
  6. *
  7. *********************************************************************/
  8. #include <cmidi.h>
  9. #include <stdio.h>
  10.  
  11. main( int argc, char *argv[] )
  12.    {
  13.    int i, copies, delay;
  14.  
  15.    /* Open cmidi, and prepare the track(s). */
  16.    CmidiOpen();
  17.    TrackPtrRegister( 1 ,TRACK_PTR_PLAY );
  18.    TrackReadCmidiData( argv[1], 1 );
  19.    TrackPtrPlayListInsert( 1 );
  20.    if ((argc!=4) || ERRORQUEUED())
  21.       {
  22.       printf( "Proper command line format: \n\n"
  23.    "  echoplay filename copies delay \n\n"
  24.    "  where \"filename\" specifies name of file containing track data\n"
  25.    "        \"copies\" specifies number of times track data is copied\n"
  26.    "        \"delay\" specifies # ms between start of successive copies\n");
  27.       CmidiClose(CLOSE_RESET_MPU);
  28.       exit( 1 );
  29.       }
  30.  
  31.    copies = atoi( argv[2] );
  32.    delay = atoi( argv[3] )/5;
  33.    for (i=2; i<=(copies+1); i++)
  34.       {
  35.         TrackPtrRegister( i ,TRACK_PTR_PLAY );
  36.         TrackPtrCopy( i, 1 );
  37.         TrackPtrPlayListInsert( i );
  38.         TrackPtrDelay( i, delay*(i-1) );
  39.         TrackPtrVelocityOn( i, -15*(i-1) );
  40.       }
  41.  
  42.    /* Start playing track(s). */
  43.    TrackPlay(); 
  44.  
  45.    /* Wait until playing has finished, then close cmidi. */
  46.    while ( PLAYING() );
  47.  
  48.    CmidiClose( CLOSE_RESET_MPU | CLOSE_PRINT_ERRORS );
  49.    }
  50.