Skip to content

Commit

Permalink
Add STK WIP Recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
NickCulbertson committed Dec 8, 2023
1 parent 5839f33 commit dd7a429
Show file tree
Hide file tree
Showing 12 changed files with 260 additions and 70 deletions.
17 changes: 17 additions & 0 deletions Cookbook/Cookbook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
5A7F40462B21FD06000A28F9 /* Waveform in Frameworks */ = {isa = PBXBuildFile; productRef = 5A7F40452B21FD06000A28F9 /* Waveform */; };
5A7F40492B21FE34000A28F9 /* PianoRoll in Frameworks */ = {isa = PBXBuildFile; productRef = 5A7F40482B21FE34000A28F9 /* PianoRoll */; };
5A7F404C2B220667000A28F9 /* STKAudioKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5A7F404B2B220667000A28F9 /* STKAudioKit */; };
5A7F40572B22774A000A28F9 /* MIDIKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5A7F40562B22774A000A28F9 /* MIDIKit */; };
C446DE542528D8E700138D0A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C446DE522528D8E700138D0A /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */

Expand All @@ -40,6 +41,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5A7F40572B22774A000A28F9 /* MIDIKit in Frameworks */,
5A7F404C2B220667000A28F9 /* STKAudioKit in Frameworks */,
5A7F40432B21F314000A28F9 /* Flow in Frameworks */,
5A7F40492B21FE34000A28F9 /* PianoRoll in Frameworks */,
Expand Down Expand Up @@ -133,6 +135,7 @@
5A7F40452B21FD06000A28F9 /* Waveform */,
5A7F40482B21FE34000A28F9 /* PianoRoll */,
5A7F404B2B220667000A28F9 /* STKAudioKit */,
5A7F40562B22774A000A28F9 /* MIDIKit */,
);
productName = Cookbook;
productReference = C446DE442528D8E600138D0A /* Cookbook.app */;
Expand Down Expand Up @@ -166,6 +169,7 @@
5A7F40442B21FD06000A28F9 /* XCRemoteSwiftPackageReference "Waveform" */,
5A7F40472B21FE34000A28F9 /* XCRemoteSwiftPackageReference "PianoRoll" */,
5A7F404A2B220667000A28F9 /* XCRemoteSwiftPackageReference "STKAudioKit" */,
5A7F40552B22774A000A28F9 /* XCRemoteSwiftPackageReference "MIDIKit" */,
);
productRefGroup = C446DE452528D8E600138D0A /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -431,6 +435,14 @@
minimumVersion = 5.5.4;
};
};
5A7F40552B22774A000A28F9 /* XCRemoteSwiftPackageReference "MIDIKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/orchetect/MIDIKit";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.9.4;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand Down Expand Up @@ -458,6 +470,11 @@
package = 5A7F404A2B220667000A28F9 /* XCRemoteSwiftPackageReference "STKAudioKit" */;
productName = STKAudioKit;
};
5A7F40562B22774A000A28F9 /* MIDIKit */ = {
isa = XCSwiftPackageProductDependency;
package = 5A7F40552B22774A000A28F9 /* XCRemoteSwiftPackageReference "MIDIKit" */;
productName = MIDIKit;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = C446DE3C2528D8E600138D0A /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ struct MasterView: View {
NavigationLink("Input Device Demo", destination: InputDeviceDemoView())
NavigationLink("MIDI Port Test", destination: MIDIPortTestView())
NavigationLink("Polyphonic Oscillator", destination: PolyphonicOscillatorView())
NavigationLink("Polyphonic STK + MIDIKit", destination: PolyphonicSTKView())
NavigationLink("Roland Tb303 Filter", destination: RolandTB303FilterView())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,13 @@ struct ArpeggiatorView: View {
@Environment(\.colorScheme) var colorScheme

var body: some View {
VStack{
NodeOutputView(conductor.instrument)
HStack {
CookbookKnob(text: "BPM", parameter: $conductor.tempo, range: 20.0...250.0)
CookbookKnob(text: "Length", parameter: $conductor.noteLength, range: 0.0...1.0)
}
CookbookKeyboard(noteOn: conductor.noteOn,
noteOff: conductor.noteOff)
NodeOutputView(conductor.instrument)
HStack {
CookbookKnob(text: "BPM", parameter: $conductor.tempo, range: 20.0...250.0)
CookbookKnob(text: "Length", parameter: $conductor.noteLength, range: 0.0...1.0)
}
CookbookKeyboard(noteOn: conductor.noteOn,
noteOff: conductor.noteOff)
.cookbookNavBarTitle("Arpeggiator")
.onAppear {
conductor.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ struct AudioKit3DView: View {
.onDisappear {
viewModel.conductor.stop()
}
.background(colorScheme == .dark ?
Color.clear : Color(red: 0.9, green: 0.9, blue: 0.9))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,28 @@ struct InstrumentSFZView: View {
@Environment(\.colorScheme) var colorScheme

var body: some View {
VStack{
HStack {
ForEach(0...7, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
HStack {
ForEach(8...15, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
HStack {
ForEach(16...23, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
HStack {
ForEach(24...30, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
CookbookKeyboard(noteOn: conductor.noteOn,
noteOff: conductor.noteOff)
}
HStack {
ForEach(0...7, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
HStack {
ForEach(8...15, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
HStack {
ForEach(16...23, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
HStack {
ForEach(24...30, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
CookbookKeyboard(noteOn: conductor.noteOn,
noteOff: conductor.noteOff)
.cookbookNavBarTitle("Instrument SFZ")
.onAppear {
conductor.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ struct SpriteKitAudioView: View {
VStack {
SpriteView(scene: scene).frame(maxWidth: .infinity, maxHeight: .infinity).ignoresSafeArea()
}
.cookbookNavBarTitle("SpriteKit Audio")
.onAppear {
conductor.start()
}.onDisappear {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,20 @@ struct DunneSynthView: View {
@Environment(\.colorScheme) var colorScheme

var body: some View {
VStack{
NodeOutputView(conductor.instrument)
HStack {
ForEach(0...6, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
HStack {
ForEach(7...13, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
CookbookKeyboard(noteOn: conductor.noteOn,
noteOff: conductor.noteOff)
}
NodeOutputView(conductor.instrument)
HStack {
ForEach(0...6, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
HStack {
ForEach(7...13, id: \.self){
ParameterRow(param: conductor.instrument.parameters[$0])
}
}.padding(5)
CookbookKeyboard(noteOn: conductor.noteOn,
noteOff: conductor.noteOff)
.cookbookNavBarTitle("Dunne Synth")
.onAppear {
conductor.start()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ struct InputDeviceDemoView: View {
})
.keyboardShortcut(.space, modifiers: [])
}
.cookbookNavBarTitle("Input Device Demo")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ struct MIDIPortTestView: View {
}
}
}
.cookbookNavBarTitle("MIDI Port Test")
.onAppear {
conductor.start()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PolyphonicOscillatorConductor: ObservableObject, HasAudioEngine {
var notes = Array(repeating: 0, count: 11)
var osc = [Oscillator(), Oscillator(), Oscillator(), Oscillator(), Oscillator(),
Oscillator(), Oscillator(), Oscillator(), Oscillator(), Oscillator(), Oscillator()]

func noteOn(pitch: Pitch, point _: CGPoint) {
for num in 0 ... 10 {
if notes[num] == 0 {
Expand All @@ -23,7 +23,7 @@ class PolyphonicOscillatorConductor: ObservableObject, HasAudioEngine {
}
}
}

func noteOff(pitch: Pitch) {
for num in 0 ... 10 {
if notes[num] == pitch.intValue {
Expand All @@ -33,7 +33,7 @@ class PolyphonicOscillatorConductor: ObservableObject, HasAudioEngine {
}
}
}

init() {
for num in 0 ... 10 {
osc[num].amplitude = 0.0
Expand All @@ -47,23 +47,21 @@ class PolyphonicOscillatorConductor: ObservableObject, HasAudioEngine {
struct PolyphonicOscillatorView: View {
@StateObject var conductor = PolyphonicOscillatorConductor()
@Environment(\.colorScheme) var colorScheme

var body: some View {
VStack {
if conductor.engine.output != nil {
NodeOutputView(conductor.engine.output!)
}
CookbookKeyboard(noteOn: conductor.noteOn,
noteOff: conductor.noteOff)

}.cookbookNavBarTitle("Polyphonic Oscillator")
.onAppear {
conductor.start()
}
.onDisappear {
conductor.stop()
}
.background(colorScheme == .dark ?
Color.clear : Color(red: 0.9, green: 0.9, blue: 0.9))
if conductor.engine.output != nil {
NodeOutputView(conductor.engine.output!)
}
CookbookKeyboard(noteOn: conductor.noteOn,
noteOff: conductor.noteOff)
.cookbookNavBarTitle("Polyphonic Oscillator")
.onAppear {
conductor.start()
}
.onDisappear {
conductor.stop()
}
.background(colorScheme == .dark ?
Color.clear : Color(red: 0.9, green: 0.9, blue: 0.9))
}
}
Loading

0 comments on commit dd7a429

Please sign in to comment.