generating sound with createJavaScriptNode in an emulator

   Hello Chris

   I am new in this mailing list. My name is Antonio, I am a Spanish 
developer. I have created this emulator:

http://jbacteria.antoniovillena.es/

   I try to put sound in the emulator with this init code:

if(typeof webkitAudioContext == 'function')
   cts= new webkitAudioContext(),
   paso= 69888*50/cts.sampleRate,
   node= cts.createJavaScriptNode(1024, 0, 1),
   node.onaudioprocess= function (e){
     data= e.outputBuffer.getChannelData(0);
     node.onaudioprocess= buffer;
   },
   node.connect(cts.destination);

   and the buffer function:

function buffer(e) {
   play= flash*69888 + st - paso*1024;
   j= 0;
   while( j<1024 )
     if( data[j++]= sample
       , (play+= paso) > vb[playp] )
       sample^= 0x40,
       playp= playp+1 & 0xff;
}

   But the quality of the sound is very bad. I have tried to increase 
the buffer to 2048 and 4096 with worse result. I don't know if the 
problem is mine or a bad Chrome implementation.

   As you can see, the 48K sound is very simple, as the PC beeper. I 
would like to implement 128K AY-8912 sound, later, if I can fix this issue.

   The source code is here:
http://jbacteria.antoniovillena.es/jBacteriaSourceCode.zip

   And a game when you can hear the bad sound is for example:
http://jbacteria.antoniovillena.es/48?fernando

   Regards (and sorry for my bad English)
-- 
    ,       _            _       __   ___ _ _
   /_\  _ _| |_ ___ _ _ (_)___   \ \ / (_) | |___ _ _  __ _
  / _ \| ' \  _/ _ \ ' \| / _ \   \ V /| | | / -_) ' \/ _` |
/_/ \_\_||_\__\___/_||_|_\___/    \_/ |_|_|_\___|_||_\__,_|

Received on Friday, 20 May 2011 06:56:59 UTC