html5-audio

How to use Web Audio API to make sound like guitar, piano etc


I want to use Web Audio API to simulate sound like guitar or something. Currently, I am using OscillatorNode to make sound by changing frequency. But I have no idea which node should I use and how to use it to make sound like guitar or something. Should I change waveform or what? and how?

Here is some reference https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html


Solution

  • "Sound like a guitar" is a vague request. If you want to manually synthesize a guitar-esque sound using Web Audio components, you'll need to do some research into waveforms for guitars and other string instruments, then read up on techniques to create these waveforms via DSP. Here's what you're looking at: http://www.ee.columbia.edu/~ronw/dsp/

    Another (probably easier) option would be to load up guitar string samples into AudioBuffer nodes and manipulate those: http://www.w3.org/TR/webaudio/#AudioBuffer