26 lines
755 B
Go
26 lines
755 B
Go
// Copyright (c) 2026 Storm Dragon
|
|
// Authors: Storm Dragon, Angus Kola
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package sound
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
const indentationCuePrefix = "generated-indentation-tone:"
|
|
|
|
func IndentationCueName(frequency int) string { return indentationCuePrefix + strconv.Itoa(frequency) }
|
|
func indentation_frequency(name string) (int, bool) {
|
|
if !strings.HasPrefix(name, indentationCuePrefix) {
|
|
return 0, false
|
|
}
|
|
frequency, err := strconv.Atoi(strings.TrimPrefix(name, indentationCuePrefix))
|
|
return frequency, err == nil && frequency >= 100 && frequency <= 2750
|
|
}
|
|
func indentation_tone_wav(frequency int) []byte {
|
|
return tone_wav(float64(frequency), 150*time.Millisecond, .7, 5*time.Millisecond)
|
|
}
|