相关疑难解决方法(0)

iPhone SDK:AVAudioRecorder计量 - 如何将peakPowerForChannel从分贝变为百分比?

iPhone SDK中的AVAudioRecorder可用于获取通道的峰值功率和平均功率,单位为分贝.范围介于0db到160db之间.用于将其转换为0-10之间或可用于音频电平表的类似值的计算是什么?

iphone core-audio avaudiorecorder decibel

8
推荐指数
2
解决办法
8125
查看次数

如何获得 Mac 音频电平?

目前,我的代码可以成功返回用户可以使用音量键设置的系统音频值。

但是,我想要的是扬声器正在播放的音频的值。因此,如果用户正在观看 Netflix 并且角色开始尖叫,则返回的值将高于角色在窃窃私语时的值。

我现在拥有的代码:

+ (AudioDeviceID)defaultOutputDeviceID {
    OSStatus status = noErr;

    AudioDeviceID outputDeviceID = kAudioObjectUnknown;

    AudioObjectPropertyAddress propertyAOPA;
    propertyAOPA.mElement = kAudioObjectPropertyElementMaster;
    propertyAOPA.mScope = kAudioObjectPropertyScopeGlobal;
    propertyAOPA.mSelector = kAudioHardwarePropertyDefaultSystemOutputDevice;

    UInt32 propertySize = sizeof(outputDeviceID);

    if (!AudioHardwareServiceHasProperty(kAudioObjectSystemObject, &propertyAOPA)) {
        NSLog(@"Cannot find default output device!");
        return outputDeviceID;
    }

    status = AudioHardwareServiceGetPropertyData(kAudioObjectSystemObject, &propertyAOPA, 0, NULL, &propertySize, &outputDeviceID);

    if(status) {
        NSLog(@"Cannot find default output device!");
    }

    return outputDeviceID;
}

+ (float)volume {
    OSStatus status = noErr;

    AudioDeviceID outputDeviceID = [[self class] defaultOutputDeviceID];

    if (outputDeviceID == kAudioObjectUnknown) { …
Run Code Online (Sandbox Code Playgroud)

macos objective-c core-audio audiotoolbox

5
推荐指数
1
解决办法
406
查看次数