小编kha*_*led的帖子

任何人都可以帮助我通过音频单元录制iPhone输出声音

这是我的代码:我使用此代码通过使用音频单元记录iPhone输出音频,然后将输出保存在output.caf中,但output.caf文件为空,任何人都知道我该怎么办?输出音频文件为空

这是音频单元的初始化

-(void) initializaeOutputUnit
{
    OSStatus status;

    // Describe audio component
    AudioComponentDescription desc;
    desc.componentType = kAudioUnitType_Output;
    desc.componentSubType = kAudioUnitSubType_RemoteIO;
    desc.componentFlags = 0;
    desc.componentFlagsMask = 0;
    desc.componentManufacturer = kAudioUnitManufacturer_Apple;

    // Get component
    AudioComponent inputComponent = AudioComponentFindNext(NULL, &desc);

    // Get audio units
    status = AudioComponentInstanceNew(inputComponent, &audioUnit);

    // Enable IO for recording
    UInt32 flag = 1;
    status = AudioUnitSetProperty(audioUnit, 
                                  kAudioOutputUnitProperty_EnableIO, 
                                  kAudioUnitScope_Input, 
                                  kInputBus,
                                  &flag, 
                                  sizeof(flag));

    // Enable IO for playback
    status = AudioUnitSetProperty(audioUnit, 
                                  kAudioOutputUnitProperty_EnableIO, 
                                  kAudioUnitScope_Output, 
                                  kOutputBus,
                                  &flag, 
                                  sizeof(flag));

    // Describe format
    AudioStreamBasicDescription audioFormat={0};
    audioFormat.mSampleRate …
Run Code Online (Sandbox Code Playgroud)

iphone core-audio audiounit ios5

11
推荐指数
1
解决办法
7766
查看次数

SpriteKit中的正弦波运动

我想从屏幕的第一个点到屏幕的最后一个点进行正弦波运动,与屏幕的大小无关.

这是我的代码,但它无法正常工作:

 SKSpriteNode* RedBird = (SKSpriteNode*)[self childNodeWithName:@"RedBird"];
CGPoint currentPoint=CGPointMake(-60,0);
double width=self.frame.size.width/4;
CGPoint cp1=CGPointMake(width, self.frame.size.height/2);
CGPoint cp2=CGPointMake((width*3), 0);
CGPoint e=CGPointMake(self.frame.size.width+200, 0);


CGMutablePathRef cgpath = CGPathCreateMutable();


CGPathMoveToPoint(cgpath,NULL, currentPoint.x, currentPoint.y);
CGPathAddCurveToPoint(cgpath, NULL, cp1.x, cp1.y, cp2.x, cp2.y, e.x, e.y);



[RedBird runAction:[SKAction group:@[[SKAction repeatActionForever:RedBirdAnimation],[SKAction followPath:cgpath asOffset:YES orientToPath:NO duration:12.0]]]];


CGPathRelease(cgpath);
Run Code Online (Sandbox Code Playgroud)

ios sprite-kit

10
推荐指数
2
解决办法
2549
查看次数

我想从iOS 10读取控制台日志

我正在使用此代码但由于更改了与Logging System相关的所有API,因此它不再适用于iOS 10.

+ (NSString *)getConsoleLog {
NSString *consoleLog = @"";
char fdate[24];

NSString *myPID = [NSString stringWithFormat:@"%d", getpid()];
aslmsg query, msg;
query = asl_new(ASL_TYPE_QUERY);
asl_set_query(query, ASL_KEY_PID, myPID.UTF8String, ASL_QUERY_OP_EQUAL);
aslresponse r = asl_search(NULL, query);

while ((msg = aslresponse_next(r))) {
    NSString *secondsString = [NSString stringWithFormat:@"%s", asl_get(msg, ASL_KEY_TIME)];
    NSString *nanoSecondsString = [NSString stringWithFormat:@"%s", asl_get(msg, ASL_KEY_TIME_NSEC)];

    NSTimeInterval seconds = [secondsString doubleValue];
    NSTimeInterval nanoSeconds = [nanoSecondsString doubleValue];
    NSTimeInterval msgTime = seconds + nanoSeconds / NSEC_PER_SEC;

    time_t timestamp = (time_t)msgTime;
    struct tm *lt = localtime(&timestamp); …
Run Code Online (Sandbox Code Playgroud)

ios10

8
推荐指数
1
解决办法
531
查看次数

通过核心图形绘制自定义形状的圆角

我正在使用Core Graphics绘制自定义形状,我想为这个形状制作圆角,这是我绘制自定义形状的代码

CGPoint p1=[self getPointFromAngleQuarter:start_angle2 andRaduis:card.small_Raduis andCenter:center];
CGContextMoveToPoint(context, p1.x, p1.y);
CGPoint p2=[self getPointFromAngleQuarter:start_angle2 andCenter:center andRaduis:self.large_Raduis];
CGContextAddLineToPoint(context, p2.x, p2.y);
CGContextAddArc(context,center.x, center.y, selectedLargeRaduis, start, end,0);
CGPoint p5=[self getPointFromAngle:end_Angle andCenter:center andRaduis:self.small_Raduis];
CGContextAddLineToPoint(context, p5.x, p5.y);
CGContextAddArc(context,center.x, center.y,selectedSmallRaduis, end, start,1);
CGContextDrawPath(context, kCGPathFill);
Run Code Online (Sandbox Code Playgroud)

这是我自定义Shape的最终结果

自定义形状:

自定义形状

core-graphics cgcontext ios

0
推荐指数
1
解决办法
990
查看次数