Sine wave: Difference between revisions

m
Line 350:
 
=={{header|J}}==
Approximately 1751 Hz (slightly flat A, two octaves above middle C), five seconds duration:
<lang J> require'media/wav'
4 wavplay wavmake <.1e3*1 o.i.55e3
</lang>
 
For simplicity, we use rely on a default wav sample rate of 11khz. Also, for simplicity, we are taking the sine of integer values (0, 1, 2, 3, 4, 5, 6), which gives us slightly more than six samples per cycle. 1e3 here represents the amplitude of our wave, which is interpreted as a signed 16 bit integer. So we're about 30 decibels below max volume (a factor of 10 in amplitude is a difference of 20 decibels):
 
<lang J> 20*10 ^. (2^15) % 1e3, 2^15
30.309 0</lang>
 
=={{header|JavaScript}}==
6,951

edits