MCPcopy
hub / github.com/freeCodeCamp/freeCodeCamp / playTone

Function playTone

client/src/utils/tone/index.ts:98–113  ·  view source on GitHub ↗
(state: ToneStates)

Source from the content-addressed store, hash-verified

96type ToneStates = keyof typeof toneUrls;
97
98export async function playTone(state: ToneStates): Promise<void> {
99 const playSound = !!store.get('fcc-sound');
100 if (playSound && toneUrls[state]) {
101 const Tone = await import('tone');
102
103 const player = new Tone.Player(toneUrls[state]).toDestination();
104
105 const storedVolume = (store.get('soundVolume') as number) ?? 50;
106 const calculateDecibel = -60 * (1 - storedVolume / 100);
107
108 player.volume.value = calculateDecibel;
109
110 await Tone.loaded();
111 player.start();
112 }
113}

Callers 5

createFlashMessageFunction · 0.90
DonateModalFunction · 0.90
handleVolumeChangeFunction · 0.90
BlockClass · 0.90
executeChallengeSagaFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected