iOS 0.5.0: hand-built editors (Tape Delay, Tape Engine, Mix Tightener, Granular scope, Wavetable tables, Grain Cloud source)
Effect visualisation through the C++ effect, engine and AU; custom wavetables and grain sources load and persist with the song; the app's slot editor hosts the file picker for bespoke views. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3b035d6a7d
commit
435305e42a
@@ -36,6 +36,20 @@ extension DeviceDataSource {
|
||||
func setHiddenValue(_ value: String, key: String) {}
|
||||
}
|
||||
|
||||
/// A host's file picker for bespoke views (the app's slot editor provides one: on
|
||||
/// iOS 15 a .fileImporter nested inside another one may not present). A view
|
||||
/// calls it with what to do with the picked URL; without one (the plugins) it
|
||||
/// uses its own .fileImporter.
|
||||
private struct DeviceFilePickerKey: EnvironmentKey {
|
||||
static let defaultValue: ((@escaping (URL) -> Void) -> Void)? = nil
|
||||
}
|
||||
extension EnvironmentValues {
|
||||
var deviceFilePicker: ((@escaping (URL) -> Void) -> Void)? {
|
||||
get { self[DeviceFilePickerKey.self] }
|
||||
set { self[DeviceFilePickerKey.self] = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
/// Hand-built pieces of device editors (the Android app's bespoke editors), by
|
||||
/// device. DeviceEditor asks here first and falls back to the card layout. Each
|
||||
/// device's views live in their own file in this folder.
|
||||
|
||||
@@ -3,8 +3,99 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// The Delay's hand-built editor parts (stub: card layout until ported).
|
||||
/// The Tape Delay's hand-built editor (Android's DelayEditor): four tape heads side
|
||||
/// by side, each an on/off toggle above a vertical division fader that snaps hard to
|
||||
/// the DelayDivisions steps (1/1 at the top … 1/16T at the bottom; a longer division
|
||||
/// fills taller), then the Loop card (Feedback / Mix / Tape). Feedback's maximum is
|
||||
/// the DSP's ceiling (0.9), so the loop can't run away.
|
||||
@MainActor
|
||||
enum DelayBespoke {
|
||||
static func body(_ model: DeviceModel) -> AnyView? { nil }
|
||||
static func body(_ model: DeviceModel) -> AnyView? { AnyView(DelayEditorView(model: model)) }
|
||||
|
||||
static let heads = 4
|
||||
/// Android's DelayDivisions labels, longest first (used when DeviceLayouts.json is missing).
|
||||
static let fallbackDivisions = ["1/1", "1/2.", "1/2", "1/4.", "1/2T", "1/4", "1/8.",
|
||||
"1/4T", "1/8", "1/16.", "1/8T", "1/16", "1/16T"]
|
||||
static var divisions: [String] { Layouts.file?.delayDivisions ?? fallbackDivisions }
|
||||
/// Android's default theme's playhead green (the selected-step band).
|
||||
static let band = Color(red: 0x7C / 255.0, green: 0xFC / 255.0, blue: 0x9A / 255.0)
|
||||
}
|
||||
|
||||
private struct DelayEditorView: View {
|
||||
@ObservedObject var model: DeviceModel
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
Text("Tape heads — drag a fader to set its time; tap the number to switch it off/on:")
|
||||
.font(Theme.mono(11)).foregroundColor(Theme.dim)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
HStack(alignment: .top, spacing: 8) {
|
||||
ForEach(0..<DelayBespoke.heads, id: \.self) { h in
|
||||
DelayHeadView(model: model, head: h)
|
||||
}
|
||||
}
|
||||
CardView(panel: LayoutPanel(title: "Loop", tone: .OUT, keys: ["feedback", "drywet", "tape"],
|
||||
labels: ["drywet": "Mix", "tape": "Tape"]),
|
||||
model: model)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One tape head: the head number as an on/off toggle, the hard-snapping division
|
||||
/// fader, and the division's name.
|
||||
private struct DelayHeadView: View {
|
||||
@ObservedObject var model: DeviceModel
|
||||
let head: Int
|
||||
|
||||
var body: some View {
|
||||
let onKey = "head\(head)On", divKey = "head\(head)Div"
|
||||
let names = DelayBespoke.divisions
|
||||
let steps = model.params[divKey].map { Int($0.max) + 1 } ?? names.count
|
||||
let on = model.value(onKey) >= 0.5
|
||||
let idx = Swift.min(steps - 1, Swift.max(0, Int(model.value(divKey))))
|
||||
let border = on ? Theme.accent : Theme.grid
|
||||
|
||||
VStack(spacing: 4) {
|
||||
Text("\(head + 1)").font(Theme.mono(13))
|
||||
.foregroundColor(on ? Theme.accent : Theme.dim)
|
||||
.frame(maxWidth: .infinity, minHeight: 26, maxHeight: 26)
|
||||
.background(on ? Theme.accent.opacity(0.22) : Theme.surface)
|
||||
.overlay(Rectangle().stroke(border, lineWidth: 1))
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { model.set(onKey, on ? 0 : 1) }
|
||||
|
||||
GeometryReader { g in
|
||||
Canvas { ctx, size in
|
||||
let stepH = size.height / CGFloat(steps)
|
||||
let top = CGFloat(idx) * stepH
|
||||
// Fill from the bottom up to the selected step: longer = taller.
|
||||
ctx.fill(Path(CGRect(x: 0, y: top, width: size.width, height: size.height - top)),
|
||||
with: .color((on ? Theme.accent : Theme.grid).opacity(0.45)))
|
||||
var lines = Path()
|
||||
for s in 1..<steps {
|
||||
let y = CGFloat(s) * stepH
|
||||
lines.move(to: CGPoint(x: 0, y: y)); lines.addLine(to: CGPoint(x: size.width, y: y))
|
||||
}
|
||||
ctx.stroke(lines, with: .color(Theme.grid.opacity(0.4)), lineWidth: 0.5)
|
||||
// The selected step's band.
|
||||
ctx.fill(Path(CGRect(x: 0, y: top, width: size.width, height: stepH)),
|
||||
with: .color((on ? DelayBespoke.band : Theme.dim).opacity(0.5)))
|
||||
}
|
||||
.background(Theme.surface)
|
||||
.overlay(Rectangle().stroke(border, lineWidth: 1))
|
||||
.contentShape(Rectangle())
|
||||
.gesture(DragGesture(minimumDistance: 0).onChanged { d in
|
||||
// Tap or drag: snap to the step under the finger.
|
||||
let i = Int(d.location.y / Swift.max(1, g.size.height) * CGFloat(steps))
|
||||
let snapped = Swift.min(steps - 1, Swift.max(0, i))
|
||||
if snapped != Int(model.value(divKey)) { model.set(divKey, Float(snapped)) }
|
||||
})
|
||||
}
|
||||
.frame(height: 150)
|
||||
|
||||
Text(names[Swift.min(names.count - 1, idx)]).font(Theme.mono(10))
|
||||
.foregroundColor(on ? Theme.text : Theme.dim)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,144 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
/// The GrainCloud's hand-built editor parts (stub: card layout until ported).
|
||||
/// A sample's length beside its peaks (the source strip's caption). Both backends
|
||||
/// adopt it; a data source without it just shows no length.
|
||||
@MainActor
|
||||
protocol SampleLengthSource: AnyObject {
|
||||
/// Seconds of the sample the setting [key] names, or nil.
|
||||
func sampleSeconds(key: String) -> Double?
|
||||
}
|
||||
|
||||
/// The Grain Cloud's source strip (Android's GrainCloudEditor.kt): load a WAV (or
|
||||
/// SF2/XI) as the cloud's own source, and see the source with its START..END region
|
||||
/// lit. The settings themselves are the card pages below it. (RECORD isn't ported.)
|
||||
@MainActor
|
||||
enum GrainCloudBespoke {
|
||||
static func header(_ model: DeviceModel) -> AnyView? { nil }
|
||||
static func header(_ model: DeviceModel) -> AnyView? { AnyView(GrainSourceStrip(model: model)) }
|
||||
|
||||
static let buckets = 300
|
||||
|
||||
/// Peaks by source (a built-in source's name, or a custom sample id): each
|
||||
/// sample's peaks are computed once, not per drawing.
|
||||
private static var cache: [String: (peaks: [Float], seconds: Double?)] = [:]
|
||||
|
||||
static func source(key: String, data: DeviceDataSource?) -> (peaks: [Float], seconds: Double?)? {
|
||||
if let c = cache[key] { return c }
|
||||
guard let p = data?.samplePeaks(key: "source", buckets: buckets), !p.isEmpty else { return nil }
|
||||
let c = (peaks: p, seconds: (data as? SampleLengthSource)?.sampleSeconds(key: "source"))
|
||||
if cache.count > 32 { cache.removeAll() }
|
||||
cache[key] = c
|
||||
return c
|
||||
}
|
||||
}
|
||||
|
||||
struct GrainSourceStrip: View {
|
||||
@ObservedObject var model: DeviceModel
|
||||
@State private var pickerShown = false
|
||||
@Environment(\.deviceFilePicker) private var hostPicker
|
||||
@State private var importError: String?
|
||||
/// Bumped while a built-in source is still being rendered, to look again.
|
||||
@State private var retry = 0
|
||||
|
||||
var body: some View {
|
||||
let name = model.choice("source")
|
||||
let custom = name == "Custom"
|
||||
let id = custom ? model.data?.hiddenValue("sfSample") : nil
|
||||
let unloaded = custom && id == nil
|
||||
let src = unloaded ? nil : GrainCloudBespoke.source(key: custom ? "C|" + (id ?? "") : "F|" + name, data: model.data)
|
||||
let caption: String = {
|
||||
if unloaded { return "Source: your own — load a sound." }
|
||||
guard let s = src else { return "Source: \(name) (preparing…)" }
|
||||
let label = custom ? "your own" : name
|
||||
return s.seconds.map { String(format: "Source: %@ · %.1f s", label, $0) } ?? "Source: \(label)"
|
||||
}()
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack(spacing: 8) {
|
||||
Text("LOAD WAV").font(Theme.mono(12)).foregroundColor(Theme.accent)
|
||||
.padding(.horizontal, 10).padding(.vertical, 6)
|
||||
.background(Theme.surface)
|
||||
.overlay(Rectangle().stroke(Theme.accent.opacity(0.6), lineWidth: 1))
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { if let pick = hostPicker { pick { url in load(url) } } else { pickerShown = true } }
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
Text(caption).font(Theme.mono(10)).foregroundColor(Theme.dim)
|
||||
if let s = src {
|
||||
let start = CGFloat(model.value("start")), end = CGFloat(model.value("end"))
|
||||
Canvas { ctx, size in draw(s.peaks, start: start, end: end, in: ctx, size: size) }
|
||||
.frame(maxWidth: .infinity, minHeight: 64, maxHeight: 64)
|
||||
.background(Theme.surface)
|
||||
}
|
||||
}
|
||||
// The completion needs nothing but the picked URL (iOS 15 resets the
|
||||
// presentation binding before calling it).
|
||||
.fileImporter(isPresented: $pickerShown, allowedContentTypes: [.item], allowsMultipleSelection: false) { result in
|
||||
guard case .success(let urls) = result, let url = urls.first else { return }
|
||||
load(url)
|
||||
}
|
||||
.alert("Import failed", isPresented: Binding(get: { importError != nil }, set: { if !$0 { importError = nil } }),
|
||||
actions: { Button("OK") { importError = nil } }, message: { Text(importError ?? "") })
|
||||
.task(id: retry) {
|
||||
guard src == nil, !unloaded, retry < 60 else { return }
|
||||
try? await Task.sleep(nanoseconds: 300_000_000)
|
||||
retry += 1
|
||||
}
|
||||
}
|
||||
|
||||
private func draw(_ peaks: [Float], start: CGFloat, end: CGFloat, in ctx: GraphicsContext, size: CGSize) {
|
||||
let a = Swift.min(start, end) * size.width, b = Swift.max(start, end) * size.width
|
||||
ctx.fill(Path(CGRect(x: a, y: 0, width: b - a, height: size.height)), with: .color(Theme.accent.opacity(0.18)))
|
||||
let bw = size.width / CGFloat(peaks.count), mid = size.height / 2
|
||||
var path = Path()
|
||||
for (i, p) in peaks.enumerated() {
|
||||
let x = (CGFloat(i) + 0.5) * bw, h = Swift.max(0.5, CGFloat(p) * mid)
|
||||
path.move(to: CGPoint(x: x, y: mid - h))
|
||||
path.addLine(to: CGPoint(x: x, y: mid + h))
|
||||
}
|
||||
ctx.stroke(path, with: .color(Theme.text), lineWidth: 1)
|
||||
}
|
||||
|
||||
private func load(_ url: URL) {
|
||||
guard let data = model.data else { importError = "Not available here yet."; return }
|
||||
if let err = data.loadFile(url, kind: "grainSource") { importError = err; return }
|
||||
// The cloud now plays its own source; show that (the backend wrote the same).
|
||||
if let i = model.params["source"]?.choices.firstIndex(of: "Custom") { model.set("source", Float(i)) }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - plug-in backend
|
||||
|
||||
extension AUDataSource: SampleLengthSource {
|
||||
/// The built-in source the `source` setting names (no sample store for your own yet).
|
||||
private func builtInSource(_ key: String) -> String? {
|
||||
guard key == "source", au.toolboxType == "GRAIN_CLOUD",
|
||||
let p = au.parameterTree?.allParameters.first(where: { $0.identifier == "source" }),
|
||||
let names = p.valueStrings, !names.isEmpty else { return nil }
|
||||
let name = names[Swift.max(0, Swift.min(names.count - 1, Int(p.value.rounded())))]
|
||||
return name == "Custom" ? nil : name
|
||||
}
|
||||
|
||||
func samplePeaks(key: String, buckets: Int) -> [Float]? {
|
||||
guard let name = builtInSource(key),
|
||||
let d = SizzleDeviceAU.grainSourcePeaks(named: name, buckets: buckets, blocking: Snapshot.active) else { return nil }
|
||||
return WavetableBespoke.floats(d)
|
||||
}
|
||||
|
||||
func sampleSeconds(key: String) -> Double? {
|
||||
guard let name = builtInSource(key) else { return nil }
|
||||
let s = SizzleDeviceAU.grainSourceSeconds(named: name)
|
||||
return s > 0 ? s : nil
|
||||
}
|
||||
|
||||
/// Wavetables and Grain Cloud sources come from the app's sample store, which
|
||||
/// the plug-in doesn't share yet.
|
||||
func loadFile(_ url: URL, kind: String) -> String? {
|
||||
switch kind {
|
||||
case "wavetable": return "Load your own wavetables in the Sizzle app for now; the plug-in plays the built-in tables."
|
||||
case "grainSource": return "Load your own sounds in the Sizzle app for now; the plug-in plays the built-in sources."
|
||||
default: return "Not available here yet."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,136 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// The Granular's hand-built editor parts (stub: card layout until ported).
|
||||
/// The Granular Glitch's editor (Android's GranularEditor): a dotted oscilloscope of
|
||||
/// the sound passing through with the granular read head drawn as a jumping
|
||||
/// playhead, and one horizontal Intensity slider below. The scope only shows data
|
||||
/// while the effect is running on signal (a mixer channel's FX in the app; render
|
||||
/// resources allocated in the plugin).
|
||||
@MainActor
|
||||
enum GranularBespoke {
|
||||
static func body(_ model: DeviceModel) -> AnyView? { nil }
|
||||
static func body(_ model: DeviceModel) -> AnyView? { AnyView(GranularEditorView(model: model)) }
|
||||
}
|
||||
|
||||
private struct GranularEditorView: View {
|
||||
@ObservedObject var model: DeviceModel
|
||||
|
||||
var body: some View {
|
||||
let intensity = Swift.min(Swift.max(model.value("intensity"), 0), 1)
|
||||
VStack(spacing: 8) {
|
||||
GranularScope(data: model.data)
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 160)
|
||||
Text("Intensity \(Int((intensity * 100).rounded()))%")
|
||||
.font(Theme.mono(12)).foregroundColor(Theme.accent)
|
||||
HorizontalSlider(value: intensity) { model.set("intensity", Swift.min(Swift.max($0, 0), 1)) }
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 40)
|
||||
Text("Low = occasional stutters · High = constant glitch & octave jumps.")
|
||||
.font(Theme.mono(10)).foregroundColor(Theme.dim)
|
||||
.multilineTextAlignment(.center)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The scope, polled from the data source once per display frame.
|
||||
private struct GranularScope: View {
|
||||
let data: DeviceDataSource?
|
||||
private static let capacity = 128 // the effect fills up to its own scope size (96)
|
||||
|
||||
var body: some View {
|
||||
TimelineView(.animation) { _ in
|
||||
let scope = data?.effectScope(capacity: Self.capacity)
|
||||
ZStack {
|
||||
Canvas { ctx, size in draw(scope, in: &ctx, size: size) }
|
||||
if scope == nil {
|
||||
Text("Add to a mixer channel's FX and play to see the scope.")
|
||||
.font(Theme.mono(11)).foregroundColor(Theme.dim)
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal, 8)
|
||||
}
|
||||
}
|
||||
}
|
||||
.background(Theme.background)
|
||||
.overlay(Rectangle().stroke(Theme.grid, lineWidth: 1))
|
||||
}
|
||||
|
||||
private func draw(_ scope: (samples: [Float], playhead: Float)?, in ctx: inout GraphicsContext, size: CGSize) {
|
||||
let w = size.width, h = size.height
|
||||
let cy = h * 0.5, amp = h * 0.42
|
||||
var base = Path()
|
||||
base.move(to: CGPoint(x: 0, y: cy))
|
||||
base.addLine(to: CGPoint(x: w, y: cy))
|
||||
ctx.stroke(base, with: .color(Theme.grid), lineWidth: 1)
|
||||
guard let s = scope, s.samples.count > 1 else { return }
|
||||
|
||||
// Dotted waveform of the signal passing through.
|
||||
let n = s.samples.count
|
||||
let step = w / CGFloat(n - 1)
|
||||
var dots = Path()
|
||||
for k in 0..<n {
|
||||
let y = cy - CGFloat(Swift.min(Swift.max(s.samples[k], -1), 1)) * amp
|
||||
dots.addEllipse(in: CGRect(x: CGFloat(k) * step - 1.5, y: y - 1.5, width: 3, height: 3))
|
||||
}
|
||||
ctx.fill(dots, with: .color(Theme.dim))
|
||||
|
||||
// Jumping playhead over the scope.
|
||||
let ph = s.playhead
|
||||
if ph >= 0 && ph <= 1 {
|
||||
let px = CGFloat(ph) * w
|
||||
var line = Path()
|
||||
line.move(to: CGPoint(x: px, y: 0))
|
||||
line.addLine(to: CGPoint(x: px, y: h))
|
||||
ctx.stroke(line, with: .color(Theme.accent), lineWidth: 2)
|
||||
ctx.fill(Path(ellipseIn: CGRect(x: px - 3, y: cy - 3, width: 6, height: 6)), with: .color(Theme.accent))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A horizontal fill-from-left slider like Android's retro faders: tap or drag to set.
|
||||
private struct HorizontalSlider: View {
|
||||
let value: Float
|
||||
let onChange: (Float) -> Void
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
let w = geo.size.width
|
||||
let frac = CGFloat(Swift.min(Swift.max(value, 0.001), 1))
|
||||
ZStack(alignment: .leading) {
|
||||
Theme.background
|
||||
HStack(spacing: 0) {
|
||||
Spacer(minLength: 0)
|
||||
Theme.accent.frame(width: 3) // thumb
|
||||
}
|
||||
.frame(width: Swift.max(w * frac, 3))
|
||||
.background(Theme.accent.opacity(0.30))
|
||||
}
|
||||
.overlay(Rectangle().stroke(Theme.grid, lineWidth: 1))
|
||||
.contentShape(Rectangle())
|
||||
.gesture(DragGesture(minimumDistance: 0).onChanged { g in
|
||||
if w > 0 { onChange(Float(g.location.x / w)) }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - plugin backend
|
||||
|
||||
/// The effect AU's scope (SizzleEffectAU, channel 0). SizzleEffectAU.h isn't in the
|
||||
/// Swift bridging headers, so its two methods are declared here and reached by
|
||||
/// selector; any other device AU doesn't respond and has no scope.
|
||||
@objc private protocol EffectScopeAU {
|
||||
func copyEffectScope(_ out: UnsafeMutablePointer<Float>, capacity: Int) -> Int
|
||||
var effectPlayhead: Float { get }
|
||||
}
|
||||
|
||||
extension AUDataSource {
|
||||
func effectScope(capacity: Int) -> (samples: [Float], playhead: Float)? {
|
||||
guard capacity > 0, au.responds(to: #selector(EffectScopeAU.copyEffectScope(_:capacity:))) else { return nil }
|
||||
let src = unsafeBitCast(au, to: EffectScopeAU.self)
|
||||
var buf = [Float](repeating: 0, count: capacity)
|
||||
let n = buf.withUnsafeMutableBufferPointer { src.copyEffectScope($0.baseAddress!, capacity: $0.count) }
|
||||
guard n >= 0 else { return nil }
|
||||
return (Array(buf.prefix(n)), src.effectPlayhead)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,96 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// The MixTightener's hand-built editor parts (stub: card layout until ported).
|
||||
/// The Mix Tightener's hand-built editor (Android's MixTightenerEditor): four
|
||||
/// vertical faders, bottom = off, top = full.
|
||||
/// - Strength: the master amount of the EQ → compressor → limiter chain (a parameter).
|
||||
/// - EQ / Comp / Limit: per-stage trims (`eqAmt`, `compAmt`, `limAmt`). They aren't
|
||||
/// ParamSpecs, so they go through the data source's hidden values (song slot or AU
|
||||
/// state); each stage's amount in the DSP is Strength × its trim. A missing trim
|
||||
/// reads as 1, like MixTightener.cpp.
|
||||
@MainActor
|
||||
enum MixTightenerBespoke {
|
||||
static func body(_ model: DeviceModel) -> AnyView? { nil }
|
||||
static func body(_ model: DeviceModel) -> AnyView? { AnyView(MixTightenerEditorView(model: model)) }
|
||||
|
||||
static let trims: Set<String> = ["eqAmt", "compAmt", "limAmt"]
|
||||
|
||||
/// A trim's value (0..1). AUDataSource doesn't forward hidden values yet, so the
|
||||
/// AU is asked directly.
|
||||
static func trim(_ model: DeviceModel, _ key: String) -> Float {
|
||||
let text: String?
|
||||
if let au = (model.data as? AUDataSource)?.au { text = au.hiddenValue(forKey: key) }
|
||||
else { text = model.data?.hiddenValue(key) }
|
||||
return Swift.min(1, Swift.max(0, text.flatMap { Float($0.trimmingCharacters(in: .whitespaces)) } ?? 1))
|
||||
}
|
||||
|
||||
static func setTrim(_ model: DeviceModel, _ key: String, _ v: Float) {
|
||||
let text = String(Swift.min(1, Swift.max(0, v)))
|
||||
if let au = (model.data as? AUDataSource)?.au { au.setHiddenValue(text, forKey: key) }
|
||||
else { model.data?.setHiddenValue(text, key: key) }
|
||||
}
|
||||
}
|
||||
|
||||
private struct MixTightenerEditorView: View {
|
||||
@ObservedObject var model: DeviceModel
|
||||
/// Hidden values aren't published by the model: bumped after a trim write so the
|
||||
/// faders re-read them (presets and parameter changes re-render via the model).
|
||||
@State private var trimRevision = 0
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 10) {
|
||||
Text("Preset-driven EQ → 3-band compressor → limiter. Pick a preset, then set the master Strength and trim each stage:")
|
||||
.font(Theme.mono(11)).foregroundColor(Theme.dim).multilineTextAlignment(.center)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
HStack(spacing: 8) {
|
||||
fader("strength", "STRENGTH")
|
||||
fader("eqAmt", "EQ")
|
||||
fader("compAmt", "COMP")
|
||||
fader("limAmt", "LIMIT")
|
||||
}
|
||||
.frame(height: 268)
|
||||
Text("Bottom = off · Top = full. Each stage = Strength × its fader.")
|
||||
.font(Theme.mono(10)).foregroundColor(Theme.dim).multilineTextAlignment(.center)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
.padding(.top, 4)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
|
||||
private func fader(_ key: String, _ label: String) -> some View {
|
||||
let hidden = MixTightenerBespoke.trims.contains(key)
|
||||
let value = hidden ? MixTightenerBespoke.trim(model, key) : Swift.min(1, Swift.max(0, model.value(key)))
|
||||
return MixTightenerFader(label: label, value: value) { v in
|
||||
if hidden { MixTightenerBespoke.setTrim(model, key, v); trimRevision &+= 1 }
|
||||
else { model.set(key, v) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One labelled vertical fader: tap or drag to set (absolute position).
|
||||
private struct MixTightenerFader: View {
|
||||
let label: String
|
||||
let value: Float
|
||||
let onChange: (Float) -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 4) {
|
||||
Text(label).font(Theme.mono(11)).foregroundColor(Theme.accent).lineLimit(1).minimumScaleFactor(0.7)
|
||||
Text("\(Int((value * 100).rounded()))%").font(Theme.mono(12)).foregroundColor(Theme.text)
|
||||
GeometryReader { g in
|
||||
let h = g.size.height
|
||||
let fill = h * CGFloat(Swift.max(0.001, value))
|
||||
ZStack(alignment: .bottom) {
|
||||
Rectangle().fill(Theme.background)
|
||||
Rectangle().fill(Theme.accent.opacity(0.30)).frame(height: fill)
|
||||
Rectangle().fill(Theme.accent).frame(height: 3).offset(y: -Swift.max(0, fill - 3))
|
||||
}
|
||||
.overlay(Rectangle().stroke(Theme.grid, lineWidth: 1))
|
||||
.contentShape(Rectangle())
|
||||
.gesture(DragGesture(minimumDistance: 0).onChanged { d in
|
||||
onChange(Float(1 - Swift.min(1, Swift.max(0, d.location.y / Swift.max(1, h)))))
|
||||
})
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,191 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// The TapeEngine's hand-built editor parts (stub: card layout until ported).
|
||||
/// The Tape Engine's hand-built editor (Android's TapeEngineEditor): a reel-to-reel
|
||||
/// transport, two NAB reels feeding tape under tension down to a playhead block
|
||||
/// between them, then round knobs for wow, flutter, hiss and the wow's tempo sync.
|
||||
///
|
||||
/// Press and hold a reel to brake the tape. Like Android, the brake is the `speed`
|
||||
/// parameter: pressing writes 0.5 and releasing writes 1 through DeviceModel.set (an
|
||||
/// AU parameter in the plugin, the slot's value in the app). TapeEngine.cpp reads
|
||||
/// `speed` as its target and glides its read rate toward it (SPEED_GLIDE per sample,
|
||||
/// ≈0.19 s at 44.1 kHz), so the pitch dives and springs back; the reels ease toward
|
||||
/// the same target at the same pace.
|
||||
@MainActor
|
||||
enum TapeEngineBespoke {
|
||||
static func body(_ model: DeviceModel) -> AnyView? { nil }
|
||||
static func body(_ model: DeviceModel) -> AnyView? { AnyView(TapeEngineEditorView(model: model)) }
|
||||
|
||||
static let brakeSpeed: Float = 0.5 // ≈ one octave down while a reel is held
|
||||
static let minSpeed: Float = 0.25
|
||||
}
|
||||
|
||||
/// The transport's geometry and motion constants (Android's TapeEngineEditor).
|
||||
private enum TapeReel {
|
||||
static let degPerSecond = 360.0 // one turn a second at full speed
|
||||
static let glideSeconds = 0.19 // the DSP's speed glide time constant
|
||||
static let lX: CGFloat = 0.30, rX: CGFloat = 0.70, centreY: CGFloat = 0.38
|
||||
static let height: CGFloat = 180
|
||||
|
||||
static func radius(_ size: CGSize) -> CGFloat { Swift.min(size.height * 0.30, size.width * 0.20) }
|
||||
|
||||
/// Whether [p] is on either reel (the brake's hit area).
|
||||
static func hit(_ p: CGPoint, _ size: CGSize) -> Bool {
|
||||
let r = radius(size), cy = size.height * centreY
|
||||
return hypot(p.x - size.width * lX, p.y - cy) <= r || hypot(p.x - size.width * rX, p.y - cy) <= r
|
||||
}
|
||||
}
|
||||
|
||||
/// The reels' angle and a display speed eased toward the target, advanced by wall
|
||||
/// time on each frame (not published: the TimelineView redraws).
|
||||
private final class TapeReelClock {
|
||||
var angle = 0.0
|
||||
var speed = 1.0
|
||||
private var last: Date?
|
||||
|
||||
func advance(to now: Date, target: Double) -> Double {
|
||||
let dt = last.map { Swift.min(0.1, Swift.max(0, now.timeIntervalSince($0))) } ?? 0
|
||||
last = now
|
||||
speed += (target - speed) * (1 - exp(-dt / TapeReel.glideSeconds))
|
||||
angle = (angle + speed * TapeReel.degPerSecond * dt).truncatingRemainder(dividingBy: 360)
|
||||
return angle
|
||||
}
|
||||
}
|
||||
|
||||
private struct TapeEngineEditorView: View {
|
||||
@ObservedObject var model: DeviceModel
|
||||
@State private var clock = TapeReelClock()
|
||||
@State private var touching = false
|
||||
@State private var braking = false
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 8) {
|
||||
transport
|
||||
Text("Hold a reel to brake the tape — pitch dives, then springs back.")
|
||||
.font(Theme.mono(11)).foregroundColor(Theme.dim).multilineTextAlignment(.center)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.frame(maxWidth: .infinity)
|
||||
HStack(alignment: .top, spacing: 6) {
|
||||
knob("wow", "Wow")
|
||||
knob("flutter", "Flutter")
|
||||
knob("hiss", "Hiss")
|
||||
knob("division", "Wow Sync")
|
||||
}
|
||||
.padding(.top, 2)
|
||||
}
|
||||
.onDisappear { release() }
|
||||
}
|
||||
|
||||
private var transport: some View {
|
||||
let target = Double(Swift.min(1, Swift.max(TapeEngineBespoke.minSpeed, model.value("speed"))))
|
||||
return GeometryReader { g in
|
||||
TimelineView(.animation) { tl in
|
||||
let angle = clock.advance(to: tl.date, target: target)
|
||||
Canvas { ctx, size in TapeTransportDrawing.draw(ctx, size, angle: angle) }
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.gesture(DragGesture(minimumDistance: 0)
|
||||
.onChanged { d in
|
||||
guard !touching else { return }
|
||||
touching = true
|
||||
if TapeReel.hit(d.startLocation, g.size) {
|
||||
braking = true
|
||||
model.set("speed", TapeEngineBespoke.brakeSpeed)
|
||||
}
|
||||
}
|
||||
.onEnded { _ in release() })
|
||||
}
|
||||
.frame(height: TapeReel.height)
|
||||
.background(Theme.surface)
|
||||
}
|
||||
|
||||
private func release() {
|
||||
touching = false
|
||||
if braking { braking = false; model.set("speed", 1) }
|
||||
}
|
||||
|
||||
@ViewBuilder private func knob(_ key: String, _ label: String) -> some View {
|
||||
if let p = model.params[key] {
|
||||
KnobView(label: label, valueText: Format.value(p, model.value(key)), value: model.value(key),
|
||||
min: p.min, max: p.max, def: p.def, tone: Theme.accent) { model.set(key, $0) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The transport drawing: tape, playhead, then the two reels over it.
|
||||
private enum TapeTransportDrawing {
|
||||
static func draw(_ ctx: GraphicsContext, _ size: CGSize, angle: Double) {
|
||||
let cx0 = size.width * TapeReel.lX, cx1 = size.width * TapeReel.rX
|
||||
let cy = size.height * TapeReel.centreY
|
||||
let r = TapeReel.radius(size)
|
||||
|
||||
// Playhead block between and below the reels.
|
||||
let hw = (cx1 - cx0) * 0.46, hh = size.height * 0.13
|
||||
let hx = size.width * 0.5, hy = cy + r + size.height * 0.14
|
||||
let tl = CGPoint(x: hx - hw / 2, y: hy - hh / 2), tr = CGPoint(x: hx + hw / 2, y: hy - hh / 2)
|
||||
|
||||
// Tensioned tape: from each reel's bottom straight to the playhead and across its top.
|
||||
var tape = Path()
|
||||
tape.move(to: CGPoint(x: cx0, y: cy + r))
|
||||
tape.addLine(to: tl); tape.addLine(to: tr)
|
||||
tape.addLine(to: CGPoint(x: cx1, y: cy + r))
|
||||
ctx.stroke(tape, with: .color(Theme.dim), lineWidth: 1.5)
|
||||
|
||||
let head = Path(roundedRect: CGRect(x: tl.x, y: tl.y, width: hw, height: hh), cornerRadius: hh * 0.45)
|
||||
ctx.fill(head, with: .color(Theme.grid))
|
||||
ctx.stroke(head, with: .color(Theme.accent), lineWidth: 1.2)
|
||||
var gap = Path()
|
||||
gap.move(to: CGPoint(x: hx, y: hy - hh / 2 + 2)); gap.addLine(to: CGPoint(x: hx, y: hy + hh / 2 - 2))
|
||||
ctx.stroke(gap, with: .color(Theme.accent), lineWidth: 1.2)
|
||||
|
||||
reel(ctx, CGPoint(x: cx0, y: cy), r, angle)
|
||||
reel(ctx, CGPoint(x: cx1, y: cy), r, angle)
|
||||
}
|
||||
|
||||
/// One NAB reel: metal flange, three rotating rounded-trapezoid bobbin holes, the hub.
|
||||
private static func reel(_ ctx: GraphicsContext, _ c: CGPoint, _ r: CGFloat, _ angle: Double) {
|
||||
ctx.fill(circle(c, r), with: .color(Theme.grid))
|
||||
var holes = Path()
|
||||
for k in 0..<3 { holes.addPath(bobbinHole(c, r, angle + Double(k) * 120)) }
|
||||
ctx.fill(holes, with: .color(Theme.surface))
|
||||
ctx.fill(circle(c, r * 0.26), with: .color(Theme.surface))
|
||||
ctx.stroke(circle(c, r * 0.26), with: .color(Theme.accent), lineWidth: 1.6)
|
||||
ctx.stroke(circle(c, r * 0.14), with: .color(Theme.accent), lineWidth: 1.1)
|
||||
ctx.stroke(circle(c, r), with: .color(Theme.dim), lineWidth: 1.4)
|
||||
}
|
||||
|
||||
private static func circle(_ c: CGPoint, _ r: CGFloat) -> Path {
|
||||
Path(ellipseIn: CGRect(x: c.x - r, y: c.y - r, width: r * 2, height: r * 2))
|
||||
}
|
||||
|
||||
/// A hole at [deg] around the reel: wide toward the hub, narrow toward the rim.
|
||||
private static func bobbinHole(_ c: CGPoint, _ r: CGFloat, _ deg: Double) -> Path {
|
||||
let rIn = r * 0.40, rOut = r * 0.86
|
||||
let v = [polar(c, rIn, deg - 44), polar(c, rOut, deg - 13), polar(c, rOut, deg + 13), polar(c, rIn, deg + 44)]
|
||||
return roundedPoly(v, corner: r * 0.09)
|
||||
}
|
||||
|
||||
/// A closed polygon through [v] with every corner rounded to [corner].
|
||||
private static func roundedPoly(_ v: [CGPoint], corner: CGFloat) -> Path {
|
||||
var p = Path()
|
||||
let n = v.count
|
||||
for i in 0..<n {
|
||||
let cur = v[i], prev = v[(i + n - 1) % n], next = v[(i + 1) % n]
|
||||
let a = toward(cur, prev, corner), b = toward(cur, next, corner)
|
||||
if i == 0 { p.move(to: a) } else { p.addLine(to: a) }
|
||||
p.addQuadCurve(to: b, control: cur)
|
||||
}
|
||||
p.closeSubpath()
|
||||
return p
|
||||
}
|
||||
|
||||
private static func toward(_ from: CGPoint, _ to: CGPoint, _ len: CGFloat) -> CGPoint {
|
||||
let dx = to.x - from.x, dy = to.y - from.y
|
||||
let d = Swift.max(1e-3, hypot(dx, dy))
|
||||
return CGPoint(x: from.x + dx / d * len, y: from.y + dy / d * len)
|
||||
}
|
||||
|
||||
private static func polar(_ c: CGPoint, _ rad: CGFloat, _ deg: Double) -> CGPoint {
|
||||
let a = deg * .pi / 180
|
||||
return CGPoint(x: c.x + rad * CGFloat(cos(a)), y: c.y + rad * CGFloat(sin(a)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,162 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
/// The Wavetable's table drawing and LOAD TABLE (stub until ported).
|
||||
/// The Wavetable's own pieces inside its generic cards (Android's WavetableEditor.kt):
|
||||
/// each oscillator card draws that oscillator's table, and Oscillator 1's card
|
||||
/// carries LOAD TABLE, because a loaded WAV becomes the "Custom" table and is
|
||||
/// selected on oscillator 1.
|
||||
@MainActor
|
||||
enum WavetableBespoke {
|
||||
static func preview(osc: Int, tone: Color, model: DeviceModel) -> AnyView? { nil }
|
||||
static func loadTableAction(tone: Color, model: DeviceModel) -> AnyView? { nil }
|
||||
static func preview(osc: Int, tone: Color, model: DeviceModel) -> AnyView? {
|
||||
AnyView(WavetablePreview(osc: osc, tone: tone, model: model))
|
||||
}
|
||||
static func loadTableAction(tone: Color, model: DeviceModel) -> AnyView? {
|
||||
AnyView(LoadTableAction(model: model))
|
||||
}
|
||||
|
||||
/// What the preview draws of a table: up to 16 of its frames, 128 points each.
|
||||
struct Curves {
|
||||
let frames: Int
|
||||
let rows: [(points: [Float], frame: Int)]
|
||||
}
|
||||
|
||||
/// Curves by table (a factory name, or a custom sample id + frame length):
|
||||
/// tables are immutable once built, so each is read and thinned out once.
|
||||
private static var cache: [String: Curves] = [:]
|
||||
|
||||
static func curves(key: String, osc: Int, data: DeviceDataSource?) -> Curves? {
|
||||
if let c = cache[key] { return c }
|
||||
guard let t = data?.wavetableFrames(osc: osc), t.frames > 0, t.size >= 128,
|
||||
t.data.count >= t.frames * t.size else { return nil }
|
||||
let n = t.size, step = Swift.max(1, t.frames / 16)
|
||||
let rows = stride(from: 0, to: t.frames, by: step).map { f -> (points: [Float], frame: Int) in
|
||||
((0..<128).map { i in t.data[f * n + i * n / 128] }, f)
|
||||
}
|
||||
let c = Curves(frames: t.frames, rows: rows)
|
||||
if cache.count > 64 { cache.removeAll() }
|
||||
cache[key] = c
|
||||
return c
|
||||
}
|
||||
|
||||
/// The table oscillator [osc] plays, and the key its curves are cached under.
|
||||
static func tableKey(osc: Int, model: DeviceModel) -> (name: String, custom: Bool, key: String) {
|
||||
let name = model.choice("o\(osc)table")
|
||||
guard name == "Custom" else { return (name, false, "F|" + name) }
|
||||
let id = model.data?.hiddenValue("sfSample") ?? ""
|
||||
return (name, true, "C|\(id)|\(model.choice("wtframe"))")
|
||||
}
|
||||
|
||||
/// Native floats from a bridge call's bytes.
|
||||
static func floats(_ d: Data) -> [Float] { d.withUnsafeBytes { Array($0.bindMemory(to: Float.self)) } }
|
||||
}
|
||||
|
||||
/// Every frame of oscillator [osc]'s table stacked back to front, the one at its POSITION lit.
|
||||
struct WavetablePreview: View {
|
||||
let osc: Int
|
||||
let tone: Color
|
||||
@ObservedObject var model: DeviceModel
|
||||
/// Bumped while the table is being built, to look again.
|
||||
@State private var retry = 0
|
||||
|
||||
var body: some View {
|
||||
let (name, custom, key) = WavetableBespoke.tableKey(osc: osc, model: model)
|
||||
let curves = WavetableBespoke.curves(key: key, osc: osc, data: model.data)
|
||||
let unloaded = custom && model.data?.hiddenValue("sfSample") == nil
|
||||
let caption = curves.map { "\(custom ? "your table" : name) · \($0.frames) frames" }
|
||||
?? (unloaded ? "Custom · no table loaded" : "\(name) (preparing…)")
|
||||
let pos = model.value("o\(osc)pos")
|
||||
ZStack(alignment: .topLeading) {
|
||||
if let c = curves {
|
||||
Canvas { ctx, size in draw(c, pos: pos, in: ctx, size: size) }
|
||||
}
|
||||
Text(caption).font(Theme.mono(9)).foregroundColor(Theme.dim)
|
||||
.padding(.horizontal, 4).padding(.vertical, 2)
|
||||
}
|
||||
.frame(maxWidth: .infinity, minHeight: 72, maxHeight: 72)
|
||||
.background(Theme.background)
|
||||
.overlay(Rectangle().stroke(Theme.grid, lineWidth: 1))
|
||||
.task(id: retry) {
|
||||
guard curves == nil, !unloaded, retry < 60 else { return }
|
||||
try? await Task.sleep(nanoseconds: 300_000_000)
|
||||
retry += 1
|
||||
}
|
||||
}
|
||||
|
||||
private func draw(_ c: WavetableBespoke.Curves, pos: Float, in ctx: GraphicsContext, size: CGSize) {
|
||||
let k = c.rows.count
|
||||
let rowH = size.height * 0.45
|
||||
let lit = Int(pos * Float(c.frames - 1) + 0.5)
|
||||
let near = Swift.max(1, c.frames / k)
|
||||
let w = size.width * 0.76
|
||||
for idx in stride(from: k - 1, through: 0, by: -1) {
|
||||
let row = c.rows[idx]
|
||||
let depth = k > 1 ? CGFloat(idx) / CGFloat(k - 1) : 0
|
||||
let x0 = size.width * 0.04 + depth * size.width * 0.18
|
||||
let yMid = size.height * 0.72 - depth * size.height * 0.45
|
||||
let on = abs(row.frame - lit) * 2 <= near
|
||||
let n = row.points.count
|
||||
var path = Path()
|
||||
for i in 0..<n {
|
||||
let p = CGPoint(x: x0 + w * CGFloat(i) / CGFloat(n), y: yMid - CGFloat(row.points[i]) * rowH * 0.5)
|
||||
if i == 0 { path.move(to: p) } else { path.addLine(to: p) }
|
||||
}
|
||||
ctx.stroke(path, with: .color(on ? tone : Theme.text.opacity(0.25)), lineWidth: on ? 1.5 : 0.75)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// LOAD TABLE in Oscillator 1's title: a Serum / WaveEdit / power-of-two-frame WAV
|
||||
/// becomes the "Custom" table and is selected on oscillator 1.
|
||||
struct LoadTableAction: View {
|
||||
@ObservedObject var model: DeviceModel
|
||||
@State private var pickerShown = false
|
||||
@Environment(\.deviceFilePicker) private var hostPicker
|
||||
@State private var importError: String?
|
||||
|
||||
var body: some View {
|
||||
Text("+ LOAD TABLE").font(Theme.mono(11)).foregroundColor(Theme.accent)
|
||||
.padding(.horizontal, 8).padding(.vertical, 3)
|
||||
.overlay(Rectangle().stroke(Theme.accent.opacity(0.6), lineWidth: 1))
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { if let pick = hostPicker { pick { url in load(url) } } else { pickerShown = true } }
|
||||
// The completion needs nothing but the picked URL (iOS 15 resets the
|
||||
// presentation binding before calling it).
|
||||
.fileImporter(isPresented: $pickerShown, allowedContentTypes: [.wav, .audio, .data],
|
||||
allowsMultipleSelection: false) { result in
|
||||
guard case .success(let urls) = result, let url = urls.first else { return }
|
||||
load(url)
|
||||
}
|
||||
.alert("Import failed", isPresented: Binding(get: { importError != nil }, set: { if !$0 { importError = nil } }),
|
||||
actions: { Button("OK") { importError = nil } }, message: { Text(importError ?? "") })
|
||||
}
|
||||
|
||||
private func load(_ url: URL) {
|
||||
guard let data = model.data else { importError = "Not available here yet."; return }
|
||||
if let err = data.loadFile(url, kind: "wavetable") { importError = err; return }
|
||||
// The slot now plays Custom on oscillator 1 at the detected frame length;
|
||||
// show that (the backend has written the same values).
|
||||
select("o1table", "Custom")
|
||||
if let frame = data.hiddenValue("wtframe") { select("wtframe", frame) }
|
||||
}
|
||||
|
||||
private func select(_ key: String, _ choice: String) {
|
||||
if let i = model.params[key]?.choices.firstIndex(of: choice) { model.set(key, Float(i)) }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - plug-in backend
|
||||
|
||||
extension AUDataSource {
|
||||
/// The built-in tables (the extension has no sample store for a custom one yet).
|
||||
func wavetableFrames(osc: Int) -> (frames: Int, size: Int, data: [Float])? {
|
||||
guard let p = au.parameterTree?.allParameters.first(where: { $0.identifier == "o\(osc)table" }),
|
||||
let names = p.valueStrings, !names.isEmpty else { return nil }
|
||||
let name = names[Swift.max(0, Swift.min(names.count - 1, Int(p.value.rounded())))]
|
||||
var frames = 0, size = 0
|
||||
guard let d = SizzleDeviceAU.factoryWavetable(named: name, blocking: Snapshot.active, frames: &frames, size: &size)
|
||||
else { return nil }
|
||||
return (frames, size, WavetableBespoke.floats(d))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user