Skip to content

Commit

Permalink
Add an aperiodic wave resembling the upper register of a piano
Browse files Browse the repository at this point in the history
  • Loading branch information
frostburn committed Jul 19, 2024
1 parent 370e367 commit e65d90d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/synth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const APERIODIC_WAVEFORMS = [
'jublag',
'ugal',
'gender',
'piano',
'tin',
'bronze',
'steel',
Expand Down Expand Up @@ -386,6 +387,26 @@ function initializeAperiodic(audioContext: BaseAudioContext) {
tolerance
)
})

APERIODIC_WAVES['piano'] = computed(() => {
const freqs = [
0.998711340392508, 1.0012886596074921, 2.000000001915048, 3.0077319605175252,
4.024484537329971, 4.028350517109971, 5.052835053482418, 6.0953608281898495,
6.100515466619817, 7.149484540322233, 7.158505158532202, 8.221649488874554, 9.326030932401801,
9.3298969121818, 9.33891753039177, 10.449742272914, 10.457474232474, 10.466494850683969,
11.597938150756168
]

const amps = [
0.9123120265773679, 0.7281477301038842, 0.5078045641543809, 0.8061314224800064,
0.3177244232370868, 0.15135058363038334, 0.12440135191000032, 0.045007651288955175,
0.050804443667738106, 0.029671376885221354, 0.023841125287306208, 0.01853341284211317,
0.02380292893502422, 0.024761095205029133, 0.020866326567241505, 0.0017670624571622458,
0.0024893662658642206, 0.0012043792096897129, 0.0014228119365412375
].map((a) => a * 0.38)

return new AperiodicWave(audioContext, freqs, amps, maxNumberOfVoices, tolerance)
})
}

export function initializeCustomWaves(audioContext: BaseAudioContext) {
Expand Down

0 comments on commit e65d90d

Please sign in to comment.