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

supernova: include argument names in queryTree #3221

Merged

Conversation

dyfer
Copy link
Member

@dyfer dyfer commented Oct 3, 2017

As noted in #3210, scsynth and supernova respond differently to the the queryTree request. This changes the behavior of supernova to match the behavior of scsynth - controls's names are being reported in the reply message.

(
Server.supernova;
// Server.scsynth;
s.waitForBoot({
	SynthDef(\prTest, {arg amp = #[0.1, 0.12], freq = 300, out = 0;
		Out.ar(out, SinOsc.ar(freq, 0, amp))
	}).add;
	s.sync;
	x = Synth(\prTest);
	OSCFunc({arg msg;
		msg.postln;
		x.free;
	}, '/g_queryTree.reply').oneShot;
	s.sendMsg("/g_queryTree", 0, 1);
})
)
//supernova - no patch
// [ /g_queryTree.reply, 1, 0, 1, 1, 1, 1000, -1, prTest, 4, 0, 0.10000000149012, 1, 0.11999999731779, 2, 300, 3, 0 ]

//supernova - with patch
//[ /g_queryTree.reply, 1, 0, 1, 1, 1, 1000, -1, prTest, 4, amp, 0.10000000149012, 1, 0.11999999731779, freq, 300, out, 0 ]

//scsynth
//[ /g_queryTree.reply, 1, 0, 1, 1, 1, 1000, -1, prTest, 4, amp, 0.10000000149012, 1, 0.11999999731779, freq, 300, out, 0 ]

@dyfer
Copy link
Member Author

dyfer commented Oct 3, 2017

Sorry, this is not ready yet... further tests revealed server crashing with larger messages. I'll keep you posted.

@dyfer
Copy link
Member Author

dyfer commented Oct 3, 2017

Seems working now.

@mossheim
Copy link
Contributor

sorry this has been decaying. i will try to find some time to look at it soon. seems decent at first glance.

@patrickdupuis patrickdupuis added this to the 3.10 milestone Jan 17, 2018
Copy link
Contributor

@mossheim mossheim left a comment

Choose a reason for hiding this comment

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

This works, thanks so much! Logic can be cleaned up though

if(name_of_slot)
p << name_of_slot;
else
p << osc::int32(i);
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be simplified to a single branch:

if (i < scsynth.number_of_slots())
  p << scsynth.name_of_slot(i);
else
  p << osc::int32(i);

also style note - put a space after if and not after the open paren

@dyfer
Copy link
Member Author

dyfer commented Jan 26, 2018

[WIP]
I looked into that and reworked logic, so it's cleaner. It needed few more changes than suggested.
However, I realized another problem: mapped audio controls are not reported properly, so this is WIP right now.

@dyfer
Copy link
Member Author

dyfer commented Mar 3, 2018

The mappings seem now to be properly reported in response to queryTree for both control and audio buses.

Copy link
Member Author

@dyfer dyfer left a comment

Choose a reason for hiding this comment

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

I also noticed that when dumping node tree with controls (to the std out, not through OSC - in IDE on mac shortcut cmd-shift-t), mappings are also omitted in supernova. I made a commend next to the line where I think this happens... I'm not sure I'll be able to track this down anytime soon, is it reasonable to open an issue about it separately?

@@ -1589,7 +1604,7 @@ void dump_controls(rt_string_stream & stream, abstract_synth const & synth, int
} else
stream << ", ";

stream << synth.get(control_index);
stream << synth.get(control_index); /*FIXME: this seems not to check for mapped controls*/
Copy link
Member Author

Choose a reason for hiding this comment

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

AFAICT this seems to be the place where controls are printed, but omitting the mappings.

@dyfer dyfer force-pushed the topic/supernova-query-control-names branch from 9b113ad to 077d79a Compare April 18, 2018 22:25
@dyfer
Copy link
Member Author

dyfer commented Apr 18, 2018

