home *** CD-ROM | disk | FTP | other *** search
-
- // A GKSound adds a single function to the Sound object: It won't
- // allow itself to be played "too much". It know when it was last
- // played and if you attempt to play it too soon after, it ignores
- // the playback message. Also, you tell it which GKSoundStream to
- // play back on. Because of this special playback method, it breaks
- // all the delegate methods of the play notification. (I can't use
- // super's -play: since I am completely overriding what it does...
- // if I had source to the Sound object, I suppose that I could re-
- //implement what super does, but the object as is can't be subclassed
- // the way I need and still retain it's old functionality. I blame
- // NeXT for this, as it seems to be a poor design that doesn't allow
- // proper subclassing+retaining functionality.)
- //
- // This object will convert itself to 16-bit linear 22050 kHz after
- // load and init so that it will work on the NXSoundStreams. If you
- // edit (and fragment) the sound, be sure to compact it before playing!
- // if you change the sound's length in any way via editing, you should
- // be sure to set up the time/percent again, as they aren't changed
- // due to edits. This is because (1) you should only change it if
- // you're going by percent, and you may be going by absolute playback
- // time, and I don't track which you used to set it up (easy to overcome)
- // and (2) there's tons of ways to alter a sound and I didn't feel
- // like overriding every method since games seldom edit their sounds!
-
- #import <appkit/appkit.h>
- #import <soundkit/soundkit.h>
-
- @interface GKSound:Sound
- {
- id nextPlay; // A DAYTime that estimates when sound OK to play again
- id streamGroup; // The GKSoundStream which we use for playback
- id timeToPlay; // how much of the sound can be unplayed and
- // still allow us to play it again (DAYTime)
- id now; // DAYTime used to hold current time; we keep it
- // around so that we aren't constantly alloc'ing it
- // since dynamic allocation is expensive timewise.
- }
-
- - setPercentToPlay:(double)percent; // how much to play before next play
- // percent is in range [0,1].
- - setTimeToPlay:aTime; // how long to play sound before next play
- - setPlayStream:aStream; // a GKSoundStream for playback
- - convert; // attempt conversion to 16bit 22.05kHz mono sound
-
- - _initGKSound; // private method to set up ivars
-
- @end
-