【问题标题】:play multiple SpeakHere audio files播放多个 SpeakHere 音频文件
【发布时间】:2014-10-07 15:39:26
【问题描述】:

通过使用文件名录制多个sn-ps,我尝试SpeakHere中录制多个单独的短语音sn-ps,我想连续播放它们,间隔固定的间隔每个 sn-p 开始之间的时间。我希望 sn-ps 系列永远循环播放,或者直到用户停止播放。

我的问题是如何更改 SpeakHere 来做到这一点?

(我说“attempted”是因为我还不能在我的 Mac Mini iPhone 模拟器上运行 SpeakHereThat is the subject of another question 并且因为 another question on the subject of multiple files 也没有得到答复。 )

SpeakHereController.mm 中是以下用于播放录制文件的方法定义。注意最后的else 子句调用player->StartQueue(false)

- (IBAction)play:(id)sender
{
    if (player->IsRunning())
    {  [snip]
    }
    else
    {       
        OSStatus result = player->StartQueue(false);
        if (result == noErr)
            [[NSNotificationCenter defaultCenter] postNotificationName:@"playbackQueueResumed" object:self];
    }
}

以下是SpeakHereAQPlayer.mm的摘录

OSStatus AQPlayer::StartQueue(BOOL inResume)
{   
    // if we have a file but no queue, create one now
    if ((mQueue == NULL) && (mFilePath != NULL)) CreateQueueForFile(mFilePath);

    mIsDone = false;

    // if we are not resuming, we also should restart the file read index
    if (!inResume) {
        mCurrentPacket = 0;

        // prime the queue with some data before starting
        for (int i = 0; i < kNumberBuffers; ++i) {
            AQBufferCallback (this, mQueue, mBuffers[i]);           
        }
    }
    return AudioQueueStart(mQueue, NULL);
}

那么,playAQPlayer::StartQueue方法可以播放多个文件吗,如何强制执行间隔,如何重复循环?

我对方法'record`的代码改编如下,所以你可以看到多个文件是如何创建的。

- (IBAction)record:(id)sender
{
    if (recorder->IsRunning()) // If we are currently recording, stop and save the file.
    {
        [self stopRecord];
    }
    else // If we're not recording, start.
    {
        self.counter = self.counter + 1 ;   //Added *****
        btn_play.enabled = NO;  

        // Set the button's state to "stop"
        btn_record.title = @"Stop";

        // Start the recorder
        NSString *filename = [[NSString alloc] initWithFormat:@"recordedFile%d.caf",self.counter];
        // recorder->StartRecord(CFSTR("recordedFile.caf"));
        recorder->StartRecord((CFStringRef)filename);

        [self setFileDescriptionForFormat:recorder->DataFormat() withName:@"Recorded File"];

        // Hook the level meter up to the Audio Queue for the recorder
        [lvlMeter_in setAq: recorder->Queue()];
    }   
}

【问题讨论】:

    标签: ios voice-recording


    【解决方案1】:

    在与 iOS 上的本地“聚会”小组交谈后,我了解到解决我的问题的简单方法是避免使用 AudioQueues,而是使用来自 AVFoundation 的“更高级别”AVAudioRecorderAVAudioPlayer .

    我还发现了如何使用我的 Mac Mini 在模拟器上部分测试我的应用程序:通过将带有 USB 的 Olympus 录音机插入我的 Mini 作为输入“语音”。这可以作为 iSight 的替代品,它不会在 Mini 上产生输入音频。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-25
      • 1970-01-01
      相关资源
      最近更新 更多