I cleaned up commit history, and also added mapped controls when dumping the node tree. I'd appreciate if someone can look this over, thanks!

Copy link
Contributor

@mossheim mossheim left a comment

Choose a reason for hiding this comment

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

Thanks! Here are my comments

} else {
bus = (scsynth.mMapControls[i]) - (scsynth.mNode.mWorld->mControlBus);
sprintf(str, "%c%d", 'c', bus);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

can this not also be a call to getMappedSymbol?

Copy link
Contributor

Choose a reason for hiding this comment

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

also extra semicolon

@@ -1575,6 +1588,7 @@ void dump_controls(rt_string_stream & stream, abstract_synth const & synth, int
const size_t number_of_slots = synth.number_of_slots();

bool eol_pending = false;
char str[10];
Copy link
Contributor

Choose a reason for hiding this comment

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

declare this closer to use please

{
bool isMapped = mMapControls[slot_index] != mControls+slot_index;
if (isMapped) {
int bus;
Copy link
Contributor

Choose a reason for hiding this comment

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

declare this separately in each branch

Copy link
Contributor

Choose a reason for hiding this comment

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

also use 4 spaces for indentation, your second level of indentation is 6 instead of 8 I think

} else {
bus = mMapControls[slot_index] - mNode.mWorld->mControlBus;
sprintf(str, "%c%d", 'c', bus);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

extra semicolon


if (scsynth.mControlRates[i] == 2) {
bus = (scsynth.mMapControls[i]) - (scsynth.mNode.mWorld->mAudioBus);
bus = (int)((float)bus / scsynth.mNode.mWorld->mBufLength);
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the purpose of these casts? if you are expecting truncation that already happens with integer division in C++.

if (mControlRates[slot_index] == 2) {
bus = mMapControls[slot_index] - mNode.mWorld->mAudioBus;
bus = (int)((float)bus / mNode.mWorld->mBufLength);
sprintf(str, "%c%d", 'a', bus);
Copy link
Contributor

Choose a reason for hiding this comment

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

clearer to move the character into the format string since it is known at compile time - "a%d", then "c%d" below

@@ -100,6 +100,8 @@ class abstract_synth:

virtual float get(slot_index_t slot_id) const = 0;

virtual bool getMappedSymbol(slot_index_t slot_id, char * str) const = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

a brief comment to explain the meaning of the return value would be nice

@@ -100,6 +100,8 @@ class abstract_synth:

virtual float get(slot_index_t slot_id) const = 0;

virtual bool getMappedSymbol(slot_index_t slot_id, char * str) const = 0; //returns true (and writes characters to *str) if the control at slot_id is indeed mapped, otherwise returns false
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please use a javadoc comment (/** ... */ or ///) on the line above? this matches the documentation style of supernova and also keeps text at a reasonable width

sprintf(str, "a%d", bus);
} else {
int bus;
bus = mMapControls[slot_index] - mNode.mWorld->mControlBus;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is fine, for future reference you can declare while initializing (int bus = ...), this will save space and reduce visual noise

Copy link
Contributor

Choose a reason for hiding this comment

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

you probably know that already, just stating my preference :)

@dyfer
Copy link
Member Author

dyfer commented Apr 19, 2018

Thank you Brian for the feedback! I made the requested corrections. I can also squish squash the last (fixing) commit into the previous one if desired.

@mossheim
Copy link
Contributor

Thanks for being so quick to respond @dyfer. I think the whole thing can be squashed on merge, it's a small enough PR in terms of LoC

@dyfer
Copy link
Member Author

dyfer commented Jun 5, 2018

Hey @brianlheim, does this PR need more changes?

Copy link
Contributor

@mossheim mossheim left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for your patience and I apologize for how long it took to review this.

@mossheim mossheim merged commit e6f5086 into supercollider:develop Sep 18, 2018
mossheim added a commit that referenced this pull request Sep 23, 2018
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.

3 participants