First time here? Check out the FAQ!
x

How do you create a SoundCollection in a script and set it as the input to a Sound?

0 votes
349 views

I'm trying to use a script to create a bunch of similar sounds and I want to add all these sounds to the inputs field of a SelectableSound.

I tried adding Sounds to an array and then setting the SoundCollectionVariable sound to my array but that didn't work.

Here's the script I've got so far...

| scrubbers s|
scrubbers := SoundCollection new.
('balloon-short.aiff' sampleFileNamesInSameFolder) do: [:file|
    s := scrubber samplefile: file.
    scrubbers add: s.
].

selector start: 0 selectorInputs: scrubbers.

 

"add:" isn't a valid message for SoundCollection so I got a bit stuck here.

Here's my Sound...

 

Am I going in the right direction?

asked Jul 8, 2018 in Capytalk & Smalltalk by alan-jackson (Virtuoso) (15,840 points)
edited Jul 9, 2018 by alan-jackson
Here's another failed attempt. I put the Sounds I'm creating into an array first then try to create the SoundCollection using the array:

----

| scrubbers s scrubbersc |
scrubbers := #().
('balloon-short-two-fingers-ascending.aiff' sampleFileNamesInSameFolder) do: [:file|
    s := scrubber samplefile: file.
    scrubbers := scrubbers, s.
].

scrubbersc := SoundCollection with: scrubbers.
selector start: 0 selectorInputs: scrubbersc.

----

I get an error "playAfter: is obsolete. Please fix the caller."

1 Answer

0 votes

Answering my own question, how embarassing. Anyway, a bit of googling about the place and I found Cristian has asked this question before and SCC answered. Basically I have to use the collect: message to create the SoundCollection.

Here's the script that works:

selector start: 0 selectorInputs: (('balloon.aiff' sampleFileNamesInSameFolder) collect: [:file|
    scrubber samplefile: file]).

 

where selectorInputs is the name of the SoundCollectionVariable in the SelectableSound. I'm still intrigued to know if I can create and use a SoundCollection object in SmallTalk and how I'd find out about its methods. 

Now off to see if I can make the selector fader in the VCS label itself with the files names. I'm sure someone's asked about that before.

 

I've put two other ways of doing this with an Array and an OrderedCollection in a related question.

 

answered Jul 9, 2018 by alan-jackson (Virtuoso) (15,840 points)
edited Jul 13, 2018 by alan-jackson
...