This is a question related to Are there APIs for custom vibrations in iOS?. I am able to create custom vibration patterns, but have no control over the intensity.
This is copied over from Kevin Cao's answer that enables custom vibration patterns:
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
NSMutableArray* arr = [NSMutableArray array ];
[arr addObject:[NSNumber numberWithBool:YES]]; //vibrate for 2000ms
[arr addObject:[NSNumber numberWithInt:2000]];
[arr addObject:[NSNumber numberWithBool:NO]]; //stop for 1000ms
[arr addObject:[NSNumber numberWithInt:1000]];
[arr addObject:[NSNumber numberWithBool:YES]]; //vibrate for 1000ms
[arr addObject:[NSNumber numberWithInt:1000]];
[arr addObject:[NSNumber numberWithBool:NO]]; //stop for 500ms
[arr addObject:[NSNumber numberWithInt:500]];
[dict setObject:arr forKey:@"VibePattern"];
[dict setObject:[NSNumber numberWithInt:1] forKey:@"Intensity"];
AudioServicesPlaySystemSoundWithVibration(4095,nil,dict);
The line of code that adds the key @"Intensity"
with an int
value doesn't do the trick and I don't know how to look inside the AudioServicesPlaySystemSoundWithVibration
method to figure it out. What do I have to pass to it so that it actually changes the intensity?
Right now, it doesn't matter if I pass 1, 1000, 0.4 or 0.0001, it's always the same intensity (on an iPhone 4 with iOS7). Can anyone recreate this?
I would like to be able not only to create vibration patterns, but a smooth vibration envelope. How to?
(As this is a research project for instrument design, I am not (yet) concerned with the App store restrictions.)