-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
166 additions
and
267 deletions.
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
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,18 @@ | ||
import AudioKit | ||
import AVFoundation | ||
import SwiftUI | ||
|
||
struct ADSRWidget: UIViewRepresentable { | ||
typealias UIViewType = ADSRView | ||
var callback: (AUValue, AUValue, AUValue, AUValue) -> Void | ||
|
||
func makeUIView(context _: Context) -> ADSRView { | ||
let view = ADSRView(callback: callback) | ||
view.bgColor = .systemBackground | ||
return view | ||
} | ||
|
||
func updateUIView(_: ADSRView, context _: Context) { | ||
// | ||
} | ||
} |
261 changes: 0 additions & 261 deletions
261
Sources/AudioKitUI/Controls/MultitouchGestureRecognizer.swift
This file was deleted.
Oops, something went wrong.
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,76 @@ | ||
// Copyright AudioKit. All Rights Reserved. Revision History at http://github.com/AudioKit/AudioKitUI/ | ||
|
||
import AudioKit | ||
import Controls | ||
import SwiftUI | ||
import CoreMIDI | ||
|
||
/// Hack to get SwiftUI to poll and refresh our UI. | ||
class Refresher: ObservableObject { | ||
@Published var version = 0 | ||
} | ||
|
||
public struct ParameterEditor2: View { | ||
var param: NodeParameter | ||
@StateObject var refresher = Refresher() | ||
|
||
public init(param: NodeParameter) { | ||
self.param = param | ||
} | ||
|
||
func floatToDoubleRange(_ floatRange: ClosedRange<Float>) -> ClosedRange<Double> { | ||
Double(floatRange.lowerBound) ... Double(floatRange.upperBound) | ||
} | ||
|
||
func getBinding() -> Binding<Float> { | ||
Binding( | ||
get: { param.value }, | ||
set: { param.value = $0; refresher.version += 1} | ||
) | ||
} | ||
|
||
func getIntBinding() -> Binding<Int> { | ||
Binding(get: { Int(param.value) }, set: { param.value = AUValue($0); refresher.version += 1 }) | ||
} | ||
|
||
func intValues() -> [Int] { | ||
Array(Int(param.range.lowerBound) ... Int(param.range.upperBound)) | ||
} | ||
var format: String { | ||
if (param.range.upperBound - param.range.lowerBound) > 20 { | ||
return "%0.0f" | ||
} else { | ||
return "%0.2f" | ||
} | ||
} | ||
|
||
public var body: some View { | ||
VStack(alignment: .center) { | ||
Text(param.def.name).font(.title2) | ||
Text("\(String(format: format, param.value))") | ||
|
||
switch param.def.unit { | ||
case .boolean: | ||
Toggle(isOn: Binding(get: { param.value == 1.0 }, set: { | ||
param.value = $0 ? 1.0 : 0.0; refresher.version += 1 | ||
}), label: { Text(param.def.name) }) | ||
case .indexed: | ||
if param.range.upperBound - param.range.lowerBound < 5 { | ||
Picker(param.def.name, selection: getIntBinding()) { | ||
ForEach(intValues(), id: \.self) { value in | ||
Text("\(value)").tag(value) | ||
} | ||
} | ||
.pickerStyle(.segmented) | ||
} else { | ||
SmallKnob(value: getBinding(), range: param.range) | ||
.frame(maxHeight: 200) | ||
|
||
} | ||
default: | ||
SmallKnob(value: getBinding(), range: param.range) | ||
.frame(maxHeight: 200) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.