This is Play.h in view mode; [Download] [Up]
/* Play.h */ /* Play is an object that can play a piece of a soundfile at any sampling rate, to the NeXT soundout, or to the SSI port, in A/D64x format for SPdiff transfer (digital transfer). To start with, you need to create an instance of the Play object, and set its delegate to an appropriate delegate. The delegate is the object Play will send its messages to, when appropriate. To play a sound, you need to setup the Play object correctly (sampling rate, stereo, and output), then you invoque the play::: method, passing the sound structure, the first sample that needs to be played, and the length of the chunk to play. Play will grab the DSP, load its executable, and start playing in the background. When it's done playing, it calls the delegate's didPlay method with self as an argument. You can stop playing at any time. The DSP is instantly released, so another application can use it. You can pause and resume playing, only when you're playing to the NeXT sound-out (pausing a sound that's output to the SSI is kind of a drag to implement)! */ #import <appkit/Application.h> #import <sound/sound.h> #import <sound/sounddriver.h> #import <streams/streams.h> #import <sys/file.h> #import <defaults/defaults.h> #import <mach/mach.h> #import <math.h> #import <stdio.h> #import <strings.h> #import <sound/accesssound.h> #import <soundkit/Sound.h> #import <mach/message.h> /* for msg_header_t */ #define AES_HIGH 2 #define AES_LOW 1 #define IDLE 0 #define PLAYING 1 #define PAUSED 2 #define LEFT 0 #define RIGHT 1 #define STEREO 2 #define SUM 3 #define MONO 4 @interface Play:Object { id delegate; DPSTimedEntry play_mon; port_t dev_port, owner_port,cmd_port; port_t reply_port, read_port, write_port; int protocol; kern_return_t k_err; SNDSoundStruct *sound; char *file[100]; SNDSoundStruct *dspStruct; msg_header_t *reply_msg; NXStream *mapfile; int low_water; int high_water; short *location; int stereo; int verbose; int CHANNEL; int AES; int INIT; int ster; int U, D, K, Filter_length; int para[4],rat[2]; int *filtre; float cut, thresh, offset; float gain; int S_rateIn, S_rateOut, S; short *foo; short *faa; int nb_iteration,inc,start; int status; int max_order; int first_samp, size_samp; char *errorMessage; BOOL WAIT; } //------------ Factory method to instantiate a new Play object. + new; - setDelegate:anObject; /* Methods to set the Play object: * -setSamplingRate: -- Sets Sampling Rate to desired value. * - setOutput: -- Sets Output as follows setOutput:0 NeXT Dacs setOutput:AES_HIGH ssi port, to A/D64X converters, 48kHz, digital setOutput:AES_LOW ssi port, to A/D64X converters, 44.1kHz, digital * - setMonoMode: -- Sets playing mode (use MONO or STEREO) * - setWait: -- If YES, Play waits until completion. * - setGain: -- Use to insert gain in the playback. */ - setSamplingRate:(int)aSamplingRate; - setOutput:(int)anOutput; - setGain:(float)aGain; - setMonoMode:(int)aMode; - setWait:(BOOL)wait; /* Methods to start, pause, resume and stop playing. * - playSound: -- Starts playing. Returns immediately. Return code 0 when no error, -1 if an error was encountered. * - stop: -- Stops Playing (the delegate receives a didPlay message) * - pause: -- Pauses when playing, resumes when paused. */ - (int) playSound:(SNDSoundStruct*)aSound:(int)begin:(int)length; - stop; - (int)pause; - pause:sender; /* handle to be used with a button */ /* The delegate can implement the following methods: - didPlay:sender; -- To acknoledge end of playback - error:(char*)anError; -- This is called whenever there's a problem. anError is a string containing the description of the error - soundAnimate:(int)samples; -- Sent periodically to tell the delegate how many samples have been played back so far. */ /////////// All this is needed by the object, but you shouldn't use it... - calculateRatio:(float)aRatio:(int*)aFactor:(float)aThreshold; - calculateFilter:(int*)aFilter:(int)aLength:(float)aCutoff:(int)anUpFactor; - playCompleted:tag; - playMonitor; @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.