Zongzi.Windowing.Context (zongzi v0.3.0)

Copy Markdown

Windowing.Strategy.window/1 的只读输入。

必填

  • timeline — 编辑后的 Timeline
  • notes_by_seq — active(及策略需要的)SeqID → Note;Timeline 不持 Note 字段

可选

  • time_sig_map / tempo_map — 拍/秒换算;默认策略主要用拍
  • interventions结构 rebase 后存活 的列表
  • opts 常用键:
    • :tpqn — 默认 480
    • :beat_ticks — 显式一拍 tick 数(覆盖从拍号/假定推导)
    • :extra — 策略私货

Caller 负责在 Anchor.rebase_all 之后组装本结构。

Summary

Functions

从 map/keyword 构造 Context。

Declaration.scope/2 的 tagged return 归一化为 tick 区间。

从 Context 组装 Declaration.scope/2 需要的 scope_ctx plain map。

Types

t()

@type t() :: %Zongzi.Windowing.Context{
  current_segments: [Zongzi.Windowing.Segment.t()],
  interventions: [Zongzi.Intervention.t()],
  notes_by_seq: %{required(Zongzi.Timeline.SeqID.t()) => Zongzi.Score.Note.t()},
  opts: map(),
  tempo_map: Zongzi.Score.TempoMap.t() | nil,
  time_sig_map: Zongzi.Score.TimeSigMap.t() | nil,
  timeline: Zongzi.Timeline.t()
}

Functions

new(attrs \\ %{})

@spec new(map() | keyword()) :: t()

从 map/keyword 构造 Context。

normalize_scope(arg, arg2)

@spec normalize_scope(
  {Zongzi.Score.Tick.t(), Zongzi.Score.Tick.t()} | {:seconds, float(), float()},
  Zongzi.Intervention.Declaration.scope_ctx()
) :: {:ok, {Zongzi.Score.Tick.t(), Zongzi.Score.Tick.t()}} | {:error, term()}

Declaration.scope/2 的 tagged return 归一化为 tick 区间。

  • {tick, tick} → 原样返回 {:ok, {tick, tick}}
  • {:seconds, s, e} → 用 scope_ctx.tempo_map 转 tick
  • {:seconds, _, _}tempo_map 为 nil → {:error, :tempo_map_required}

scope_ctx(context)

从 Context 组装 Declaration.scope/2 需要的 scope_ctx plain map。

字段

  • :timelinectx.timeline
  • :tempo_mapctx.tempo_map
  • :tpqnctx.opts[:tpqn] 或默认 480