DEV Community

Discussion on: A simple audio sequencer using Web Audio Api & Angular

Collapse
jomopipi profile image
JomoPipi • Edited on

Nice article :D
Instead of hard-coding each note's frequency, it might be less work to start with some frequency and just keep multiplying it by the 12th root of two to get the next one.

const TR2 = 2 ** (1.0 / 12.0)
const frequencies = [...Array(12 * nOctaves + 1)].reduce(notes => 
    (notes.push(notes[notes.length-1] * TR2), notes),[110])
Enter fullscreen mode Exit fullscreen mode