From 1a46c8e86e95fc8ff44d15cda187f9e5360a285a Mon Sep 17 00:00:00 2001 From: Jakob Leben Date: Thu, 15 Mar 2012 17:41:59 +0100 Subject: [PATCH] class library: improve Stethoscope redirection The check whether server has SHM interface alone was not valid, as it depended also on whether the server is running. Remedy this issue and simplify redirection: * change QtGUI key mapping: 'stethoscope' -> QStethoscope2 'stethoscope1' -> QStethoscope * QStethoscope2: throw error if server not local * Remove Stethoscope2 and redirection in Server:-scope, and implement all redirection in Stethoscope: if GUI is Qt and server is running and doesn't have SHM interface, redirect to QStethoscope, otherwise use the 'stethoscope' key * Add more defaults to Stethoscope arguments, to ease instantiation --- .../Common/GUI/PlusGUI/Control/server-scope.sc | 8 ++----- SCClassLibrary/Common/GUI/ViewRedirect.sc | 26 ++++++++-------------- SCClassLibrary/QtCollider/QStethoscope2.sc | 7 +++--- SCClassLibrary/QtCollider/QtGUI.sc | 4 ++-- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/SCClassLibrary/Common/GUI/PlusGUI/Control/server-scope.sc b/SCClassLibrary/Common/GUI/PlusGUI/Control/server-scope.sc index da0b194ee..8287b0158 100644 --- a/SCClassLibrary/Common/GUI/PlusGUI/Control/server-scope.sc +++ b/SCClassLibrary/Common/GUI/PlusGUI/Control/server-scope.sc @@ -4,13 +4,9 @@ zoom = zoom ? 1.0; if(scopeWindow.isNil) { - if ((GUI.id == \qt) and: (this.isLocal)) { - scopeWindow = \QStethoscope2.asClass.new(this, numChannels, index, bufsize, zoom, rate); - } { - scopeWindow = Stethoscope(this, numChannels, index, bufsize, zoom, rate, nil, - this.options.numBuffers); + scopeWindow = Stethoscope(this, numChannels, index, bufsize, zoom, rate, nil, + this.options.numBuffers); // prevent buffer conflicts by using reserved bufnum - }; scopeWindow.window.onClose = scopeWindow.window.onClose.addFunc({ scopeWindow = nil }); ServerTree.add(this, this); } { diff --git a/SCClassLibrary/Common/GUI/ViewRedirect.sc b/SCClassLibrary/Common/GUI/ViewRedirect.sc index e3874d011..31bafa9b9 100644 --- a/SCClassLibrary/Common/GUI/ViewRedirect.sc +++ b/SCClassLibrary/Common/GUI/ViewRedirect.sc @@ -59,29 +59,21 @@ Slider : ViewRedirect { *key { ^\slider }} Pen : GuiRedirect { *key { ^\pen }} Stethoscope : GuiRedirect { - *new { arg server, numChannels = 2, index, bufsize = 4096, zoom, rate, view, bufnum; + *new { arg server, numChannels = 2, index = 0, bufsize = 4096, zoom = 1, rate = \audio, view, bufnum; index = index.asControlInput; - if(server.hasShmInterface and: { GUI.current.respondsTo(\stethoscope2) }) { - ^Stethoscope2(server, numChannels, index, bufsize, zoom, rate, view, bufnum) - } { - // if server has shared mem but current gui doesn't support, - // this should show the "scoping on internal server only" message + + if (GUI.id == \qt and: + { server.serverRunning and: server.hasShmInterface.not }) + { + ^GUI.current.stethoscope1.new + (server, numChannels, index, bufsize, zoom, rate, view, bufnum) + }{ ^super.new(server, numChannels, index, bufsize, zoom, rate, view, bufnum) }; } *key { ^\stethoscope } } -Stethoscope2 : GuiRedirect { - *new { arg server, numChannels = 2, index, bufsize = 4096, zoom, rate, view, bufnum; - index = index.asControlInput; - if(server.hasShmInterface) { - ^super.new(server, numChannels, index, bufsize, zoom, rate, view, bufnum) - } { - ^Stethoscope(server, numChannels, index, bufsize, zoom, rate, view, bufnum) - }; - } - *key { ^\stethoscope2 } -} + ScopeView : ViewRedirect { *key { ^\scopeView }} FreqScopeView : ViewRedirect { *key { ^\freqScopeView }} // redirects to FreqScope diff --git a/SCClassLibrary/QtCollider/QStethoscope2.sc b/SCClassLibrary/QtCollider/QStethoscope2.sc index db9317e52..db82985b7 100644 --- a/SCClassLibrary/QtCollider/QStethoscope2.sc +++ b/SCClassLibrary/QtCollider/QStethoscope2.sc @@ -24,13 +24,12 @@ QStethoscope2 { *new { arg server, numChannels = 2, index = 0, bufsize = 4096, zoom = 1.0, rate = \audio, view, bufnum; + var bus; - var bus = Bus(rate, index, numChannels, server); if(server.isNil) {server = Server.default}; + if(server.isLocal.not) {Error("Can not scope on remote server.").throw}; - if (bufnum.notNil) - { ("QStethoscope2: the 'bufnum' argument ignored." - + "A shared-memory scope buffer is always allocated internally.").warn }; + bus = Bus(rate, index, numChannels, server); ^super.new.initQStethoscope( server, view, bus, bufsize, 1024 * zoom.asFloat.reciprocal ); } diff --git a/SCClassLibrary/QtCollider/QtGUI.sc b/SCClassLibrary/QtCollider/QtGUI.sc index efedaac12..477ed3022 100644 --- a/SCClassLibrary/QtCollider/QtGUI.sc +++ b/SCClassLibrary/QtCollider/QtGUI.sc @@ -51,8 +51,8 @@ QtGUI { *freqScope { ^PlusFreqScopeWindow } *freqScopeView { ^PlusFreqScope } *scopeView { ^QScope } - *stethoscope { ^QStethoscope } - *stethoscope2 { ^QStethoscope2 } + *stethoscope1 { ^QStethoscope } + *stethoscope { ^QStethoscope2 } *soundFileView { ^QSoundFileView } *envelopeView { ^QEnvelopeView } *tabletView { ^this.notImplemented( "TabletView"); } -- 2.11.4.GIT