-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from NickCulbertson/AddStereoDelay
Added Stereo Delay Example
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Cookbook/CookbookCommon/Sources/CookbookCommon/Recipes/Effects/StereoDelay.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |