Preset Metronome Recording Using Remote I / O

I managed to create the exact functionality that I wanted to use avaudioplayer and avaudiorecorder, but, of course, problems with the delay. Therefore, after reading almost every article on the Internet and looking at the stacks of sample code, I'm still not sure how to achieve the following:

  • The user selects a 2 bar sample record (4 bits per bar) with a preview / calculation
  • User clicks record
  • The metronome began, which counts in 4 beats (emphasis in the first measure)
  • The application automatically starts recording at the beginning of the next line.
  • The application automatically disables recording at the end of the 3rd bar (2 bars + preview clip)
  • Then the user can play back his recording or delete it and start over.

So, with avaudioplayer and avaudiorecorder, I just created a โ€œcafโ€ using the courage with the metronome set with the correct doubling (bpm is installed for the application). Then I configure and play avaudioplayer and use the audiodidfinishsuccessately delegate method, performed some logic to start the recorder, restart the player, save the loop counter, etc., to disable recording and audio.

As I mentioned, I was pretty much able to achieve the user experience that I am experiencing, but lag problems are unacceptable.

I work with audio devices and remote IO and set up a project with playback callback and recorder callback, etc., but now I am faced with the problem of working on how to make this work based on the description above. I am trying to work out the following things for beginners:

  • If I create a file from 1 bit caf, how can I use audio devices and remote I / O to play x number of beats and then stop?
  • How can I pre-show and start recording callback after 4 beats.

Can someone give me some ideas or point me in the right direction. As I mentioned, I have already done a number of studies, including buying a basic audiobook, reading each article at atastypixel.com, timbolstad.com, etc. And trawling through apple papers.

Thanks in advance for your help.

+4
source share
1 answer

I am running NSTimer. Use BPM (Beats per Minute) / 60 based values. Therefore, if the user wants to write a file with two bars with an account, he can do something like this:

//timer interval=100BPM/60secs per minute timerInterval=100/60; metroTimer = [NSTimer scheduledTimerWithTimeInterval:timerinterval target:self selector:@selector(blinkMetroLight) userInfo:nil repeats:YES]; - (void)blinkMetroLight { if(beatNumber == 0) { beatNumber = 1; } else if (beatNumber == 5) { [self audioProcessorStart]; } if (beatNumber == 8) { [self audioProcessorStop]; [metroTimer invalidate]; metroTimer = nil; } beatNumber++ } 
-1
source

Source: https://habr.com/ru/post/1413552/


All Articles