#include "Glue.h"
#include "Empty.h"


pascal OSErr effect(ModParamsPtr modInfo, GluePtr glue, ModSettingsHandle *prefs)
{
	StringHandle	progressString;
	short			timeToCallProgress;
	OSErr			result = kModCancel;
	
	// effect can receive in prefs either nil or a valid handle. If the effect does
	// not have any settings, prefs will be nil and we wont do anything with it.
	
	UseResFile(modInfo->refNum);
	
	
	// read the settings.
	
	DisposHandle((Handle)*prefs);
	*prefs = 0L;
	
	
	// lets load the string well show in the progress window.
	
	progressString = (StringHandle)Get1Resource('STR ', 128);
	if (progressString == 0L)
		return kModCouldntLoadMyRes;
	
	
	// set up the progress window.
	
	(*glue->ModSetupProgress)(modInfo, &timeToCallProgress, progressString);
	ReleaseResource((Handle)progressString);
	
	
	// if the selection is empty, select the whole channels.
	
	if (modInfo->selSt == modInfo->selEnd)
	{
		modInfo->selSt = 0L;
		(*glue->ModMaxRelChSize)(&modInfo, &modInfo->selEnd);
	}
	
	
	// process the sound from modInfo->selSt to modInfo->selEnd,
	// from channel (*modInfo->hands)[ modInfo->selSt-1 ].chan
	// to channel (*modInfo->hands)[ modInfo->selEnd-1 ].chan (inclusive).
	
	
	(*glue->ModCloseProgress)();
	
	return result;
}