Mac 应用程序录音时有噪音

发布于 2024-12-05 20:28:23 字数 1205 浏览 1 评论 0原文

我正在使用 QTKit 进行录制和播放,但是当我录制生成的文件时,有很多噪音(气压)。

我正在使用

QTCaptureDevice *audioDevice = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeSound];

和捕获会话

captureSession = [[QTCaptureSession alloc] init];

以及这些

QTCaptureDecompressedAudioOutput    *captureAudioDataOutput;

    AudioUnit                   effectAudioUnit;
    ExtAudioFileRef             extAudioFile;

    AudioStreamBasicDescription currentInputASBD;
    AudioBufferList             *currentInputAudioBufferList;

还有这些行(可能是噪音的原因在这里)

/* Create an effect audio unit to add an effect to the audio before it is written to a file. */
    OSStatus err = noErr;

    AudioComponentDescription effectAudioUnitComponentDescription;
    effectAudioUnitComponentDescription.componentType= kAudioUnitType_Effect;
    effectAudioUnitComponentDescription.componentSubType = 0;
    effectAudioUnitComponentDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
    effectAudioUnitComponentDescription.componentFlags = 0;
    effectAudioUnitComponentDescription.componentFlagsMask = 0;

请有人帮助我。

I am using QTKit for recording and playing, but when i am recording the resultant file having lot of noise(air pressure).

I am using

QTCaptureDevice *audioDevice = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeSound];

and capture session

captureSession = [[QTCaptureSession alloc] init];

And these

QTCaptureDecompressedAudioOutput    *captureAudioDataOutput;

    AudioUnit                   effectAudioUnit;
    ExtAudioFileRef             extAudioFile;

    AudioStreamBasicDescription currentInputASBD;
    AudioBufferList             *currentInputAudioBufferList;

Also these lines (may be the reason of noise is here)

/* Create an effect audio unit to add an effect to the audio before it is written to a file. */
    OSStatus err = noErr;

    AudioComponentDescription effectAudioUnitComponentDescription;
    effectAudioUnitComponentDescription.componentType= kAudioUnitType_Effect;
    effectAudioUnitComponentDescription.componentSubType = 0;
    effectAudioUnitComponentDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
    effectAudioUnitComponentDescription.componentFlags = 0;
    effectAudioUnitComponentDescription.componentFlagsMask = 0;

Please some one help me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

匿名。 2024-12-12 20:28:23

如果设置正确,您应该不会听到任何噪音。基本上,您根本不需要设置音频设备。您需要获得一个并使用它。可以从 QTCaptureDevice 类获取系统中可用音频设备的列表:

[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeSound]

选择您需要的设备并获取其音频输入:

[STCaptureDeviceInput captureDeviceInputWithDevice:audioDevice type:STCaptureDeviceAudio]

在录制之前将输入设置为捕获会话:

[_captureSession addInput:captureAudioDeviceInput error:&error]

它应该可以正常工作。

You should not be getting any noise if you set it up correctly. Basically, you do not need to setup the audio device at all. You need to get one and use it. The list if available audio devices in your system can be obtained from the QTCaptureDevice class:

[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeSound]

Select the one you need and get the audio input for it:

[STCaptureDeviceInput captureDeviceInputWithDevice:audioDevice type:STCaptureDeviceAudio]

Set the input to the capture session before recording:

[_captureSession addInput:captureAudioDeviceInput error:&error]

It should just work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文