Skip to content

Commit

Permalink
Merge pull request #137 from NickCulbertson/AddStereoDelay
Browse files Browse the repository at this point in the history
Added Stereo Delay Example
  • Loading branch information
NickCulbertson authored Oct 30, 2023
2 parents d03d124 + d189365 commit 9bea0d4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ struct MasterView: View {
NavigationLink("Phase-Locked Vocoder", destination: PhaseLockedVocoderView())
NavigationLink("Playback Speed", destination: PlaybackSpeedView())
NavigationLink("Pitch Shifter", destination: PitchShifterView())
NavigationLink("Stereo Delay", destination: StereoDelayView())
NavigationLink("String Resonator", destination: StringResonatorView())
NavigationLink("Time / Pitch", destination: TimePitchView())
}
Group {
NavigationLink("Time / Pitch", destination: TimePitchView())
NavigationLink("Transient Shaper", destination: TransientShaperView())
NavigationLink("Tremolo", destination: TremoloView())
NavigationLink("Variable Delay", destination: VariableDelayView())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import AudioKit
import AudioKitEX
import AudioKitUI
import AVFoundation
import DunneAudioKit
import SoundpipeAudioKit
import SwiftUI

class StereoDelayConductor: ObservableObject, ProcessesPlayerInput {
let engine = AudioEngine()
let player = AudioPlayer()
let delay: StereoDelay
var dryWetMixer: DryWetMixer
let buffer: AVAudioPCMBuffer

init() {
buffer = Cookbook.sourceBuffer
player.buffer = buffer
player.isLooping = true

delay = StereoDelay(player)
dryWetMixer = DryWetMixer(player, delay)
engine.output = dryWetMixer
}
}

struct StereoDelayView: View {
@StateObject var conductor = StereoDelayConductor()

var body: some View {
VStack {
PlayerControls(conductor: conductor)
HStack {
ForEach(conductor.delay.parameters) {
ParameterRow(param: $0)
}
ParameterRow(param: conductor.dryWetMixer.parameters[0])
}
DryWetMixView(dry: conductor.player,
wet: conductor.delay,
mix: conductor.dryWetMixer)
}
.padding()
.cookbookNavBarTitle("Stereo Delay")
.onAppear {
conductor.start()
}
.onDisappear {
conductor.stop()
}
}
}

0 comments on commit 9bea0d4

Please sign in to comment.