Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Play Random Audio
Old
devinw95
Junior Member
 
Status: Offline
Posts: 1
Join Date: Nov 2015
Unhappy Play Random Audio - 11-29-2015, 06:27 PM

I have a collection of audio clips that I would like to play in random orders to go along with my Alice program. I barely know where to start with this, right now I'm focusing on using random variables and arrays but I don't know how to use these to accomplish my task. Any input/help would be greatly appreciated, thank you!
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 12-12-2015, 11:56 PM

Create a world variable. (Make it a number variable)

Create a world method appropriately named to what your task is.

Use a list function, have the number variable you created be assigned to a random number (use the min and max number to make a range of how many sound clips you are using)

then use if statements below that to find if the variable value == "randomly selected number" then "sound clip whatever" will play.

Use the else section of the if statements to further your conditions to test for the value of the variable.

There are multiple ways to have it loop while your world is running but one of the easiest is to put in a loop and place the method in a event "when the world begins"
Attached Images
File Type: jpg Example_1.jpg (19.1 KB, 7 views)


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn
   
Reply With Quote
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
Smile 12-13-2015, 01:40 PM

Or you can try something easier, and make less code work for you. Just add the single line where it's needed.
Attached Images
File Type: jpg EasyWay2.jpg (16.7 KB, 7 views)

Last edited by MrMoke; 12-13-2015 at 05:44 PM.
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 12-15-2015, 05:12 PM

Quote:
Originally Posted by MrMoke View Post
Or you can try something easier, and make less code work for you. Just add the single line where it's needed.
The only downside to not touching the program for close to a year, I barely remember any of it. But with any "language" there is always multiple ways to make something happen.


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn
   
Reply With Quote
Reply

Tags
arrays, audio, random variables, variables

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.