0

我使用 Cocos2d。这个 CocosDention 没有我需要的属性。也许有人知道在ios当前阶段使用什么方式记录和保存所有声音。DJ 应用程序怎么样 - 他们将音乐从不同的片段中保存下来并将它们放在一起。

比如在游戏中播放背景音乐。当玩家跳跃时,cocosdenchion 会播放跳跃的声音。我可以实时创建结合背景音乐和其他音乐效果的新曲目并保存吗?

我如何理解 AVAudioRecorder 仅用于录制麦克风设备。我可以为此使用什么——AudioToolbox?开放式?核心音频?其他框架?

在我想使用 FMOD 之前,但是有 500 美元的许可证,我不确定我的项目会给我一些比赛资金。在此我找到免费的方法或框架。谢谢。

4

1 回答 1

1

I found some solution. I use BASS iOS library. one minus – it's paid. And second minus – it's written on C++. And not some example for iOS. But have good help on the forum.

    //BASS initialisation. use BASS_free for free resources
    BASS_Init(-1,44100,0,NULL,NULL);

    //create mixer
    BASS_GetInfo(&info); // get output device info. needet to get freq
    mixer=BASS_Mixer_StreamCreate(info.freq, 2, 0); // create a stereo mixer with the same sample rate
NSString *shortSound = [[NSBundle mainBundle] pathForResource:@"piano2" ofType:@"wav"];
    //create channel
    chan2 = BASS_StreamCreateFile(FALSE, [shortSound cStringUsingEncoding:NSUTF8StringEncoding], 0, 0, BASS_STREAM_DECODE);

    //create channel from file use absolute path url
    NSString *soundFileName = [[NSBundle mainBundle] pathForResource:@"ff13" ofType:@"mp3"];
    chan = BASS_StreamCreateFile(FALSE, [soundFileName cStringUsingEncoding:NSUTF8StringEncoding], 0, 0, BASS_STREAM_DECODE|BASS_SAMPLE_FLOAT|BASS_SAMPLE_LOOP);

    //add channel into mixer
    BASS_Mixer_StreamAddChannel(mixer, chan, 0);

    //point the dirrectory and file name for our new file saved mixer data
    NSString *documentDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *filename = [documentDir stringByAppendingString:@"/file.mp3"];

    //start encode mixer to file when view did load. With parameters for encode.
    BASS_Encode_StartCAFile(mixer, 'm4af', 'alac', 0, 0, [filename cStringUsingEncoding:NSUTF8StringEncoding]);

    //mixer add any delay for play added channel. Fix it using this option
    BASS_ChannelSetAttribute(mixer, BASS_ATTRIB_NOBUFFER, 1);

    BASS_ChannelPlay(mixer, 0); // start mixer

Here used mixer for record all sounds and microphone voice.

于 2012-09-15T16:43:24.467 回答