A coding competition
Editor’s Note: This entry produces audio output directly as well as a file. The audio file must then be manually converted to ogg / pcm and the resulting file produced does not exactly match the original. For technical reasons, only the converted audio file can be shown here.
Readers are encouraged to run the original for themselves, but your mileage may vary.
The body
tag is created and a button
is placed inside with a click event attached.
When the button
is clicked an async function calls a secondary function that will return a promise to the primary.
The secondary function accepts 3 variables frequency
, wave shape
and duration
from an array of notes
.
AudioContext
, Oscillator
and Gain
which are required to hear sound.MediaStream
to the Destination
which are required play the sound over the device’s speakersMediaRecorder
which is required to capture and store each sound so that it can be written to a file and downloaded.MediaRecorder
and the Oscillator
and after the specified duration
pushes the chunk of data to an array.notes
is built with the above function.In the next phase of the primary function the chunks of audio are combined with Blob
and encoded. Once this step is complete the url of the encoded media is assigned to an <a>
tag and a click event is fired on it starting the download of the file.
a.html
play
button.webm
formatDownloads
folder on your local disk_.webm
_.webm
with Chrome browserChrome (JavaScript + WebAPI)
989
Sample Rate: | Hz |
Sample Size: | bits |
Channels: | |
Encoding: |