[tw5] Very basic macro to play sounds

G’day,

Download the attached and drag into tiddlywiki.com to import the 3 tiddlers.

“I Play Sound on Render” tiddler references the sound macro, playing a tone upon render of the tiddler.

The related macro is in the “Macro” tiddler.

The “HTML Sound Player” tiddler is fed by the Macro into an iframe to execute the javascript that creates the sound.

Because sounds at higher frequencies sound obnoxiously loud, I’ve set things up to make the higher frequencies less loud and the lower frequencies louder.

Kind of an easy way to generate simple beeps and boops and bell sounds without much fuss.

TW_SoundMacro.json (1.57 KB)

For the giggles (a “bonking one’s head on a metal pipe” sound), put the following in a tiddler:

<<sound “200” “2” “exponentialRampToValueAtTime”>>

<<sound “500” “5” “exponentialRampToValueAtTime”>>

So a way to simultaneously play multiple sounds for some goofy effects.

1 Like

Hi,

sorry for the ignorant question , but what format are these sounds ,midi ?

Strangely enough, I’ve seen the word MIDI for ages, but never looked it up. MIDI is a standard communication protocol for electronic music instruments/equipment.

The generation of sounds in what I’ve done is just generation of frequencies using the web audio api.

I had to do a lot of digging, putting together bits and pieces from all over the place, to get a very rudimentary understanding of it all.

Starting with: Introduction to Web Audio API