home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / SoundApps / TimeWarp / Source / Controller.h < prev    next >
Encoding:
Text File  |  1995-06-12  |  3.1 KB  |  105 lines

  1. /* Contoller.h
  2.  * The Controller is provides all of the User Interface as well as the
  3.  * computational "guts" of the TimeWarp application.
  4.  *
  5.  * You may freely copy, distribute, and reuse the code in this example.
  6.  * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  7.  * fitness for any particular use.
  8.  *
  9.  * Written by: Robert Poor
  10.  * Created: Sep/92
  11.  */
  12.  
  13. #import <objc/Object.h>
  14. #import "DACPlayer.h"
  15. #import <sound/sound.h>
  16. #import <dpsclient/dpsclient.h>    /* for DPSTimedEntry */
  17.  
  18. #define SPEED_RANGE    4.0
  19. /* 
  20.  * speed will change from 1/SPEED_RANGE to SPEED_RANGE as the slider
  21.  * is changed from 0 to 1.
  22.  */
  23.  
  24. #define UPDATE_RATE    0.66667
  25. /*
  26.  * UPDATE_RATE determies how often we update the status display
  27.  */
  28.  
  29. /***
  30.  *** FIXPOINT DEFINITIONS
  31.  *** We use fixpoint math in the inner loops.  A fixpoint number has
  32.  *** the binary point right in the middle, so a fixpoint 1.0 is represented
  33.  *** by 0x00010000, and .25 represented by 0x00004000.
  34.  ***/
  35.  
  36. typedef    long    fixpoint_t;
  37. #define LOG2_FIXPOINT_UNITY    (16)    
  38. #define FIXPOINT_UNITY        (1<<LOG2_FIXPOINT_UNITY)
  39.  
  40. @interface Controller:Object
  41. {
  42.   /* principal UI components */
  43.   id    window;        /* the main control panel */
  44.   id    speedSlider;    /* slider to control speed */
  45.   id    speedField;    /* text field to control speed */
  46.   id    repeatButton;    /* repeat the sound when it stops */
  47.   id    statusField;    /* text field for displaying general messages */
  48.   id    queuedField;    /* text field to describe how much has been queued */
  49.   id    playedField;    /* text field to describe how much has been played */
  50.   id    completionView;    /* a CompletionView indicator */
  51.   id    completionField;    /* a textField for the completion view */
  52.   
  53.   /* internal objects */
  54.   DPSTimedEntry    updateTE;    /* timed entry for updating status display */
  55.   DACPlayer    *dacPlayer;    /* an object to play the sound */
  56.   char    *filename;        /* name of the sound file to be processed */
  57.   SNDSoundStruct *srcSound;    /* sound structure associated with filename */
  58.   short    *src, *srcBase, *srcEnd;    /* cached pointers to sound data */
  59.   float rate;            /* rate at which we play the sound */
  60.   fixpoint_t    fixRate;    /* fixpoint representation of current rate */
  61.   fixpoint_t    residue;    /* current fractional offset from src */
  62.   BOOL    stoppedManually;    /* set to true when the stop button pushed */
  63. }
  64.  
  65. - init;
  66. - free;
  67. - appDidInit:sender;
  68.  
  69. - openSoundFile:sender;
  70. /* open a sound file for playback */
  71.  
  72. - closeSoundFile:sender;
  73. /* close existing sound file */
  74.  
  75. - play:sender;
  76. /* start playing a sound */
  77.  
  78. - stop:sender;
  79. /* stop playing current sound */
  80.  
  81. - pause:sender;
  82. /* pause (or prepare) the current sound */
  83.  
  84. - setSpeedLinear:sender;
  85. /*
  86.  * Set the playback speed linearly.  The speed will be set to the value as
  87.  * returned by [sender floatValue].
  88.  */
  89.  
  90. - setSpeedLogarithmic:sender;
  91. /*
  92.  * set the speed logarithmically.  The speed will be set to 1/SPEED_RANGE to
  93.  * SPEED_RANGE as [sender floatValue] ranges from 0 to 1.
  94.  */
  95.  
  96. /**
  97.  ** Delegate methods for the DACPlayer
  98.  **/
  99.  
  100. - willPlay :player;
  101. - didPlay :player;
  102. - playData :player :(char *)data :(int)nbytes;
  103. - didChangeState :player from:(Pla_state_t)old to:(Pla_state_t)new;
  104.  
  105. @end