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

ndef uses embedded specs for guis #5686

Merged
merged 3 commits into from
Aug 17, 2022
Merged

ndef uses embedded specs for guis #5686

merged 3 commits into from
Aug 17, 2022

Conversation

adcxyz
Copy link
Contributor

@adcxyz adcxyz commented Jan 9, 2022

Purpose and Motivation

Fixes #5515.

Currently, NdefGui does not find controlspecs embedded in synth functions,
thus NdefGui cannot use such specs for its slider ranges.
With this PR, core JITLib NdefGui finds these specs and uses them.

Types of changes

  • Bug fix
// Ndef with an embedded spec:
n = Ndef(\1, { Saw.ar(freq: \fff.kr(200, spec: [50, 500, \exp])) * 0.1 });
// before this PR, this gui uses guessed range of 10-4000
n.gui;

// with this PR, ndef finds the embedded spec:
n.findFirstSpecFor(\fff);
// also in the specs method
n.specs;
// and the gui uses the 50 - 500 range given in the embedded spec:
n.gui;

Note: this fix works for plain SC without JITLibExtensions quark;
JITLibExtensions update to use it is simple, and ready to go.

  • Code is tested
  • All tests are passing
  • Updated documentation
  • This PR is ready for review

@adcxyz adcxyz requested a review from madskjeldgaard January 9, 2022 13:10
@@ -665,6 +665,14 @@ SynthDef {
^desc
}

findSpecFor { |controlName|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we want to avoid a double lookup?

var spec = metadata[\specs];
^spec !? { spec[controlName] }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, better, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -413,6 +413,9 @@ SynthDefControl : SynthControl {
bytes = control.bytes; // copy cached data
}

findSpecFor { |controlName|
^synthDef.findSpecFor(controlName)
}
specs {
^synthDef.specs
}
Copy link
Member

@telephon telephon Jan 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could even add one for SynthControl:

findSpecFor { |controlName|
var synthDesc =  this.synthDesc;
var specs;
^synthDesc !? {
specs = synthDesc.specs;
specs !? { specs[controlName] }
}
}

Then you can use the specs of Synths played like Ndef(\x, \default)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should SynthDesc also have its own findSpecFor method?
SynthDesc is used in many other places, so could be useful, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that seems reasonable.

@adcxyz
Copy link
Contributor Author

adcxyz commented Jan 10, 2022

ah, just saw that this portaudio file slipped into the PR by accident!

  • any ideas how to remove it?

@telephon
Copy link
Member

I would try this:

copy the commit SHA of the version before the commit, then do a git reset <SHA>. Then you can use Discard Changes in the GitHubDesktop to throw away that portaudio file change. Then commit. And then do a force push (git push --force).

well, at least what I would try.

@joshpar joshpar added this to the 3.13.0 milestone Feb 20, 2022
@joshpar
Copy link
Member

joshpar commented Feb 27, 2022

@adcxyz can you please resolve formatting issues? After that I will merge this in.

@joshpar joshpar closed this Feb 27, 2022
@joshpar joshpar reopened this Feb 27, 2022
@joshpar
Copy link
Member

joshpar commented Feb 27, 2022

ooops! accidentally closed it! reopened for reformatting.

@dyfer
Copy link
Member

dyfer commented May 8, 2022

It seems that the problem is not with the formatting itself, but with the state of this branch (there were no changes to cpp files; also there's a rouge submodule change here). As far as I can tell, this branch needs to be rebased on the develop. @adcxyz would you do that or should I do it and force push?

@joshpar
Copy link
Member

joshpar commented Aug 15, 2022

Hi all - we'd like to pull this in for 3.13.0 and are planning an RC for that after our meeting on Aug, 27, 2022. Anything else to add? Or can we close this?

@telephon
Copy link
Member

To me, this looks good. It would be better if findSpec were added to SynthDesc too, but fine like this as well.

@dyfer
Copy link
Member

dyfer commented Aug 15, 2022

In the interest of moving this forward, I've rebased this on develop and will force push it now.

EDIT: the submodule change is still there. working on it now

@dyfer
Copy link
Member

dyfer commented Aug 15, 2022

Looks like I was able to fix the submodule change. This should be clean to merge now.

@telephon telephon merged commit 8eee62e into develop Aug 17, 2022
@telephon telephon deleted the findSpec branch August 17, 2022 10:12
@adcxyz
Copy link
Contributor Author

adcxyz commented Aug 18, 2022

@dyer @telephon
thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NdefGui (EnvirGui) ignores local specs from NamedControls
4 participants