10 ms·
Neutralizing the iOS camera click sound through active sound cancellation
- JosephRedfern 12y agoIs this how noise-cancelling headphones work?
- citizens 12y agoNot sure, but it's how a lot of karaoke tracks are made.
- clay_to_n 12y agoAnd if an artist releases instrumental or a capella versions of their track, you can usually use this to get the other. Only works if they're exactly the same as the original of course.
- psuter 12y agoAnother trick is to invert one of the stereo channels and add it to the other one: this eliminates everything that was mixed in with neutral pan. That's typically where the voice is. It will also remove e.g the drum kick, but this can be salvaged with a low-pass filter. Note that you end up with a mono track.
- deleted 12y ago[deleted]
- derekp7 12y agoWhile on the subject of these tricks -- disconnect the ground from the audio out, and tie the speaker grounds together. This causes the speakers to use each other as ground, which in effect causes the middle voice to cancel out.
- nitrogen 12y agoI used that trick to get a cheap rear channel from my thrift store stereo back in my high school days.
- robszumski 12y agoThat's really interesting. I never knew how they did that. Canceling out the frequencies of the voice makes complete sense.
- robin_reala 12y agoYes. They have a microphone and a circuit that inverts that input and mixes it into the recording.
- mbell 12y agoThat's not really what happens in noise-cancelling headphones. The transforms required are fairly complex, simple mixing is a long way from what is required to achieve good results.
- ethanbond 12y agoThe transforms aren't complex... They're inverted. What's complex is getting the timing right (can only occur at a fixed distance from the ear so they can delay the generated canceling waves appropriately). It's just wave addition. -1 + 1, occurring at the same time, is 0.
- mbell 12y ago> The transforms aren't complex... They're inverted. Again, It's not that simple. Most ANC headphones use a digital feed-forward control system using a variant of the LMS algorithm to provide coefficients to an adaptive FIR filter(s). Generally you also have to apply additional filters to model the loudspeaker / system response. Better systems will use a hybrid analog/digital approach, either way, there is a lot more to it than 'invert the mic signal and add'. The reason that ANC headphones didn't really exist until recently is that sufficiently high performance yet low power DSPs were needed to perform the necessary computations.
- mturmon 12y agoThanks for the correction. I assume that the simple v(t) + -1*v(t) = 0 approach is unworkable because you can't generate the canceling signal (-1 * v(t)) fast enough? By the time you have received it, amplified it, and played it back, it's too late? So you need a predictive approach.
- deleted 12y ago[deleted]
- jayd16 12y agoEveryone is getting really excited because they think this is how it works, but no, not exactly. The shutter sound comes from the same speaker as the anti-shutter sound. The phone is mixing the tracks together and playing nothing. It's not like both sounds are played and they neutralize each other as sound waves.
- lovemenot 12y agoSince it would have more general applicability, I am curious how effective could the noise-cancelling-like method could be? What would be the constraints on its effectiveness?
- wyager 12y agoIt's the same process that would happen if you actually played both sounds. The superposition is just happening in software instead of air.
- ANTSANTS 12y agoInverted sound waves can cancel each other in air, I've heard (or not heard) the effect with my own ears.
- TTPrograms 12y agoRight, but for any point source this is effect is going to vary spatially. That's why you can't make one speaker totally cancel out another speaker over a whole room.
- jayd16 12y agoSure, but my point is that there is only one speaker involved so the cancellation happens in the electronics, before any sound is made.
- kordless 12y agoIt's interesting to think of 'cancellation' in different mediums. Waves in physical space. Radio in electromagnetism. And now 'computed' waves cancel each other too.
- ertdfgcb 12y agoThis is a really cool solution to a problem that really seems like it shouldn't exist.
- pliu 12y agoIt's all relative. There are probably a lot of subway riding Japanese ladies that would argue that this problem really really should exist.
- greggman 12y agoHow do you figure? The same laws don't apply to digital cameras which come on all shapes and sizes.
- sosborn 12y agoWhen you are holding a camera, the intent is somewhat obvious. When you are holding a phone, not so much. That's the real separation.
- greggman 12y agoCameras come in all different shapes and sizes. I can get cameras that look like cellphones. I can even get keychain cameras for $4 off eBay and put them in my shoes. Set them to video and shoot hours of up skirt shots. The law does nothing to stop people who want to take pictures without you knowing they're doing it. Anyone who wants to will. The law is pointless
- Pitarou 12y agoNo, it is not pointless. The point of this law is to create the perception that the authorities are doing something about the perceived epidemic of upskirt photography. The same authorities also erect signs next to escalators warning people that upskirt photography is a crime. They serve the same purpose: to make escalator-riding ladies feel that the authorities are watching out for them. Don't knock it. It works.
- rrggrr 12y agoHilarity from the comments: I wish I could upvote twice: once for the inverted-cancelling hack, and once for answering your own question, just to counteract anyone daft enough to downvote you for that. – Daniel Earwicker 1 hour ago
- georgiecasey 12y agoi think that was aimed at me. i said in a now deleted comment: > Wow! Even though I know it's allowed, some coolness points deducted for posting the question yourself :-). I'd definitely do the same though. I'd be stopping random people in the street telling them the hack! i know posting and answering your own questions is encouraged on SO, it was just a joke!
- soundoflight 12y agoIt looks like he posted it AND answered it at the same time though, which is really weird.
- maxidog 12y agoEspecially weird considering the hack is totally unnecessary. You can take a picture without making a shutter sound using AVFoundation.
- m_myers 12y agoThere's a checkbox at the bottom of the "Ask" screen that lets you write your answer before posting the question. Makes it easier to document a piece of knowledge if you don't have a blog to post it on. http://stackoverflow.com/help/self-answer http://stackoverflow.com/help/self-answer
- TorKlingberg 12y agoI wonder if Apple is intentionally forcing the shutter sound, to prevent secret upskirt shots. I know several phones have had shutter sounds that cannot be disabled, and some countries have required it. In that case Apple might reject apps that use this trick.
- smackfu 12y agoEnd user can use the mute switch to turn off the sound. This question is about doing it programmatically.
- zbowling 12y agoIn Japan, the iPhone will always have the shutter sound even with mute on. You can't disable it or mute it. Even if you didn't buy the phone in Japan, the iPhone will do that in Japan.
- timothya 12y agoI've been to Japan, and my iPhone didn't make any shutter sounds while I was there.
- deleted 12y ago[deleted]
- gurkendoktor 12y agoNow the question is - how would the iPhone even know that's in Japan? :) GPS? I think OS X uses the time zone for these things, e.g. to block certain WiFi channels due to legal requirements.
- tacotime 12y agoWell, it is a phone... It's going to have access to geo data from the local cell phone towers, no timezone hacks necessary. In fact I believe the iPhone adjusts your active timezone automatically according to the geo data collected from the local cell tower, hence why your phone time changes when you touch down after a long flight.
- deleted 12y ago[deleted]
- happyscrappy 12y agoOn Android you can record without the user knowing which is way cooler.
- cpach 12y agoIs that really true?
- happyscrappy 12y agoOnly if you side load apps and give full permissions.
- deleted 12y ago[deleted]
- mschuster91 12y agoHow is this possible? Doing ANC would require the sound to be played at the exact same microsecond as the target sound.
- mikeash 12y agoI would guess that the sounds are both enqueued, and then playback of both actually starts slightly later, perhaps when the audio hardware indicates that it's ready to start accepting data.
- rasz_pl 12y agoVERY low audio latency on iOS. Its not android
- colanderman 12y agoCloser to exact same millisecond. 44.1 kHz sampling rate + 64(ish)-sample buffer granularity = ~1 millisecond.
- chronial 12y agoEven that is an overly harsh requirement. While being close does not completely remove the sound but still does severly reduce its volume: http://www.wolframalpha.com/input/?i=sin%28x%29+-+sin%28x-0.2%29%2C+sin%28x%29+-+sin%28x-0.5%29%2C+sin%28x%29 http://www.wolframalpha.com/input/?i=sin%28x%29+-+sin%28x-0....
- colanderman 12y agoNo, not really. If you're off by a millisecond (the minimum, assuming 64-sample buffers and 64 kHz sampling rate), frequencies which are even multiples of 500 Hz will be nullified, those which are odd multiples of 500 Hz will be amplified, and the rest will fall somewhere between those extremes. (This is known as a "comb filter"; see [1] and [2].) Your examples demonstrate the behavior of such filtering only for frequencies much less than 500 Hz, which will indeed be attenuated. However, a camera "click" sound, being both brief and noisy, contains lots of high-frequency content which will be, on the whole, preserved. In fact, assuming the "click" sound can be approximated by white noise, its total energy will be doubled by such filtering! So yes, you do need to play the sounds within the same millisecond. [1] http://en.wikipedia.org/wiki/Comb_filter http://en.wikipedia.org/wiki/Comb_filter [2] http://en.wikipedia.org/wiki/File:Comb_filter_response_ff_neg.svg http://en.wikipedia.org/wiki/File:Comb_filter_response_ff_ne...
- ja27 12y agoBarely related, but it's surprising how often DSLR newbies show up on photography forums asking how to disable the shutter sound on their cameras.
- vpdn 12y agoAwesome hack! If anyone wants try it out and play around, here's a demo project: https://github.com/vpdn/SilentPhotoCaptureDemo https://github.com/vpdn/SilentPhotoCaptureDemo
- pygy_ 12y agoApple owns the copyright of the shutter sound. That's enough to reject an app using this trick.
- 0x0 12y agoI guess the app could read the shutter audio file and invert it on the fly, it doesn't need to ship with the inverted sound upfront. As a bonus it would likely work even if future OS updates changed the sound (well, unless they moved the file so it would no longer be found)
- inafewwords 12y agoAnother trick is to use a dummy cord. Use a broken headset and cut off the jack. Plug that into the phone. Diverts sound to headset which doesn't exist. Or just put on a working set of headphones