Audio Unit Graph pause and repeating

前端 未结 2 633
悲&欢浪女
悲&欢浪女 2021-01-16 06:57

I\'ve been trying to implement Audio Unit Graph using Apple provided code: IphoneMixerEQGraphTest. So far I have encountered two problems:

1.) I can\'t find any way

相关标签:
2条回答
  • 2021-01-16 07:20

    NO REPEATING FUNCTIONALITY

    So far I have found a way to deal with audio stopping - although it's not pretty:

    I load same audio file in AVAudioPlayer - and get from it sound file duration. Then, using

    performSelector:withObject:afterDelay: 
    

    I can stop AUGraph when sound file should end playing.

    PAUSE AUGRAPH FUNCTIONALITY

    It turns out that implementing pause is pretty simple. While AUGraph data source is not changed - by calling

    [graphController startAUGraph]; or [graphController stopAUGraph];
    

    will only pause/resume playing.

    Although this affects performSelector timer. So, to use both - pause/no-repeating possibilities, one should use NSTimer - when AUGraph paused - then timer pauses too. When AUGraph resumed - timer resumes counting, and when it reaches provided sound file duration - it stops playing.

    Bottom line

    By using duration value from AVAudioPlayer (or any other player which provides duration) - it is possible to implement AUGraph sound player with play/pause/stop (no-repeat/repeat)/next song/previous song/ functions + EQUALIZER.

    0 讨论(0)
  • 2021-01-16 07:45

    AVAudioPlayer is a huge class, You can easily get duration from:

    Float64 fileDuration = PrepareFileAU (fileAU, fileFormat, audioFile);
    

    see ADC sample at:

    http://developer.apple.com/library/mac/#samplecode/PlayFile/Introduction/Intro.html

    avoiding including other frameworks.

    0 讨论(0)
提交回复
热议问题