Objective-C的/ IOS:扭转NSMutabledata字节 [英] Objective-c/IOS: Reversing the bytes in NSMutabledata
问题描述
在我的应用程序都存储在NSMutableData像这样的音频文件的字节数:
NSMutableData *数据= [NSMutableData dataWithBytes:byteData长度:LEN];
我可以然后使用以后玩这个
播放器= [[AVAudioPlayer页头] initWithData:数据错误:&放大器;错误]
我的问题是什么code将扭转数据对象的字节数,这样就起到时声音倒退?
任何帮助非常多AP preciated。
顺便说一下,用获得的音频的byteData:
NSMutableData *波= [NSMutableData dataWithContentsOfURL:URL]NSUInteger LEN = [波长]
BYTE * byteData =(BYTE *)malloc的(LEN);
的memcpy(byteData,[波字节],LEN);
DaveSmith122是正确的。你不能只是扭转字节的数据。我已经实现了使用和CoreAudio的AudioUnits同样的效果。使用ExtFileReader C API来读取文件到LPCM缓冲区,然后根据需要可以撤消缓冲区。
In my application I have the bytes of an audio file stored in NSMutableData like so:
NSMutableData *data = [NSMutableData dataWithBytes:byteData length:len];
I can then later play this using
player = [[AVAudioPlayer alloc] initWithData:data error:&error];
My question is what code would reverse the bytes in the data object, so that when played the sound is backwards?
Any help is very much appreciated.
By the way, the byteData of the audio is obtained using:
NSMutableData *wave =[NSMutableData dataWithContentsOfURL:url];
NSUInteger len = [wave length];
Byte *byteData = (Byte*)malloc(len);
memcpy(byteData, [wave bytes], len);
DaveSmith122 is right. You cannot just reverse the byte data. I have achieved the same effect using CoreAudio and AudioUnits. Use ExtFileReader C API to read the file into lPCM buffers and then you can reverse the buffers as needed.
这篇关于Objective-C的/ IOS:扭转NSMutabledata字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!