grails - Generate an Audio waveform in Groovy -


is there way generate audio waveform using groovy? or there third party libraries allows generate audio waveforms using groovy.

you can generate , play waveform using java audio (converted java here):

import javax.sound.sampled.*  byte[] wavform( int freq, int seconds, int samplerate ) {   byte[] ret = new byte[ seconds * samplerate ]   ret.length.times { idx ->     ret[ idx ] = (byte)( math.sin( ( 2.0 * math.pi * idx ) / ( samplerate / freq ) ) * 127 )    }   ret }  int samplerate = 8000 new audioformat( samplerate, 16, 1, true, true ).with { af ->   audiosystem.getsourcedataline( af ).with { line ->     line.open( af )     line.start()     wavform( 200, 1, samplerate ).with { byte[] wav ->       line.write( wav, 0, wav.length )     }     line.drain()     line.close()   } } 

however, you've tagged question grails, assume don't want play it?


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -