Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename SynthDef.actual_name -> effective_name #408

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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