标签: ezaudio

有人可以解释这段代码如何使用Accelerate Framework将音量转换为分贝?

我正在使用EZAudio构建iOS应用程序.它的委托返回一个float**缓冲区,其中包含指示检测到的卷的浮点值.这个委托被不断调用,它的工作是一个不同的线程.

我想要做的是从EZAudio获取浮点值并将其转换为分贝.


EZAudioDelegate

这是我用于获取麦克风数据的简化EZAudio代表:

- (void)microphone:(EZMicrophone *)microphone hasAudioReceived:(float **)buffer withBufferSize:(UInt32)bufferSize withNumberOfChannels:(UInt32)numberOfChannels {
    /*
     *  Returns a float array called buffer that contains the stereo signal data
     *  buffer[0] is the left audio channel
     *  buffer[1] is the right audio channel
     */

    // Using a separate audio thread to not block the main UI thread
    dispatch_async(dispatch_get_main_queue(), ^{

        float decibels = [self getDecibelsFromVolume:buffer withBufferSize:bufferSize];

        NSLog(@"Decibels: %f", decibels);

    });

}
Run Code Online (Sandbox Code Playgroud)

问题

问题是,从以下链接实施解决方案后,我不明白它是如何工作的.如果有人能解释它如何将音量转换为分贝,我将非常感激


代码

该解决方案使用 …

objective-c ios accelerate-framework ezaudio

12
推荐指数
1
解决办法
2039
查看次数

当EZRecorder在iPhone X上调用ExtAudioFileWrite时崩溃

我有一个示例应用程序,它使用AudioKit来录制音频并显示该音频数据的波形.此示例应用程序有两个viewControllers,其中根vc是一个空白页面,其中包含一个按钮,用户可以将该用户带到录音页面.

出于某种原因,仅在iPhone X(iOS 11.4.1)上,在录制音频时,如果我点击导航栏上的后退按钮(左上角),然后尝试再次录制,应用程序将崩溃.

特别是当录音机的方法appendDataFromBufferList: withBufferSize:调用时,应用程序似乎崩溃ExtAudioFileWrite(self.info->extAudioFileRef, bufferSize, bufferList).控制台中打印的错误消息是:

testAudioCrash(1312,0x16e203000)malloc:***对象0x109803a00的错误:释放对象的校验和不正确 - 对象可能在被释放后被修改. ***在malloc_error_break中设置断点以进行调试

我经历过僵尸剖析,泄漏剖析,逐步完成逻辑和堆栈,但我似乎无法弄清楚为什么会发生这种情况.

下面我提供了测试应用程序的代码以及堆栈和控制台输出的屏幕截图.任何帮助弄清楚为什么会崩溃将非常感激.不幸的是,这次崩溃也不是100%可重复的事实让我对它更加模糊.

代码注释如下:.h文件中没有自定义代码,所以我没有提供.每个视图控制器都有xib文件,其中包含UI组件.它们非常简单,所以我没有提供有关这些的信息,虽然我没有任何问题提供任何信息,任何人都要求.如果有人认为有必要,我也可以压缩项目并分享.

Repro步骤:1)启动应用2)点击录制音频按钮3)点击录制按钮4)点击导航栏上的按钮

5)重复步骤2-4直到发生崩溃

AppDelegate.m代码:

#import "AppDelegate.h"
#import "testViewController.h"

@interface AppDelegate ()
@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    testViewController* rootVC = [[testViewController alloc] initWithNibName: @"testViewController" bundle: NSBundle.mainBundle];
    UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController: rootVC];
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.rootViewController = nav;
    [self.window makeKeyAndVisible];
    return YES;
}


