Skip to main content

Sine Wave Generator

This example generates a sine wave to the audio output using the SineGeneratorNode. Frequency and amplitude can be adjusted by the setFrequency and setAmplitude methods.

import SwitchboardSDK

class SineWaveGeneratorExample {

let audioEngine = SBAudioEngine()
let audioGraph = SBAudioGraph()
let sineGeneratorNode = SBSineGeneratorNode()

init() {
audioGraph.connect(sineGeneratorNode, to: audioGraph.outputNode)

func setFrequency(_ newValue: Float) {
sineGeneratorNode.frequency = newValue

func setAmplitude(_ newValue: Float) {
sineGeneratorNode.amplitude = newValue