martinjoiner / Skywriter-WebGL

An interactive 3D skywriter plane
0 stars 0 forks source link

🛩️ Aeroplane engine sound FX using Web Audio API #2

Open martinjoiner opened 6 years ago

martinjoiner commented 6 years ago

This ticket would suite somebody with a knowledge of sound FX and an interest in using the Web Audio API in JavaScript.

The project needs a module written in JavaScript that creates some basic light aircraft engine sounds:

At least 3 (maybe more) different pitches of engine noise:

I was thinking the Oscillator Node is the best tech for this but after research I now think a sample might be easier.

Incase you're interested, here's the basic code to make a middle A sound with the Oscillator:

var context = new AudioContext(),
oscillator = context.createOscillator();

oscillator.connect(context.destination); // Connect to speakers
oscillator.start(0); // Start generating sound immediately

oscillator.type = 'sine'; // Tell the oscillator to use a sine wave
oscillator.frequency.value = 440; // 440 hertz is a middle A

The module will need public methods to interact with it, firstly just to test it and later for when I hook up the plane speed to this new engine sound: stopEngine(), startEngine(), setEngineTone(num).

Code Standards

Please use Web Audio API https://webaudio.github.io/web-audio-api/ Please write the code using the Revealing Module Pattern Write your code in /src/js/sounds.js

csjiang commented 6 years ago

Hey @martinjoiner, is it required that the sound synthesis be written in pure JS using the Web Audio API, or is it acceptable to load a prerecorded audio source and then manipulate that programmatically?

Thanks!

martinjoiner commented 6 years ago

Hi @csjiang,

Yeah good point! Last night I was chatting with a couple of musically-trained synth geeks and they made it clear to me how hard it is to make an engine noise without a very complex synth, equipped with analogue and distortion filters. I will edit my post above and remove that requirement. Also notice that I have already added the "hiss" sound for the smoker so it's just the engine noise I need help with. (WIll edit now)