hui xie
hui xie

Reputation: 1

Audio mute after changing speed by AUGraph

I use AUGraph to change music speed and get music by rendercallback

_mixNode = [self addNode:kAudioUnitType_Mixer subType:kAudioUnitSubType_MultiChannelMixer];
_effectNode = [self addNode:kAudioUnitType_FormatConverter subType:kAudioUnitSubType_NewTimePitch];
_outputNode = [self addNode:kAudioUnitType_Output subType:kAudioUnitSubType_GenericOutput];
...
AURenderCallbackStruct callbackStruct;
callbackStruct.inputProcRefCon = (__bridge void*)(self);
callbackStruct.inputProc = RenderCallback;
AUGraphSetNodeInputCallback(_audioGraph, _mixNode, 0, &callbackStruct);

I set speed by this code:

AudioUnitSetParameter(_effectAudioUnit, kNewTimePitchParam_Rate, kAudioUnitScope_Global, 0, _speed, 0);

And I found if abs(speed1-speed2)==1 and change multiple times, like 2<->3/3<->4 etc, output music will probably be silent, other difference is OK.

The problem is only happened on IOS16\IOS17 platform

I tried different speed couples, and found only abs(speed1-speed2)==1 would result in silent, even 2.5<->3.5

other speed like 4<->6, 2.1<->3 is OK

Upvotes: 0

Views: 45

Answers (0)

Related Questions