Using Select Data to trigger an audio file to play

Sorry if this is a basic question… I’m new to TouchDesigner.

I have a CHOP connected to serial to receive an input from an Arduino. The input comes in as a number 0, 1, 2, 3. As that serial input gives me the 10 latest results, I use a select CHOP to get the latest number (0, 1, 2, 3). It looks like below:

For my audio selection, I have 4 audio files that go into a switch CHOP and then to an output (laptop speaker). Looks like below.

I want to use the switch CHOP to select the right index based on the data from my select CHOP. Looks like this:

image

How do I select the input corresponding to the input from the Select CHOP above?

Thanks for reading to this point – I’d appreciate the help!

Hi @StephenAbraham,

the screenshots are a bit tiny but I think I can make out that you are very close to the solution.
There are 2 ways:

  • since you have the Switch CHOP’s “First Input is Index” parameter toggled on, the first input to the Switch should actually be the Select CHOP that holds the index from the Arduino followed by the remaining Audio File In CHOPs.
  • you can also toggle off the Switch CHOP’s “First Input is Index” parameter and now control the “Index” parameter directly by either exporting or referencing the index channel from the Select CHOP.

For triggering the Play state of each Audio File In CHOP, have a look at the OP Snippets and how the Fan CHOP could help you here.

Does that make sense?
cheers
Markus

Wow, thanks for helping so quickly Marcus. I tried to do this:

but it doesn’t seem to work. The select always seems to select 0.

Can you see what I’m doing wrong from this?

Thanks for your help… I really appreciate it.

Hi @StephenAbraham,

if I can see that correctly on the screenshot, the Switch CHOP is currently disabled. (the grey arrow on the left side below the orange flag that is also turned on.)

You are welcome to share the file here as well.

cheers
Markus

1 Like

THAT’s IT! That was exactly what I was missing. All is working now. Thank you so, so much for your generous help Markus!

1 Like

Hi @StephenAbraham,

generally I would advise not to resize operators but make use of zooming the network when trying to inspect operators. This will keep your network tidy.

You can reset the operator size of all operators in your network by right clicking somewhere in the network pane, then first selecting “Normalize Node Sizes” and then “Reset Node Sizes”

cheers
Markus

That’s good advice. The issue would have jumped out at me sooner if I understood what that funny arrow meant :smile: . Again thanks!!

1 Like