Extract iPod Library raw PCM samples and play with sound effects

后端 未结 4 1968
清歌不尽
清歌不尽 2020-12-04 15:47

I am trying to extract raw PCM samples from an MP3 in the iPod Library so that I can play the song and manipulate the pitch, tempo, and apply sound effects (such as filters)

4条回答
  •  醉酒成梦
    2020-12-04 16:48

    Additionally to Tom Irving's Answer, I suggest replacing

           UInt8 buffer[length];
           CMBlockBufferCopyDataBytes(blockBufferRef, 0, length, buffer);
    
            NSData * data = [[NSData alloc] initWithBytes:buffer length:length];
    

    with

            NSMutableData * data = [[NSMutableData alloc] initWithLength:length];
            CMBlockBufferCopyDataBytes(blockBufferRef, 0, length, data.mutableBytes);
    

    which avoids double handling the samples, and reduces memory usage overhead.

    alternatively, you can wrap [NSMutableData dataWithLength:length] in an auto release pool as demonstrated in this answer to an unrelated but similar question.

提交回复
热议问题