web audio - Queue PCM buffers with WebAudio API -


i pcm data server. best way play them 1 after another? call following function each sample batch get:

function playsamples( samples ) {      let count = samples.length / 2;      let leftdata = new float32array( count );     let rightdata = new float32array( count );      ( let t = 0; t < count; ++ t ) {         leftdata[ t ] = samples[ t * 2 + 0 ] / 0x7fff;         rightdata[ t ] = samples[ t * 2 + 1 ] / 0x7fff;     }      let audiobuffer = this.context.createbuffer( 2, count, this.frequency );      audiobuffer.getchanneldata( 0 ).set( leftdata );     audiobuffer.getchanneldata( 1 ).set( rightdata );      let sourcenode = this.context.createbuffersource( );      sourcenode.buffer = audiobuffer;     sourcenode.connect( this.context.destination );     sourcenode.start( this.endtime );      this.endtime += audiobuffer.duration;  } 

basically, setup new buffer each batch, schedule play right @ end of previous batch. kinda works, audio isn't enough, due lot of noise expect come clumsy concatenation of samples. there better way want?


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -