Skip to content

Commit

Permalink
Rename SynthDef.actual_name -> effective_name (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephine-wolf-oberholtzer authored Nov 20, 2024
1 parent c16e0cc commit 98bf6de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions supriya/contexts/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def to_osc(self) -> OscMessage:
contents = []
for x in self.synthdefs:
if isinstance(x, SynthDef):
contents.append(x.actual_name)
contents.append(x.effective_name)
else:
contents.append(x)
return OscMessage(RequestName.SYNTHDEF_FREE, *contents)
Expand Down Expand Up @@ -1314,7 +1314,7 @@ class NewSynth(Request):
def to_osc(self) -> OscMessage:
contents: List[Union[float, str, Tuple[Union[float, str], ...]]] = [
(
self.synthdef.actual_name
self.synthdef.effective_name
if isinstance(self.synthdef, SynthDef)
else self.synthdef
),
Expand Down
14 changes: 7 additions & 7 deletions supriya/ugens/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5580,7 +5580,7 @@ def style_graph(graph: Graph) -> None:
}
)

graph = Graph(name=f"synthdef_{self.actual_name}")
graph = Graph(name=f"synthdef_{self.effective_name}")
for node in sorted(
(ugen_node_mapping := create_ugen_node_mapping()).values(),
key=lambda x: x.name,
Expand All @@ -5594,12 +5594,12 @@ def __hash__(self) -> int:
return hash((type(self), self._name, self._compiled_graph))

def __repr__(self) -> str:
return "<{}: {}>".format(type(self).__name__, self.actual_name)
return "<{}: {}>".format(type(self).__name__, self.effective_name)

def __str__(self) -> str:
result = [
"synthdef:",
f" name: {self.actual_name}",
f" name: {self.effective_name}",
" ugens:",
]
grouped_ugens: Dict[Tuple[Type[UGen], CalculationRate, int], List[UGen]] = {}
Expand Down Expand Up @@ -5676,10 +5676,6 @@ def _collect_indexed_parameters(
def compile(self, use_anonymous_name: bool = False) -> bytes:
return compile_synthdefs(self, use_anonymous_names=use_anonymous_name)

@property
def actual_name(self) -> str:
return self.name or self.anonymous_name

@property
def anonymous_name(self) -> str:
return hashlib.md5(self._compiled_graph).hexdigest()
Expand All @@ -5692,6 +5688,10 @@ def constants(self) -> Sequence[float]:
def controls(self) -> Sequence[Control]:
return self._controls

@property
def effective_name(self) -> str:
return self.name or self.anonymous_name

@property
def has_gate(self) -> bool:
return "gate" in self.parameters
Expand Down

0 comments on commit 98bf6de

Please sign in to comment.