Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Stereo Delay Example #137

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
}
}
Loading