- (void)applicationWillResignActive:(UIApplication …
Run Code Online (Sandbox Code Playgroud)

ios ezaudio audiokit iphone-x ios11.4

12
推荐指数
0
解决办法
174
查看次数

EZAudio CocoaPods模块导入错误

当使用CocoaPods将EZAudio添加到我的swift项目时,我收到一个编译器错误:
Could not build Objective-C module 'EZAudio'

我的Podfile是这样的:

platform :ios, '9'
use_frameworks!

pod 'CorePlot'
pod 'SWRevealViewController'
pod 'EZAudio'
Run Code Online (Sandbox Code Playgroud)

我将它添加到swift文件中,如下所示:

import EZAudio
Run Code Online (Sandbox Code Playgroud)

我没有使用桥接头.有没有人知道为什么会这样?

xcode ios cocoapods swift ezaudio

7
推荐指数
1
解决办法
1294
查看次数

如何修剪用EZAudioRecorder录制的音频?

我想修剪用EZAudioRecorder录制的音频.

我正在编写此代码来修剪音频.这对于使用AVAudioRecorder录制的音频工作正常但是它会触发EZAudioRecorder的错误阻止,错误无法打开文件.

-(BOOL)trimAudiofile{
   float audioStartTime=1.0;
   float audioEndTime=2.0;//define end time of audio
   NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
   [dateFormatter setDateFormat:@"yyyy-MM-dd_HH-mm-ss"];
   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
   NSString *libraryCachesDirectory = [paths objectAtIndex:0];
   libraryCachesDirectory = [libraryCachesDirectory stringByAppendingPathComponent:@"Caches"];
   NSString *OutputFilePath = [libraryCachesDirectory stringByAppendingFormat:@"/output_%@.m4a", [dateFormatter stringFromDate:[NSDate date]]];
   NSURL *audioFileOutput = [NSURL fileURLWithPath:OutputFilePath];
   NSURL *audioFileInput=[self testFilePathURL];//<Path of orignal audio file>

   if (!audioFileInput || !audioFileOutput)
   {
       return NO;
   }

  [[NSFileManager defaultManager] removeItemAtURL:audioFileOutput error:NULL];
  AVAsset *asset = [AVAsset assetWithURL:audioFileInput];

  AVAssetExportSession …
Run Code Online (Sandbox Code Playgroud)

objective-c avfoundation avaudiorecorder ios ezaudio

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

iOS:是否可以同时从多个麦克风录音

所有最近的 iPhone 都有 2 个以上的麦克风。是否可以同时从所有麦克风录音?如果可能,最好的 iOS 音频库是什么(AudioKit、EzAudio、AudioUnits、CoreAudio)?AudioKit 和 EzAudio 中没有提到这个功能。

core-audio audiounit ios ezaudio audiokit

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

如何在 Swift 中用 Float 填充 AudioBuffer

我制作了一个使用 EZAudio 库的应用程序,它必须从麦克风获取数据并将其存储在变量中(我已经这样做了):

    func microphone(microphone: EZMicrophone!, 
                    hasAudioReceived buffer: UnsafeMutablePointer<UnsafeMutablePointer<Float>>, 
                    withBufferSize bufferSize: UInt32, 
                    withNumberOfChannels numberOfChannels: UInt32) 
   {
       let new = (buffer[0].memory)
       audioStack.append(new)
   }
Run Code Online (Sandbox Code Playgroud)

如您所见,我使用 EZMicrophoneDelegate 和上面的 func 从麦克风获取缓冲区数据。

未来的想法是通过 WebSocket 发送值并立即播放。

我想使用 EZOuput 和 EZOuputDataSource`s 方法播放该数组:

    func output(output: EZOutput!, 
                shouldFillAudioBufferList audioBufferList: UnsafeMutablePointer<AudioBufferList>, 
                withNumberOfFrames frames: UInt32, 
                timestamp: UnsafePointer<AudioTimeStamp>) -> OSStatus 
    {
         if audioStack.count > 0 {
         let data = audioBufferList.memory.mBuffers.mData
         // "data" = is pointer to mData, that i want to fill with float
         // and I have do it here

         return …
Run Code Online (Sandbox Code Playgroud)

objective-c audioqueueservices swift ezaudio

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