MCPcopy Create free account
hub / github.com/dashrobotco/robot-components / hashString

Method hashString

src/utils/SoundEffects.ts:238–246  ·  view source on GitHub ↗

* Simple string hash function for consistent pitch variations

(str: string)

Source from the content-addressed store, hash-verified

236 * Simple string hash function for consistent pitch variations
237 */
238 private hashString(str: string): number {
239 let hash = 0;
240 for (let i = 0; i < str.length; i++) {
241 const char = str.charCodeAt(i);
242 hash = ((hash << 5) - hash) + char;
243 hash = hash & hash; // Convert to 32-bit integer
244 }
245 return Math.abs(hash) / 2147483647; // Normalize to 0-1
246 }
247
248 /**
249 * Resume audio context if it's suspended (required by some browsers)

Callers 1

playHoverSoundMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected