First time here? Check out the FAQ!
x

How can I create unique FeedbackLoop names in an encapsulation while still having a FromMemoryWriter parameter?

+1 vote
313 views

In the kata we're making an encapsulated Sound (a state variable filter) that allows the user of the Sound to put a waveshaper in the feedback path. Nice. And we want to also allow the use of a MemoryWriter instead of specifiying a wavetable filename....AND we want to be able to use more than one of these Sounds in the same flow. 

Our Sound uses feedback loops. A massive simplification of the Sound to show the issue would be:

If we want to use more than one of these Sounds in a flow we'd need to protect the FeedbackLoop's connections by making them uniquely named. The normal way I'd do that would be with the UniqueMemoryWriterRecorderNames (henceforth UMWRN) and CancelUnique.....  like so:

I also want to allow the user of the Class to be able to use a MemoryWriter RecordingName as the shaping function in the WaveShaper:

 

But if I do this then the RecordingName gets rewritten by the UMWRN and so doesn't work. 

If I put a CancelUniqueMemoryWriterRecordingName (aka CUMWRN) in front of the WaveShaper and then another UMWRN after it, the user can set the RecordingName, but the FeedbackLoopInput and FeedbackLoopOutput's connections are now being renamed by different UMWRNs and so no longer connect to each other. 

So how would you approach this?

What we came up with was to not use UMWRNs and instead attempt to make the connection names unique ourselves which we're doing by appending a random number to the connection name. There is of course some chance that the random numbers could come out the same in different instances of the class (hence my earlier question of "How do you generate a unique number in Smalltalk?").

Is there a better way of doing this?

 

asked Mar 18, 2020 in Using Kyma by alan-jackson (Virtuoso) (15,840 points)

1 Answer

+1 vote

This issue is now solved with the new Smalltalk message:

Number nextUniqueNumber

You can now generate a unique number in a script and pass that in to the Connection names of the FeedbackLoops. 

 

answered Mar 26, 2020 by alan-jackson (Virtuoso) (15,840 points)
...