Friday, October 21, 2011

Back to Back Gapless Audio Playback with AVAudioPlayer on the iPhone

There are two ways that I know of to get two audio files from AVAudioPlayer to play one after the other. The first, and the one I have seen recommended elsewhere, is to use audioPlayerDidFinishPlaying as follows:

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {
    if ([player isEqual:self.firstAudioFile]) {
        [self.secondAudioFile play];

However this can cause a gap in playback between the two audio files. One way to avoid this and avoid use of this method completely is to schedule the second one to play when the first is done, like this:

[self.firstAudioFile play]
NSTimeInterval now = self.firstAudioFile.deviceCurrentTime;
[self.secondAudioFile playAtTime: now + self.firstAudioFile.duration];

Hope this helps people searching around for a solution to this.

The Apple documentation for AVAudioPlayer:

Friday, August 12, 2011

Cellular Automata Predator Prey Model

Model of predator prey interactions using cellular automata. This was made with three other people for a BioMath class. If I remember correctly the # symbols are prey and the * are predators. What you see in the video are cycles of one becoming abundant while the other diminishes and then switching.

It uses this python software:

Saturday, August 6, 2011

Recommended Books

I have included things that I underlined or noted when I initially read the book. These are in no order.

Currently reading:
The Art of Learning by Josh Waitzkin
Programming  Interviews Exposed by John Mongan, Noah Suojanen and Eric Giguere

Talent Is Overrated by Geoff Colvin

Hackers & Painters by Paul Graham
"The more IT flavor the job descriptions had, the less dangerous the company was. The safest kind were the ones that wanted Oracle experiences. You never had to worry about those. You were also safe if they said they wanted C++ or Java developers. If they wanted Perl or Python programmers, that would be a bit frightening-that's starting to sound like a company where the technical side, at least, is run by real hackers." p. 161
Programming languages vary in power.

On Intelligence by Jeff Hawkins
Chapter 8: The Future of Intelligence

Crush It! by Gary Vaynerchuk

Complexity by Menlanie Mitchell
Chapter 9 on Genetic Algorithms, Chapter 10 on Cellular Automata

The Search by John Battelle
"'Because of their early success, they were closed-minded and a bit arrogant,' Khosla recalls. 'Nothing deceives like success,' Excite cofounder Joe Kraus acknowledges." p. 55
Chapter 4: Google Is Born

In Search of Memory by Eric Kandel
"Libet proposes that the process of initiating a voluntary action occurs in an unconscious part of the brain, but that just before the action is initiated, consciousness is recruited to approve or veto the action. In the 200 millisecond before a finger is lifted, consciousness determines whether it moves or not." p. 390
"One such shift will be from studying elementary processes-single proteins, single genes, and single cells-to studying system properties-mechanisms made up of many proteins, complex systems of nerve cells, the functioning of whole organisms, and the interaction of groups of organisms." p. 423
"Giacomo Rizzolatti, an Italian neuroscientist, has discovered that when a monkey carries out a specific action with its hand, such as putting a peanut in its mouth, certain neurons in the premotot cortext become active. Remarkably, the same neurons become active when a monkey watches another monkey (or even a person) put food in its mouth." p. 425

Business Stripped Bare by Richard Branson
"Inspire your people to think like entrepreneurs, and whatever you do, treat them like adults." p. 40
"Life has become too cosy for many, who have their lives mapped out by parent and teachers. It's all a bit, well, comfortable" p. 282

Outliers by Malcom Gladwell
"We sometimes think of being good at mathematics as an innate ability. You either have "it" or you don't. But to Schoenfeld, it's not so much ability as attitude. You master mathematics if you are willing to try." p. 246
On education: many kids are picked at a very young age to be "smarter" than others and are treated as such until it becomes true.

The Mac OS X Command Line by Kirk McElhearn

How to Win Friends & Influence People by Dale Carnegie