OSErr ExportWAVEtoAIFF (Movie theMovie, FSSpec *theFile)
{
ComponentInstance myComponent = NULL;
SoundDescriptionHandle myDesc = NULL;
ComponentResult myErr = badComponentType;
// open a movie export component
myComponent = GetAIFFMovieExportComponent();
if (myComponent == NULL)
goto bail;
// create and fill in a sound description
myDesc = (SoundDescriptionHandle)NewHandleClear(sizeof(SoundDescription));
if (myDesc == NULL)
{
myErr = MemError();
goto bail;
}
// specify the export format
(**myDesc).descSize = sizeof(SoundDescription);
(**myDesc).sampleSize = 16;
(**myDesc).sampleRate = rate22050hz;
(**myDesc).dataFormat = kQUALCOMMCompression;
(**myDesc).dataRefIndex = 1;
(**myDesc).numChannels = 1;
// tell the export component to use the
// specified audio characteristics
myErr = MovieExportSetSampleDescription(myComponent,
(SampleDescriptionHandle)myDesc, SoundMediaType);
if (myErr != noErr)
goto bail;
// export the movie into a file
myErr = ConvertMovieToFile(
theMovie, // the movie to convert
NULL, // the first track
theFile, // the output file
kQTFileTypeAIFF, // the output file type
sigMoviePlayer, // the output file creator
smSystemScript, // the script
NULL, // resource ID
0L, // no flags
myComponent); // the export component
bail:
// dispose of any storage we allocated
if (myComponent != NULL)
CloseComponent(myComponent);
if (myDesc != NULL)
DisposeHandle((Handle)myDesc);
return((OSErr)myErr);
}
ComponentInstance GetAIFFMovieExportComponent()
{
ComponentDescription cd;
Component c = 0;
ComponentInstance ci=0;
cd.componentType = MovieExportType;
cd.componentSubType = kQTFileTypeAIFF;
cd.componentManufacturer = SoundMediaType;
cd.componentFlags = 0;
cd.componentFlagsMask = 0;
c = FindNextComponent( c, &cd );
if (c != nil)
{
ci = OpenComponent(c);
}
return ci;
}
[Sep 05 2000]
|