Live data from Hacker News

Generation of Music Using Pure JS and HTML5

cssdeck.com

11–17 of 17 posts

Re: Generation of Music Using Pure JS and HTML5

#11
Yeah, that's MY CODE, mate. Maybe give some credit, eh?

Edit: Looks like OP just borrowed my note array.. which I in turn borrowed from Aphex twin, so no harm done... :)

Also, it isn't working 100% in Chrome, the sampling rate is probably wrong.

You can check out my example Here: http://valdemarorn.github.com/Files/JSAudio/index.html

Anyway, Riffwave was posted here yesterday, and I posted a similar example I did with WebAudioAPI. Basically, it's that code that OP has adapted to fit into RiffWave.

My code can be found here: https://github.com/ValdemarOrn/valdemarorn.github.com/tree/m...

Re: Generation of Music Using Pure JS and HTML5

#12

Yeah, that's MY CODE , mate. Maybe give some credit, eh? Edit: Looks like OP just borrowed my note array.. which I in turn borrowed from Aphex twin, so no harm done... :) Also, it isn't working 100% in Chrome, the sampling rate is probably wrong. You can check out my example Here: http://valdemarorn.github.com/Files/JSAudio/index.html Anyway, Riffwave was posted here yesterday, and I posted a similar example I did wi…

Yes the notes sequence and the base frequency algorithm is yours and I notified you about using it here. http://news.ycombinator.com/item?id=4561565

I am sorry for not giving credit to you on the main page.

Edit: BTW, what is wrong with the sampling frequency? I think 44KHz is sufficient and it's working fine on my Chrome. A fork maybe?

Re: Generation of Music Using Pure JS and HTML5

#13

Yeah, that's MY CODE , mate. Maybe give some credit, eh? Edit: Looks like OP just borrowed my note array.. which I in turn borrowed from Aphex twin, so no harm done... :) Also, it isn't working 100% in Chrome, the sampling rate is probably wrong. You can check out my example Here: http://valdemarorn.github.com/Files/JSAudio/index.html Anyway, Riffwave was posted here yesterday, and I posted a similar example I did wi…

Yes the notes sequence and the base frequency algorithm is yours and I notified you about using it here. http://news.ycombinator.com/item?id=4561565 I am sorry for not giving credit to you on the main page. Edit: BTW, what is wrong with the sampling frequency? I think 44KHz is sufficient and it's working fine on my Chrome. A fork maybe?

No problem, I was just a little surprised when I saw it :)

Re: Generation of Music Using Pure JS and HTML5

#15
post #14

That distortion you're hearing is because of sharp changes in your signal's amplitude. To get rid of it, you should apply a little bit of smoothing to the attack and release of individual notes.

A little ADSR envelope and one smidgen of FM synthesis helps...

		var data = [],
			sampleRateHz = 44100,
			lengthInSeconds = 8,
			sampleCount = sampleRateHz * lengthInSeconds,

			//Notes sequence, play with it ;)
			notes = [87, 0, 87, 0, 85, 0, 82, 0, 80, 0, 82, 82, 80, 0, 82, 0, 85, 0, 78, 0, 78, 78],
			
			noteLength = sampleCount / notes.length,
			
			//Base Frequency based on the notes
			baseFreq = function(index) {
				var r = 2 * Math.PI * 220.0 * Math.pow(2,(notes[index]-69)/12.0) / sampleRateHz;
				return r;
			},
			
			envelope = function(offset, attack, decay, sustain, release) {
				if (offset 

Re: Generation of Music Using Pure JS and HTML5

#16
post #15
post #14

That distortion you're hearing is because of sharp changes in your signal's amplitude. To get rid of it, you should apply a little bit of smoothing to the attack and release of individual notes.

A little ADSR envelope and one smidgen of FM synthesis helps... var data = [], sampleRateHz = 44100, lengthInSeconds = 8, sampleCount = sampleRateHz * lengthInSeconds, //Notes sequence, play with it ;) notes = [87, 0, 87, 0, 85, 0, 82, 0, 80, 0, 82, 82, 80, 0, 82, 0, 85, 0, 78, 0, 78, 78], noteLength = sampleCount / notes.length, //Base Frequency based on the notes baseFreq = function(index) { var r = 2 * Math.PI * 2…

this helped a LOT! I created a fork just to test and the sound was definitely awesome! http://cssdeck.com/labs/5atlvhph/0
Post reply on HN