Skip to content

Commit

Permalink
Now changing the frequency actually works
Browse files Browse the repository at this point in the history
  • Loading branch information
Snesnopic committed May 17, 2024
1 parent 566c7a8 commit 6971f25
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Morser/Model/VibrationEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,19 @@ class VibrationEngine: ObservableObject {
var dashPlayer: BeepPlayer?

func readMorseCode(morseCode: String) {

let soundFreq = Float(VibrationEngine.soundFrequency)
morseCodeIndex = 0
morseCodeString = morseCode
if VibrationEngine.soundEnabled && dotPlayer == nil && dashPlayer == nil {
dotPlayer = BeepPlayer(frequency: 600, duration: dotDuration)
dashPlayer = BeepPlayer(frequency: 600, duration: dashDuration)
dotPlayer = BeepPlayer(frequency: soundFreq, duration: dotDuration)
dashPlayer = BeepPlayer(frequency: soundFreq, duration: dashDuration)
}
triggerNextVibration()
}

func readMorseCode(sentence: Sentence) {
morseCodeIndex = 0
morseCodeString = sentence.sentence!.morseCode()
if VibrationEngine.soundEnabled && dotPlayer == nil && dashPlayer == nil {
dotPlayer = BeepPlayer(frequency: 600, duration: dotDuration)
dashPlayer = BeepPlayer(frequency: 600, duration: dashDuration)
}
triggerNextVibration() }
readMorseCode(morseCode: sentence.sentence!)
}
// Function to trigger vibrations based on Morse code
func triggerNextVibration() {
guard morseCodeIndex < morseCodeString.count else {
Expand Down Expand Up @@ -117,6 +112,8 @@ class VibrationEngine: ObservableObject {
morseCodeString = ""
vibrationTimer?.invalidate()
vibrationTimer = nil
dotPlayer = nil
dashPlayer = nil
}

/// - Tag: CreateEngine
Expand Down

0 comments on commit 6971f25

Please sign in to comment.