void ofxQtAudioRecorder::addAudioSamples( float * audioBuffer, int sampleCount){
	
	if(audioMedia != NULL)
	{
		
		printf("adding %i samples\n", sampleCount);
				
		OSErr err = BeginMediaEdits(audioMedia);
		checkErr(0x0201);
		
		int bytesPerSample = sizeof(Float32);
		
		//printf("bytes %i\n", bytesPerSample);
		
		AddMediaSample2(audioMedia,   // insert into audio media
						(UInt8*)audioBuffer, // size
						sampleCount * bytesPerSample, // number of bytes of audio data
						kSoundSampleDuration,  // normal decode duration
						0,            // no display offset (won't work anyway)
						(SampleDescriptionHandle) soundDesc,
						sampleCount / numChannels, // number of samples 
						0,            // no flags
						NULL);        // not interested in decode time
		
		// end media editing and add media to the track
		EndMediaEdits(audioMedia);
		checkErr(0x0202);
		
		TimeValue trackStart = (TimeValue)(0); 
		InsertMediaIntoTrack(audioTrack, trackStart, 0, GetMediaDuration(audioMedia), fixed1);
		checkErr(0x0203);
		
		//printf("added audio media\n");
	}
}
Пример #2
0
int encode_audio(soundmovie_buffer_t *buffer)
{
    if (!audio_ready) {
        return 0;
    }

    OSStatus err = AddMediaSample2 (audioMedia,
                                    (const UInt8 *)buffer->buffer,
                                    buffer->used * sizeof(SWORD),
                                    1,
                                    0,
                                    (SampleDescriptionHandle)soundDescriptionHandle,
                                    buffer->used,
                                    0,
                                    NULL);
    if (err != noErr) {
        log_debug("quicktime_audio: error adding samples!");
    }
    return 0;
}