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

sclang: refactoring processSelect and validateBuffer #141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

elgiano
Copy link
Contributor

@elgiano elgiano commented Sep 5, 2022

to remove duplicate code scattered over many classes, prProcessSelect becomes FluidProcessSelect, and buffer validation for BufProcessors is now a method inherited from FluidBufProcessor.

FluidProcessSelect usage:

// FluidSpectralShape
const <features=#[\centroid,\spread,\skewness,\kurtosis,\rolloff,\flatness,\crest];
classvar <featuresLookup;
*initClass {
	featuresLookup = FluidProcessSelect(this, this.features);
}
*kr { 
   [...]
   var selectbits = this.featuresLookup.encode(select);
   [...]
}

validateBuffer: converts with .asUGenInput, checks for nil, and throws on error

// e.g FluidBufPitch
*kr {
    [...]
    source = this.validateBuffer(source, "source");
    [...]
}
// example error: the class name and the second argument are used in the error message
// FluidBufPitch:  Invalid source buffer

Let me know if you like it :)

to remove duplicate code, processSelect becomes FluidProcessSelect,
and buffer validation for BufProcessors is now a method inherited from
FluidBufProcessor
@weefuzzy
Copy link
Member

This looks grand. I'll give it an experimental merge and test when I can.

A general sclang question: is there any naming convention for denoting classes as being for internal use, in the absence of namespaces or such like? We've got quite a few little helpers like this that aren't part of the user interface, and I guess it would be useful noise reduction if we could mark them clearly.

@tremblap
Copy link
Member

I just read in the "Writing Classes" tutorial that there is a prefix 'pr' for private methods... but that is a good question, maybe for the sc forum if @elgiano doesn't have the answer - which I doubt :)

@elgiano
Copy link
Contributor Author

elgiano commented Sep 29, 2022 via email

@weefuzzy weefuzzy changed the base branch from dev to main February 21, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants