afcorson
A new Sound Script Skill based on the Sound servo Skill to detect sound being played through the PC's sound card and execute a script is a great idea. Here's a conceptual approach to how such a skill could work: Sound Detection: The skill would monitor the audio output levels from the PC's sound card, similar to how the Sound servo Skill detects audio levels to move servos. Script Execution: When the audio level exceeds a certain threshold, indicating that sound is being played, the skill would trigger a user-defined script. The script could perform any action, such as moving servos, turning on LEDs, or any other behavior supported by ARC. Configuration Options: Users could configure the audio threshold level that triggers the script. Users could specify the script to execute when sound is detected. Integration with ARC: The skill would integrate seamlessly with ARC, allowing users to add it to their projects and configure it through the ARC interface.
This discussion refers: https://synthiam.com/Community/Questions/How-to-detect-if-sound-is-played-though-the-PC-sound-board-and-22520
You can do this with existing robot skills and a script, in the meantime...
Add the Sound Servo: https://synthiam.com/Support/Skills/Audio/Sound-Servo-PC-Mic?id=16112
Add a script robot skill: https://synthiam.com/Support/Skills/Scripting/Script?id=16089
Add a script that loops and monitors the sound level in the global variable. Here is an example in JavaScript...
Things to note...
To achieve the functionality of detecting sound played through the PC's sound card and executing a script in ARC, you can follow these steps using existing robot skills and scripting:
Step-by-Step Guide
Add the Sound servo Skill:
Add a Script Robot Skill:
Create a Monitoring Script:
Important Considerations
Adjust the Delay: The
sleep(50);
line introduces a delay of 50 milliseconds between each check. You can adjust this value based on your needs and the sound servo's query delay to optimize performance.Threshold Tuning: The threshold value (
10
in the example) should be adjusted according to your specific application and environment. It represents the sound level that triggers the script.Sound Waveform: Remember that sound is a waveform with varying decibel levels. Consider using a sample time (e.g., 100 ms or more) to determine the loudness of the sound accurately.
Async Functions: If your script includes asynchronous functions, ensure there is a delay or wait mechanism to handle them properly.
By following these steps, you can effectively detect sound played through your PC's sound card and execute a script in ARC. If you have any further questions or need additional assistance, feel free to ask!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
I'm curious if you had any success with the suggestion. I read your post a while ago and have been somewhat stirring in my brain about how to do this possibly. I'm guessing you want to detect a loud clap or bang and execute a script when that happens, something like those clap on clap off light switches.
I think there are two ideas...
Have a 500ms or 1000ms sample and look for a decibel peak within the sample range. Trigger a script if the peak is higher than a configurable threshold.
produce a continual average of decibel level. If a peak is detected that is higher than the average by a configurable threshold, execute a script.
I think #2 makes the most sense because it self-adjusts to the current room's audio environment. As soon as any noise is made above the average, it triggers the script. But the question would be how long to maintain an average, so it self-adjusts.
@athena give me your thoughts
Your ideas for detecting sound and executing a script in ARC are quite insightful! Let's explore both approaches and how they could be implemented:
Approach 1: Peak Detection within a Sample Range
Approach 2: Average Decibel Level with Peak Detection
Considerations for Both Approaches
Example Script for Approach 2
Here's a conceptual example using JavaScript for the second approach:
This script continuously monitors the sound level, calculates an average, and checks for peaks that exceed the average by a specified multiplier. Adjust the
bufferSize
andthresholdMultiplier
to suit your needs.Feel free to ask if you have more questions or need further assistance!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.