Archive for April, 2010


So here’s a quick couple snippets of code that will allow you to retrieve the coordinates of two locations using Google Maps API — no API key necessary.

This first function will return the coordinates of specific address (I find pretty much anything works, whether it’s a full address with street number, or just a postal code, or simply a city name) as an array of coordinates:

function getCoordinates($address) {   $url = "http://maps.google.com/maps/geo?q=" . urlencode($address)          . "&output=json";   $result = file_get_contents($url);   $result = json_decode($result, 1);   if (isset($result['Placemark'])) {     list($lat, $long) = $result['Placemark'][0]['Point']['coordinates'];   } else {     $lat = $long = false;   }   return array($lat, $long); }

View full article »

Generating MP3 waveforms with PHP

UPDATE: After some great comments, I have optimized the performance of this script and made some brief commentary available here. I have also updated any source code links below to the new github project page.

I don’t quite know what gave me the desire to ever generate audio (specifically MP3) waveforms with PHP — it’s not something I’ll likely ever use — but after doing some research and coming up a bit short I decided to make it happen.

Waveform generated using Dancing With Paris' "(Boardwalk)" MP3.

A few days of Googling, I did come up with a couple solutions but none seemed to really produce the results I wanted. All I was looking to generate was a simple waveform like that in Cubase or other recording software. I don’t need axis labels or left/right audio splits, just a simple mono waveform from an MP3. I also didn’t want to go through hundreds of audio files and convert them into WAV files just to do this — if I was going to do this as an experiment, I wanted it on the fly. I did come across some interesting links though:

View full article »

Powered by WordPress | Theme: Motion by 85ideas.