New class VisualBuffer

Hi all,

As I posted on here a few weeks ago ago, I recently tried Pure Data again after over a decade. I have been so fond of interacting with arrays, I’ve been trying to see how well I can port them to SC.

Essentially what I’ve made is a wrapper around a Buffer, that tries to bridge smoothly to sclang and gui interaction. It has been mostly successful, for me… The biggest caveats being that as far as I can tell there is no way to tell when a buffer has been written to on the server with e.g. BufWr (I get around this by making a routine to refresh the language side when I know it’s being written to – maybe this is fine), and that also as far as I can tell there’s no way to change the buffer’s sample rate on the server manually, which is mostly fine but sometimes annoying. If anyone has ideas about these things I would love to hear.

My proof of concept is up here:

And here is a little demo video:

Please give feedback, if you try this out. It would be cool if this is useful for more than just me :slight_smile:

15 Likes

That demo was mighty impressive :smiley:

1 Like

Interestingly, buffers DO know when they are modified. This is not accessible via the server API in sclang, but it’s visible to UGens (take a look at ScopeOut’s use of m_bufupdates). IIRC this is only used for scopes, and isn’t really exposed anywhere else, but making e.g. a BufChanged UGen that fires a trigger when a buffer is written to would be very useful.

4 Likes

Wow, this is supercool, I will definitely give at spin.

1 Like

Interesting. I will check this out, thanks!

this topic came up today in a dev meeting, and I was looking around the source code for this feature (mSndBufUpdates), so for the records: it seems like it’s only tracking operations that come through osc commands, for example b_read, b_alloc, b_gen..., and I haven’t found any UGen (like BufWr) that actually notifies it. It looks like it’s used only by ScopeOut.

1 Like

@Eric_Sluyter this looks cool! However, when I try drawing in the window I get:

ERROR: Message 'range' not understood.
RECEIVER:
   Float 0.913614   60000000 3FED3C54
ARGS:
   Integer -1
   Integer 1
KEYWORD ARGUMENTS:
CALL STACK:
	DoesNotUnderstandError:reportError
		arg this = <instance of DoesNotUnderstandError>
	Nil:handleError
		arg this = nil
		arg error = <instance of DoesNotUnderstandError>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of DoesNotUnderstandError>
	Object:throw
		arg this = <instance of DoesNotUnderstandError>
	Object:doesNotUnderstand
		arg this = 0.91361445188522
		arg selector = 'range'
		arg args = [*2]
		arg kwargs = [*0]
	< FunctionDef in Method Collection:collectAs >
		arg elem = 0.91361445188522
		arg i = 0
	ArrayedCollection:do
		arg this = [*85]
		arg function = <instance of Function>
		var i = 0
	Collection:collectAs
		arg this = [*85]
		arg function = <instance of Function>
		arg class = <instance of Meta_Array>
		var res = [*0]
	< FunctionDef in Method VisualBufferWindow:updateFromView >
		var insertArr = nil
	True:if
		arg this = true
		arg trueFunc = <instance of Function>
		arg falseFunc = nil
	VisualBufferWindow:updateFromView
		arg this = <instance of VisualBufferWindow>
		var tmp = nil
	< FunctionDef in Method VisualBufferWindow:init >  (no arguments or variables)
	View:mouseUp
		arg this = <instance of MultiSliderView>
		arg x = 272
		arg y = 78
		arg modifiers = 0
		arg buttonNumber = 0
	View:mouseUpEvent
		arg this = <instance of MultiSliderView>
		arg x = 272
		arg y = 78
		arg modifiers = 0
		arg buttonNumber = 0

^^ ERROR: Message 'range' not understood.