Tibor SzászAz élmény, ami számít

  • Nyitólap
  • Magamról
  • Projectek
  • Ajánlatkérés
  • Kapcsolat
  • RSS

2010 0509

Customizing the SoundCloud waveform image

Customizing the SoundCloud waveform image For the last months, I'm using SoundCloud's API to create an application. I had several issues, that I managed to solve, and this one I'm going to show you is one of my favorite. The waveform that soundcloud generates for a song, looks like the one I attached to the post.
It's not bad, as long as you can integrate the gray mask with your application design. If you can't then you can start to scratch your head. I did. :)


The solution I came up with is simple: put the waveform on a canvas, then process the image to fit my design. Fortunately, there is a great canvas image manipulation library, called Pixastic. It was created by Jacob Seidelin (aka. Nihilogic) and it has several filters, in my case the brightness filter did the job.
If you are familiar with Photoshop, you can imagine how easy it is to reduce some brightness and add some contrast to achieve some image enhancement.
Pixastic does it in a very fast way. Here is a sample code how can you use it:

var renderWaveform = function( waveformURL )
{
	var img = new Image();
	img.src = waveformURL;

	img.onload = function()
	{
		var ctx = $('#waveform')[0].getContext('2d');

		var gradient = ctx.createLinearGradient(0, 0, 0, 30);
		gradient.addColorStop(0, '#ccc'); 
		gradient.addColorStop(1, '#000');
		ctx.fillStyle = gradient;

		// Draw background
		ctx.fillRect( 0, 0, 210, 30 );

		ctx.drawImage( img, 0, 0, 210, 30 );

		Pixastic.process( $('#waveform')[0], "brightness", {brightness:-33,contrast:0.5});
	}
}
The results are nice:


Kommentek


#01

Latom addig piszkaltalak, mig megoldottad ezt a dolgot! :) IE8 alatt egyebkent csak a narancssarga poziciojelzo jelenik meg a lejatszon. :(

Beküldte: Rapp @ 2010-05-19 22:29

#02

El is felejtettem, hogy ezt beszéltük, de valóban, megérte :D

Beküldte: Tibi @ 2010-05-21 17:50

#03

Good morning Tabot,
We need a chart player as yours above for webradio to trasnmit events in Rio de Janeiro in 2-3 months.

Do you have any solution for unlimited songs at all, we like of cloudychats, but it seems a solution for a limited number of musics.


Regards

Beküldte: Cleber @ 2011-06-10 16:17

#04

Can you please explain how this manipulated image is used? Are you displaying it on your own website, or replacing the one used by Soundcloud?

Beküldte: Peter Shute @ 2012-01-24 22:55

#05

I used the manipulated waveform for a custom SoundCloud player on my own site, cloudycharts.com it seems to be broken now, I'll fix it some time.

I had to write a simple proxy script that downloaded the track's waveform image and displayed it, because the canvas element cannot work in a cross domain way. The conversion was done on the fly.

Beküldte: Tibi @ 2012-01-24 23:27

Új komment hozzáadása


Neved
E-mail
Your avatar
Weblapod
Komment

Eligazítás

Me myself and I
Imádok kódolni, különösesn a webre. Már 6 éve építem az online világot, kedvenc játékszereim:
JavaScript, PHP, XHTML, MySQL, Canvas, Flash
Switch to english

Témakörök

  • Coffee break
  • Design & stuff
  • Generative arts
  • Programming
  • User experience

Barátok

  • Kárpáti Róbert
  • Royaljerry
  • Bagi Zoltán
  • Pegazoo
  • Charles Alexander Deli
  • Bence Bangócs
  • Lunakid
  • Rapp design

Közösségi láz

  • Facebook
  • IWIW
  • TurulMeme

Címkék

javascript (14) php (6) mootools (5) iscaffold (4) codeigniter (4) tutorial (3) crud (3) structure-synth (2) renders (2) template (2) css (2) free (2) google (2) drupal (1) data-visualisation (1) resizing (1) canvas (1) soundcloud (1) wordpress (1) joomla (1) google-buzz (1) hack (1) script (1) rss (1) bermuda-triangle (1) interface (1) design, (1) transitions (1) easing (1) microsoft (1) windows8 (1) magyar (1) bugs (1) ie8 (1) experience (1) user (1) twitter (1) facebook (1) email (1) table (1) rc1 (1) nl2br (1) drag-and-drop (1) slideshow (1) wikipedia (1) dns (1) svg (1) experiment (1) firefox-extension (1) tagging (1) slimbox (1) bugfix (1) cfdg (1) lists (1) inspiration (1) data-uri (1) trick (1) forge (1) infovis (1) blackout (1) tabs (1) library (1) sitebuild (1) utf8 (1) class (1) ajax (1) konami-codes (1) open-source (1)




Minden jog fenntartva, ©2008-2012 - Készült CodeIgniter keretrendszerrel - Konami codes - Mostly Valid XHTML 1.1 - Valid CSS 2.1