home *** CD-ROM | disk | FTP | other *** search
- /*****
- * SoundEffect.c
- *
- * SoundEditor: Copyright (c) 1993 by
- *
- * Motion Works Corp.
- * #130 - 1020 Mainland Street
- * Vancouver, BC
- * (604) 685-9975
- *
- * Author: DMS (13SEP93)
- *
- * generic sound effect (SE) component source for Marvin's Modulator
- *
- *****/
-
- #include <MacHeaders>
- #include <QuickTimeComponents.h>
-
- #include "SoundEffect.h"
-
- #define kVersionNumber 1
-
- // prototypes
-
- pascal ComponentResult _SEOpen( Handle storage, ComponentInstance self );
- pascal ComponentResult _SEClose( Handle storage, ComponentInstance self );
- pascal ComponentResult _SECanDo( short selector );
- pascal ComponentResult _SEVersion( void );
- pascal ComponentResult _SETarget( ComponentInstance capturingComponent );
-
- pascal ComponentResult _SEDoEffect( Handle theSound,
- Size *newSelectionStart, Size *newSelectionEnd,
- Handle *newSound,
- Size *insertStart, Size *deleteEnd
- );
-
- pascal ComponentResult _SEWorksOnSelectionOnly( Boolean *answer );
-
-
-
- /***
- * main
- *
- ***/
-
- #ifdef DEBUG_SOUND_EFFECT
-
- // use this declaration when we're running linked
-
- pascal ComponentResult SoundEffectDispatcher( ComponentParameters *params, Handle storage )
-
- #else
-
- // use this declaration when we're building a standalone component
- // (be sure to comment out the define of DEBUG_SOUND_EFFECT in SoundEffect.h
- // before using this source file to build a standalone component)
-
- pascal ComponentResult main( ComponentParameters *params, Handle storage )
-
- #endif DEBUG_SOUND_EFFECT
- {
- ComponentResult result = noErr;
-
- // Did we get a Component Manager request code (< 0)?
-
- if ( params->what < 0 )
- {
- switch ( params->what )
- {
- // Open request
- case kComponentOpenSelect:
- result = CallComponentFunctionWithStorage( storage,
- params, (ComponentFunction)_SEOpen );
- break;
-
- // Close request
- case kComponentCloseSelect:
- result = CallComponentFunctionWithStorage( storage,
- params, (ComponentFunction)_SEClose );
- break;
-
- // Can Do request
- case kComponentCanDoSelect:
- result = CallComponentFunction( params, (ComponentFunction)_SECanDo );
- break;
-
- // Version request
- case kComponentVersionSelect:
- result = CallComponentFunction( params, (ComponentFunction)_SEVersion );
- break;
-
- // Target request
- case kComponentTargetSelect:
- result = CallComponentFunction( params, (ComponentFunction)_SETarget );
- break;
-
- // Register request not supported
- case kComponentRegisterSelect:
- // Unknown request
- default:
- result = paramErr;
- break;
- }
- }
- else // Was it one of our request codes?
- {
- switch ( params->what )
- {
- case kDoEffect:
- result = CallComponentFunction( params, (ComponentFunction)_SEDoEffect );
- break;
-
- case kWorksOnSelectionOnly:
- result = CallComponentFunction( params, (ComponentFunction)_SEWorksOnSelectionOnly );
- break;
-
- default:
- result = paramErr;
- break;
- }
- }
-
- return result;
- }
-
-
-
- /***
- * _SEOpen
- *
- ***/
-
- pascal ComponentResult _SEOpen( Handle storage, ComponentInstance self )
- {
- ComponentResult result = noErr;
- PrivateGlobals** globals;
-
- // Did we get our storage?
- if ( globals = (PrivateGlobals**)NewHandleClear( sizeof( PrivateGlobals ) ) )
- {
- // Keep a reference to self
- (*globals)->self = (Component)self;
-
- // Set storage ref
- SetComponentInstanceStorage( self, (Handle)globals );
- }
- else // NewHandleClear failed
- {
- result = MemError();
- }
-
- return result;
- }
-
-
-
- /***
- * _SEClose
- *
- ***/
-
- pascal ComponentResult _SEClose( Handle storage, ComponentInstance self )
- {
- ComponentResult result = noErr;
-
- // Do we have any clean up to do?
- if ( storage )
- {
- // Dispose globals
- DisposHandle( storage );
- }
-
- return result;
- }
-
-
-
- /***
- * _SECanDo
- *
- ***/
-
- pascal ComponentResult _SECanDo( short selector )
- {
- switch (selector)
- {
- // Component Manager request codes
- case kComponentOpenSelect:
- case kComponentCloseSelect:
- case kComponentCanDoSelect:
- case kComponentVersionSelect:
- case kComponentTargetSelect:
-
- // SE component request codes
- case kDoEffect:
- return TRUE;
-
- case kComponentRegisterSelect: // Register request not supported
- default: // Not a request code we recognize
- return FALSE;
- }
- }
-
-
-
- /***
- * _SEVersion
- *
- ***/
-
- pascal ComponentResult _SEVersion()
- {
- // Return the version info
- return kVersionNumber;
- }
-
-
-
- /***
- * _SETarget
- *
- ***/
-
- pascal ComponentResult _SETarget( ComponentInstance capturingComponent )
- {
- ComponentResult result = noErr;
-
- return result;
- }
-