iPhone 版 Soundtouch

发布于 2024-08-20 23:11:43 字数 202 浏览 4 评论 0原文

有人能够制作吗 http://www.surina.net/soundtouch/ 适用于 iPhone?

简单的 Xcode 演示会很有帮助。

我只想通过一些音高操纵来播放音效。

谢谢 克里斯

Has someone been able to make
http://www.surina.net/soundtouch/
work for iPhone?

Simple Xcode Demo would be helpful.

I'd just like to play a soundeffect with some pitch manipulation.

thx
chris

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

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

发布评论

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

评论(1

墨离汐 2024-08-27 23:11:43

使用 SoundTouch 实现音频效果的最佳方法是同时使用 SoundStretch

您可以从这里下载两者的源代码 http://www.surina.net/soundtouch/源代码.html

SoundStretch 是执行 SoundTouch 的命令行程序
WAV 音频文件的库效果。该程序是源代码
如何使用 SoundTouch 库例程处理声音的示例
在其他程序中,但它可以用作独立音频
以及处理工具。

SoundStretch 功能:

  • 阅读并阅读写入 .wav 音频文件
  • 允许非常宽的参数调整范围:
  • 节奏和节奏播放速率可调范围-95% .. +5000%
  • 音高(调)可在 -60 .. +60 半音(+- 5 八度)范围内调节。
  • 每秒节拍数 (BPM) 检测,可以调整节奏以匹配所需的 BPM 速率。
  • 提供完整源代码
  • 命令行界面允许使用SoundStretch实用程序以批处理模式处理.wav音频文件
  • 支持通过标准输入/输出管道处理.wav音频流
  • SoundStretch 使用 SoundTouch 库例程进行音频处理。

使用示例:

NSArray *effects = [NSArray arrayWithObjects:@"-rate=-22", nil];
NSURL *audio = [self base:input output:output effects:effects];

其中 base:output:effects 定义为:

- (NSURL *)base:(NSURL *)input output:(NSURL *)output effects:(NSArray *)effects{
    int _argc = 3 + (int)[effects count];
    
    const char *_argv[]={"createWavWithEffect",[[input path] UTF8String], [[output path] UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String]};
    
    for (int i=0; i<[effects count]; i++) {
        _argv[i+3] = [effects[i] UTF8String];
    }
    createWavWithEffect(_argc, _argv);

    // IMPORTANT! Check the file size, maybe you will need to set by yourself

    return output;
}

如果您不想自己编译 SoundTouch,我已经与编译的库共享了 GitHub 存储库对于 armv7armv7sarm64i386x86_64

https://github.com/enrimr/soundtouch-ios-library

如果您想通过以下方式使用 SoundTouch如果您自己不使用 SoundStretch,则必须在 Xcode 项目中添加 SoundTouch 目录(其中包括 libSoundTouch.a 和带有标头的目录)。

对于 SWIFT 项目:

使用 SWIFT 编程时,您无法导入 .h,因此您需要创建一个名为 -Bridging-Header-File 的 .h 文件.h
然后在您的项目构建设置中引用它(在“Swift Compiler”下查找“Objective C Bridging Header”):

$(SRCROOT)/<Your-Project-Name>-Bridging-Header.h

现在您必须能够使用 SoundTouch 类。

对于 Objective-C 项目:

包含以下行

#include "SoundTouch.h" 

在控制器文件中

createWavWithEffect 的实现:

int createWavWithEffect(const int nParams, const char * const paramStr[])
{
    WavInFile *inFile;
    WavOutFile *outFile;
    RunParameters *params;
    SoundTouch soundTouch;

    fprintf(stderr, _helloText, SoundTouch::getVersionString());

    try 
    {
        // Parse command line parameters
        params = new RunParameters(nParams, paramStr);

        // Open input & output files
        openFiles(&inFile, &outFile, params);

        if (params->detectBPM == TRUE)
        {
            // detect sound BPM (and adjust processing parameters
            //  accordingly if necessary)
            detectBPM(inFile, params);
        }

        // Setup the 'SoundTouch' object for processing the sound
        setup(&soundTouch, inFile, params);

        // clock_t cs = clock();    // for benchmarking processing duration
        // Process the sound
        process(&soundTouch, inFile, outFile);
        // clock_t ce = clock();    // for benchmarking processing duration
        // printf("duration: %lf\n", (double)(ce-cs)/CLOCKS_PER_SEC);

        // Close WAV file handles & dispose of the objects
        delete inFile;
        delete outFile;
        delete params;

        fprintf(stderr, "Done!\n");
    } 
    catch (const runtime_error &e) 
    {
        // An exception occurred during processing, display an error message
        fprintf(stderr, "%s\n", e.what());
        return -1;
    }

    return 0;
}

The best way to implement audio effects using SoundTouch is using also SoundStretch.

You can download the source code of both from here http://www.surina.net/soundtouch/sourcecode.html

SoundStretch is a command-line program that performs SoundTouch
library effects on WAV audio files. The program is a source code
example how SoundTouch library routines can be used to process sound
in other programs, but it can be used as a stand-alone audio
processing tool as well.

SoundStretch features:

  • Reads & writes .wav audio files
  • Allows very broad parameter adjustment ranges:
  • Tempo & Playback Rate adjustable in range -95% .. +5000%
  • The sound Pitch (key) adjustable in range -60 .. +60 semitones (+- 5 octaves).
  • Beats-Per-Second (BPM) detection that can adjust tempo to match with the desired BPM rate.
  • Full source codes available
  • Command-line interface allows using the SoundStretch utility for processing .wav audio files in batch mode
  • Supports processing .wav audio streams through standard input/output pipes
  • SoundStretch uses the SoundTouch library routines for the audio procesing.

Example of use:

NSArray *effects = [NSArray arrayWithObjects:@"-rate=-22", nil];
NSURL *audio = [self base:input output:output effects:effects];

Where base:output:effects is defined as:

- (NSURL *)base:(NSURL *)input output:(NSURL *)output effects:(NSArray *)effects{
    int _argc = 3 + (int)[effects count];
    
    const char *_argv[]={"createWavWithEffect",[[input path] UTF8String], [[output path] UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String]};
    
    for (int i=0; i<[effects count]; i++) {
        _argv[i+3] = [effects[i] UTF8String];
    }
    createWavWithEffect(_argc, _argv);

    // IMPORTANT! Check the file size, maybe you will need to set by yourself

    return output;
}

If you don't want to compile by yourself SoundTouch, I have shared a GitHub repository with that libraries compiled for armv7, armv7s, arm64, i386 and x86_64

https://github.com/enrimr/soundtouch-ios-library

And if you want to use SoundTouch by yourself without using SoundStretch, you have to add SoundTouch directory (which includes libSoundTouch.a and the directory with headers) in your Xcode project.

For SWIFT projects:

Programming with SWIFT you can't import a .h so you will need to create a .h file named <Your-Project-Name>-Bridging-Header-File.h
Then reference it in your projects build settings (under "Swift Compiler" look for "Objective C Bridging Header") with:

$(SRCROOT)/<Your-Project-Name>-Bridging-Header.h

And now you must be able to use SoundTouch class.

For Objective-C projects:

Include the following line

#include "SoundTouch.h" 

in your controller file.

Implementation of createWavWithEffect:

int createWavWithEffect(const int nParams, const char * const paramStr[])
{
    WavInFile *inFile;
    WavOutFile *outFile;
    RunParameters *params;
    SoundTouch soundTouch;

    fprintf(stderr, _helloText, SoundTouch::getVersionString());

    try 
    {
        // Parse command line parameters
        params = new RunParameters(nParams, paramStr);

        // Open input & output files
        openFiles(&inFile, &outFile, params);

        if (params->detectBPM == TRUE)
        {
            // detect sound BPM (and adjust processing parameters
            //  accordingly if necessary)
            detectBPM(inFile, params);
        }

        // Setup the 'SoundTouch' object for processing the sound
        setup(&soundTouch, inFile, params);

        // clock_t cs = clock();    // for benchmarking processing duration
        // Process the sound
        process(&soundTouch, inFile, outFile);
        // clock_t ce = clock();    // for benchmarking processing duration
        // printf("duration: %lf\n", (double)(ce-cs)/CLOCKS_PER_SEC);

        // Close WAV file handles & dispose of the objects
        delete inFile;
        delete outFile;
        delete params;

        fprintf(stderr, "Done!\n");
    } 
    catch (const runtime_error &e) 
    {
        // An exception occurred during processing, display an error message
        fprintf(stderr, "%s\n", e.what());
        return -1;
    }

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