home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / next / programm / 7832 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.4 KB  |  93 lines

  1. Newsgroups: comp.sys.next.programmer
  2. Path: sparky!uunet!caen!dmno
  3. From: dmno@math.lsa.umich.edu (Lo Shih)
  4. Subject: recording from DSP problems
  5. Message-ID: <SbV=wG=@engin.umich.edu>
  6. Date: Fri, 18 Dec 92 23:10:27 EST
  7. Organization: University of Michigan, Mathematics Department, Ann Arbor
  8. Sender: Lo Shih and Chris Miller, {lfo}{ff}
  9. Distribution: comp.sys.next.programmer
  10. Keywords: DSP, Sound, record, IB, AppKit
  11. Nntp-Posting-Host: winterpark.math.lsa.umich.edu
  12. Lines: 79
  13.  
  14. We are building a Sound App and we're having problems recording
  15. from the DSP. We're using a MetaResearch Digital Ears to sample
  16. our sound into the Next standard Sound structure. 
  17.  
  18. We know that the Digital Ears works because we can issue a "sndrecord -d"
  19. command from the terminal with success.
  20.  
  21. We're setting the data format of our Sound to SND_FORMAT_DSP_DATA_16 
  22. when recording and changing the data format to SND_FORMAT_LINEAR_16
  23. when playing (which is recommended by the GeneralRef/AppKit docs).
  24. We know that we've filled the Sound struct with some data. We get a 
  25. logical value for duration sampleCount and dataSize. 
  26.  
  27. However, when we send the sound a play message, nothing is played
  28. and an error code "18" is returned. We put some of our code at the
  29. end of this article.
  30.  
  31. Please help us if you can. 
  32.                                     - Lo Shih
  33.                                     - Chris Miller
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. our code:
  41.  
  42. - record:sender
  43.   /*
  44.    *  If ready, initialize the sound struct and record
  45.    */
  46.   if ([theSound status] == NX_SoundStopped) {
  47.     [self setSoundSize];
  48.         
  49.     sndError = [theSound record];
  50.     [self printError];
  51.   }
  52.   
  53.   return self;
  54. }
  55.  
  56. - setSoundSize
  57. {
  58.   /*
  59.    *  if the NXRadio is on MIC then record from microphone
  60.    *  otherwise record from the DSP
  61.    */
  62.   if ([micRadio state]) {
  63.     [theSound setDataSize:(int)9000000
  64.       dataFormat:(int)SND_FORMAT_MULAW_8
  65.       samplingRate:(int)SND_RATE_CODEC
  66.       channelCount:(int)1
  67.       infoSize:(int)4];
  68.   }
  69.   else {
  70.     [theSound setDataSize:(int)9000000
  71.       dataFormat:(int)SND_FORMAT_DSP_DATA_16
  72.       samplingRate:(int)SND_RATE_HIGH
  73.       channelCount:(int)2
  74.       infoSize:(int)4];
  75.   }
  76. }
  77.  
  78. - play:sender
  79. {
  80.   if (([theSound status] == NX_SoundStopped) || 
  81.           ([theSound status] == NX_SoundPlayingPaused)) {
  82.     if (![theSound isPlayable]) {
  83.         [theSound convertToFormat:(int)SND_FORMAT_LINEAR_16];
  84.     }
  85.     sndError = [theSound play];
  86.     [self printError];
  87.   }
  88.     
  89.   return self;    
  90. }
  91.  
  92.