home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / Resound / ReverseModule.m < prev    next >
Encoding:
Text File  |  1992-04-02  |  1.4 KB  |  69 lines

  1.  
  2. #import "ReverseModule.h"
  3. #import "Imports.h"
  4.  
  5.  
  6. @implementation ReverseModule
  7.  
  8. - ReverseIt:sender
  9. {
  10.     id Currentsound=[TheModuleController CurrentSound:self];
  11.     int DataFormat=[Currentsound dataFormat];
  12.     
  13.     
  14.     if ((DataFormat==SND_FORMAT_MULAW_8)||
  15.         (DataFormat==SND_FORMAT_MULAW_SQUELCH)||
  16.         (DataFormat==SND_FORMAT_LINEAR_8)||
  17.         (DataFormat==SND_FORMAT_DSP_DATA_8) )
  18.         
  19.         
  20.         {    
  21.         char *TheSamples;
  22.         int NumberOfSamples;
  23.         int x;
  24.         char Trader;
  25.         if ([TheModuleController RunCompactPanel:self]);
  26.             {
  27.             [Currentsound compactSamples];
  28.             TheSamples=(char *)[Currentsound data];
  29.             NumberOfSamples=[Currentsound sampleCount];
  30.             for (x=0;x<(NumberOfSamples-1)/2;x++)
  31.                 {
  32.                 Trader=TheSamples[x];
  33.                 TheSamples[x]=TheSamples[NumberOfSamples-x];
  34.                 TheSamples[NumberOfSamples-x]=Trader;
  35.                 }
  36.             [TheModuleController SoundChanged:Currentsound];
  37.             return self;
  38.             }
  39.         }
  40.         
  41.     else
  42.         
  43.         {
  44.         short int *TheSamples;
  45.         int NumberOfSamples;
  46.         int x;
  47.         short int Trader;
  48.         if ([TheModuleController RunCompactPanel:self]);
  49.             {
  50.             [Currentsound compactSamples];
  51.             TheSamples=(short int *)[Currentsound data];
  52.             NumberOfSamples=[Currentsound sampleCount];
  53.             for (x=0;x<(NumberOfSamples-1)/2;x++)
  54.                 {
  55.                 Trader=TheSamples[x];
  56.                 TheSamples[x]=TheSamples[NumberOfSamples-x];
  57.                 TheSamples[NumberOfSamples-x]=Trader;
  58.                 }
  59.             [TheModuleController SoundChanged:Currentsound];
  60.             return self;
  61.             }
  62.         }
  63.  
  64.     
  65. }
  66.  
  67.  
  68. @end
  69.