The forum on this site is closed for new comments and posts. Continue the conversation in our Snap AR Discord server.

How do I trigger music based on what a random selector lands on?

  • Hi Ryan!

    That's a great idea, I can't wait to see it.

    What you can do is set up a behavior script:

    And then in the ImageRandomizer script, you can add a line to call this:

    global.behaviorSystem.sendCustomTrigger("play_song_" + curIndex);

    and each behavior script trigger will correlate to the image.

    So the first image will play 

    play_song_0

    and the second image will play 

    play_song_1

    Let me know if you need any clarification.

     

    Thanks!

    Jonathan 

    Comment actions Permalink
  • Hey!

    I think I'm almost getting the hang of it, haha. I'm very very very new to scripting and the project file is originally a template created by another user where all you have to do is put images in to randomize.

    So, essentially, I'm digging myself into unknown territory here, so I appreciate the help.

    Question - do I have to create a different behavior script for each song to correlate with? Or how does it work? How/where do I import each song to correlate properly?

    Thanks,

    Ryan

    Comment actions Permalink
  • Hi Ryan,

    Awesome!

    Ya, each behavior script should control each song so that you can call that behavior script to play the song. 

    In the example above, you can see:

    global.behaviorSystem.sendCustomTrigger("play_song_" + curIndex);

    which means that the script will try to call the behavior play_song_ with curIndex appended to the end. CurIndex represents the order of the image in the ImageRandomizer script.

    So for the first song for the first image, call the custom trigger in Behavior: play_song_0. The next one play_song_1, and so forth. 

    By the way, I am referring to this: https://support.lensstudio.snapchat.com/hc/en-us/community/posts/360055891792--Example-Project-Rotate-Through-Random-Images example project.

    Cheers!

    Jonathan 

    Comment actions Permalink
  • Hi Jonathan!

    I have a question. How to change Tap Trigger to be Mouth Opened Trigger? I have tried to play with scripting but still can't change anything :( 

    I hope you can help me. Thanks

    Comment actions Permalink
  • Hi Ryan, 

    Can you clarify where you want to change it? 


    In general you can trigger things using Behavior:

    https://lensstudio.snapchat.com/guides/scripting/helper-scripts/behavior/

    Or if you are using a script, you can use the "MouthOpenedEvent" key rather than the "TouchStartEvent" key:

    https://lensstudio.snapchat.com/api/classes/MouthOpenedEvent/

     

    Thanks again, 

    Jonathan

     

    Comment actions Permalink
  • Hi!

    in the example project that you provided. The trigger used is a tap to start the randomization of the image. what if I change it to randomization starting after I start recording for three seconds like "Guess the Gibberish" project.

    I already changed the script but it didn't works :(

    Regards,

    Ryan

    Comment actions Permalink
  • Thanks Jonathan Solichin, works wall!! 

    how can I mute the Mic and record the sound in the lens when I make a video? 

     

    Comment actions Permalink

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?

Version

Graphics

Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:

Name:

Email:

What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!