• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[long] Capturing sound to a QT Movie
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[long] Capturing sound to a QT Movie


  • Subject: [long] Capturing sound to a QT Movie
  • From: Ken Wieschhoff <email@hidden>
  • Date: Fri, 22 Feb 2002 14:57:31 -0500

I'm trying to capture audio from a Griffin iMic into a Sound Track in a QuickTime Movie from the CaptureIOProcs. I'm having difficulty trying to add the samples to the track as I'm not sure if their format is correct.

Code follows, but is there a built-in way to do this already?

*************

:
:

mSoundDesc = (SoundDescriptionHandle) NewHandleClear(sizeof(SoundDescription));
AudioStreamBasicDescription *streamDesc =
GetAudioParameters(/*AudioDeviceID*/ inAudioDevice);


if (mSoundDesc && streamDesc)
{
// Populate the sound description handle
(**mSoundDesc).descSize = sizeof(SoundDescription);

/* sound format ('lpcm') */
(**mSoundDesc).dataFormat = streamDesc->mFormatID;

(**mSoundDesc).dataRefIndex = 1;

/* number of channels of sound */
(**mSoundDesc).numChannels = streamDesc->mChannelsPerFrame;

/* number of bits per sample */
(**mSoundDesc).sampleSize = streamDesc->mBitsPerChannel *
streamDesc->mChannelsPerFrame * streamDesc->mFramesPerPacket *
streamDesc->mBytesPerFrame * streamDesc->mBytesPerPacket * 8;

/* sample rate sound is captured at */
(**mSoundDesc).sampleRate = X2Fix(streamDesc->mSampleRate);

}



*************

void MovieMaker::StartRecordingSoundTrack()
{
OSErr err = noErr;

fAudioTrack = NewMovieTrack (fMovie, 0, 0, kFullVolume);
CheckError (GetMoviesError(), "NewMovieTrack" );

fAudioMedia = NewTrackMedia ( fAudioTrack, SoundMediaType,
FixRound ((**mSoundDesc).sampleRate),
nil, 0);
CheckError (GetMoviesError(), "NewTrackMedia" );

err = BeginMediaEdits (fAudioMedia);
CheckError( err, "BeginMediaEdits" );
}


*************

void MovieMaker::AddSampleToAudioTrack(void *inputBuffer, UInt32 inputBufferSize)
{
Handle audioBuffer = NULL;
if ( inputBufferSize) {


audioBuffer = NewHandle(inputBufferSize);
BlockMove(inputBuffer, *audioBuffer, inputBufferSize);

OSErr err = AddMediaSample( fAudioMedia,
audioBuffer,
0, /* offset in data */
inputBufferSize, /* Data Size */
1, /* duration of each sound sample */

/* Sound Description */
(SampleDescriptionHandle) mSoundDesc,

1, /* number Of Samples */
0, /* self-contained samples */
nil);

CheckError( err, "AddMediaSample" );
}
}

*************

void MovieMaker::EndRecordingSoundTrack()
{
OSErr err = noErr;

err = EndMediaEdits (fAudioMedia);
CheckError( err, "EndMediaEdits" );

err = InsertMediaIntoTrack (fAudioTrack,
0, /* track start time */
0, /* media start time */
GetMediaDuration (fAudioMedia), kFix1);
CheckError( err, "InsertMediaIntoTrack" );
}

*************

Finally the routine which sends data:

OSStatus CAudioClass::CaptureIOProc(AudioDeviceID inDevice,
const AudioTimeStamp* inNow,
const AudioBufferList* inInputData,
const AudioTimeStamp* inInputTime,
AudioBufferList* outOutputData,
const AudioTimeStamp* inOutputTime)
{
if(inInputData) {
// send data to movie maker when implemented...
gMovieMaker->AddSampleToAudioTrack(inInputData->mBuffers[0].mData,
inInputData->mBuffers[0].mDataByteSize);

:
:




When I open the movie in QuickTime player to look at the movie attributes, the "Data Rate" is listed as '< 1byte/sec' and the "Data Size" has no size associated with it all.

Can anyone help?

->Ken



--
- --
Ken Wieschhoff
(770)813-0231
***************************
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: [long] Capturing sound to a QT Movie
      • From: Jeff Moore <email@hidden>
References: 
 >Re: Here's a fun potential CoreMIDI bug (From: Doug Wyatt <email@hidden>)
 >Sound playback under Carbon (From: Martin Hairer <email@hidden>)

  • Prev by Date: Re: Questions on data in MIDIPackets
  • Next by Date: Re: [long] Capturing sound to a QT Movie
  • Previous by thread: Sound playback under Carbon
  • Next by thread: Re: [long] Capturing sound to a QT Movie
  • Index(es):
    • Date
    • Thread