To accomplish your goal in TouchDesigner, follow these steps:
-
Set Up the OSC In DAT:
- Ensure the OSC In DAT is configured to receive messages with the address pattern
/wordResponse.
-
Add the Received Word to the Table:
- Use a Python script to update the table with the received word. Connect this script to the OSC In DAT so it runs every time a message is received.
-
Update the Text TOP with the New Word:
- Write a script to update the Text TOP with the word from the table. This script can be part of the same script used to update the table or can be a separate one that runs immediately after the table update.
- Create an OSC In DAT and configure it to listen to the correct port.
- Set the OSC address pattern to
/wordResponse.
- Create a table DAT named
wordResponseTable if it doesn’t exist.
- Add a script DAT connected to the OSC In DAT to handle the incoming messages.
Here’s an example script to add the word to the table:
def onReceiveOSC(channel, sampleIndex, val, prev):
# Assuming 'val' is the received word
# Reference to the wordResponseTable
table = op('wordResponseTable')
# Clear the table and add the new word
# Call function to update the Text TOP
def update_text_top(word):
# Reference to the Text TOP
text_top = op('input_text')
# Update the text parameter with the new word
text_top.par.text = word.upper()
# Bind the function to OSC In DAT
op('oscin1').receive = onReceiveOSC
- Ensure the
update_text_top function is called after updating the table.
The update_text_top function will take the word from the table and update the Text TOP.
Based on the provided image, ensure that:
- The OSC In DAT (
oscin1) receives the messages correctly.
- The table (
wordResponseTable) is updated with the incoming word.
- The Text TOP (
input_text) is updated with the new word from the table.
Place this script in a DAT (e.g., a script DAT connected to the OSC In DAT):
def onReceiveOSC(channel, sampleIndex, val, prev):
# Assuming 'val' is the received word
# Reference to the wordResponseTable
table = op('wordResponseTable')
# Clear the table and add the new word
# Call function to update the Text TOP
def update_text_top(word):
# Reference to the Text TOP
text_top = op('input_text')
# Update the text parameter with the new word
text_top.par.text = word.upper()
# Bind the function to OSC In DAT
op('oscin1').receive = onReceiveOSC
Ensure the names in the script match your actual DAT names in TouchDesigner. Adjust the references if needed based on your setup.
This setup should receive the word via OSC, update the table, and then update the text in the Text TOP.