Playing multiple tracks for iPods on iPhone at the same time with pitch bend and other effects

I have been doing this for the past two weeks, and it drives me crazy. I asked this question a couple of days ago ( Extract the original PCM samples for the iPod library and play with sound effects ), and although the answer got me halfway, I'm still stuck.

Basically, I'm trying to get several songs from the iPod library to play with effects such as pitch bend, equalizer effects, etc.

I followed the path of AVPlayer and AVAudioPlayer, which are too simple. The only structure I've seen that can play audio with these effects is OpenAL. I tried several objective c-wrappers (Finch and ObjectAL). Finch does not play compressed audio, while ObjectAL will only convert it for me if I pass the file URL (which I cannot do because I have an incompatible iPod library URL).

An example of an application that does what I want to beautifilly is Click DJ . It can quickly download songs from the iPod library (unlike TouchDJ , and it plays them with all kinds of effects.

Any help would be greatly appreciated.

+3
source share
1

PCM, OpenAL, ObjectAL.

:

  • (AL_FORMAT_MONO16 AL_FORMAT_STEREO16)

ALSource . OALSimpleAudio (, ), , :

[OALSimpleAudio sharedInstance].reservedSources = 20; // or some number < 32

( init):

mySource = [[ALSource source] retain];

ALBuffer , :

ALBuffer* myBuffer = [ALBuffer bufferWithName:someName
                           data:myAudioData
                           size:audioDataSizeInBytes
                         format:audioFormat
                      frequency:sampleRateInHz];

:

[mySource play:myBuffer];

Edit: ALBuffer free() , . , :)

2: "freeDataOnDestroy" ALBuffer, , ( YES).

3: . , , . "playBuffer" OALSimpleAudio.

, OALSimpleAudio :

myBuffer = [[ALBuffer bufferWithName:someName
                           data:myAudioData
                           size:audioDataSizeInBytes
                         format:audioFormat
                      frequency:sampleRateInHz] retain];

...

id<ALSoundSource> source = [[OALSimpleAudio sharedInstance] playBuffer:myBuffer
                                                                volume:1.0
                                                                 pitch:1.0
                                                                   pan:0
                                                                  loop:NO];

[source pitchTo:2.0
       duration:5.0
         target:nil
       selector:nil];
// And so on...
+5

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


All Articles