Random patch generator inspired by the Moog Sound Studio kit's dice game.
Includes DFAM, Mother-32 and Subharmonicon patch bays as custom UIView
instances.
You can create as many PatchBay
instances with PatchBayView
s as you want and apply auto-layout on them or embed them in stack views.
let dfam = PatchBayView<DFAM>(patchBay: DFAM())
let mother32 = PatchBayView<Mother32>(patchBay: Mother32())
let subharmonicon = PatchBayView<Subharmonicon>(patchBay: Subharmonicon())
You can use this protocol and create other synths.
- Create a final class conforming
PatchBay
, - Implement
PatchBay
protocol values. - Create the patch points inside an enum conforming
PatchPoint
, - Add the patch points as cases.
- Implement
PatchPoint
protocol values.
final class CustomSynth: PatchBay {
typealias PatchPoints = PB
var name: String = "My Custom Synth"
var colCount: Int = 2
var rowCount: Int = 1
enum PB: Int, PatchPoint {
case vco
case vcoOut
var type: PatchType {
switch self {
case .vco: return .input
case .vcoOut: return .output
}
}
var name: String {
switch self {
case .vco: return "VCO CV"
case .vcoOut: return "VCO OUT"
}
}
var patchable: Bool {
switch self {
case .vco: return true
case .vcoOut: return true
}
}
}
}
- Create an instance of
PatchGenerator
. - Add rule set for allowed patch point connections.
- Call
generatePatch()
function on the patch generator. - It returns a
Patch
struct which includes the input and outputPatchPoint
s inPatchable
format. - You can use the
highlight(patch: Patch)
function onPatchBayView
s for highlighting the patch points.
let generator = PatchGenerator()
generator.addRule(fromPatchBay: dfam, toPatchBay: dfam)
generator.addRule(fromPatchBay: dfam, toPatchBay: mother32)
generator.addRule(fromPatchBay: mother32, toPatchBay: dfam)
generator.addRule(fromPatchBay: mother32, toPatchBay: mother32)
let patch = generator.generatePatch()
dfam.highlight(patch: patch)
mother32.highlight(patch: patch)