Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Sound JukeTrack_v16_1_secs_looped  

JukeTrack_v16_1_secs_looped

its better to play many wavs sound looped i used in a merry go round

Category: Sound
By : BACANA
Created: 2010-09-25 Edited: 2010-09-25
Worlds: Second Life

the Zip file

Download all files for JukeTrack_v16_1_secs_looped
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. JukeTrack_v16_1_secs_looped_1.lsl
1 float INTERVAL = 10.00;
2
3 integer LISTEN_CHAN = 2000;
4 integer SEND_CHAN = 2001;
5 float VOLUME = 1.0;
6
7 integer g_iSound;
8 integer tottrack;
9 integer g_iListenCtrl = -1;
10 integer g_iPlaying;
11 integer g_iLinked;
12 integer g_iStop;
13 integer g_iPod;
14 string g_sLink;
15
16 // DEBUG
17 integer g_iWasLinked;
18 integer g_iFinished;
19
20 Initialize()
21 {
22 //llSetText(llGetObjectName(), <0, 100, 100>, 10);
23
24 // reset listeners
25 if( g_iListenCtrl != -1 )
26 {
27 llListenRemove(g_iListenCtrl);
28 }
29 g_iListenCtrl = llListen(LISTEN_CHAN,"","","");
30 g_iPlaying = 0;
31 g_iLinked = 0;
32 }
33
34
35
36 PlaySong()
37 {
38 integer i;
39
40 g_iPlaying = 1;
41 //llWhisper(0,"Playing...");
46 llSetTimerEvent(5.0); // wait 5 seconds before queueing the second file
47 g_iSound = 1;
48
49 // for ( i = 1; i < tottrack; i++ )
50 // {
52 // }
53 }
54
55
56 StopSong()
57 {
58 g_iPlaying = 0;
59 llWhisper(0,"Stopping...");
61 llSetTimerEvent(0.0);
62 }
63
64
65 integer CheckLink()
66 {
67 string sLink;
68
69 sLink = llGetLinkName(1);
70 g_sLink = sLink;
71 if( llGetSubString(sLink,0,6) == "Jukebox" )
72 {
73 return TRUE;
74 }
75 return FALSE;
76 }
77
78
79 default
80 {
82 {
83 Initialize();
84 }
85
86 on_rez(integer start_param)
87 {
88 Initialize();
89 if( start_param )
90 {
91 g_iPod = start_param - 1;
92 if( g_iPod )
93 {
95 } else {
96 // Tell the controller what the CD key is so it can link
97 llWhisper(SEND_CHAN,"LINK " + (string)llGetKey());
98 }
99 }
100 }
101
102 changed(integer change)
103 {
104 if( change == CHANGED_LINK )
105 {
106 if( llGetLinkNumber() == 0 )
107 {
108 StopSong();
109 llDie();
110 } else {
111 if( g_iStop )
112 {
113 llMessageLinked(1,llGetLinkNumber(),"UNLINK","");
114 } else {
115 llMessageLinked(1,llGetLinkNumber(),"LINKID","");
116 g_iWasLinked = 1;
117 }
118 }
119 }
120 }
121
122 attach(key id)
123 {
124 if( id == NULL_KEY )
125 {
126 llDie();
127 } else {
128 PlaySong();
129 }
130 }
131
133 {
134 if( perm == PERMISSION_ATTACH )
135 {
137 llSetTexture("clear",ALL_SIDES);
138 }
139 }
140
141 touch_start(integer total_number)
142 {
143 llWhisper(0,"Playing...");
144
145 integer i;
146
147 for ( i = 0; i < total_number; i++ )
148 {
149 if( llDetectedKey(i) == llGetOwner() )
150 {
151 //llWhisper(0,"DEBUG: g_iPlaying=" + (string)g_iPlaying);
152 //llWhisper(0,"DEBUG: Link=" + (string)llGetLinkNumber());
153 //llWhisper(0,"DEBUG: g_iWasLinked=" + (string)g_iWasLinked);
154 //llWhisper(0,"DEBUG: g_iFinished=" + (string)g_iFinished);
155 if( g_iPlaying )
156 {
157 llWhisper(0,"Stopping...");
158 g_iPlaying = 0;
160 llSetTimerEvent(0.0);
161 } else {
162 PlaySong();
163 }
164 }
165 }
166 }
167
168 listen(integer channel, string name, key id, string message)
169 {
170 if( message == "RESET" )
171 {
172 if( llGetLinkNumber() == 0 )
173 {
174 llDie();
175 } else {
176 llMessageLinked(1,llGetLinkNumber(),"UNLINK","");
177 }
178 }
179
180 if( message == "STOP" )
181 {
182 if( g_iPod )
183 {
184 StopSong();
186 }
187 }
188 }
189
190 link_message(integer sender_num, integer num, string str, key id)
191 {
192 if( str == "PLAY" )
193 {
194 if( !g_iPlaying )
195 {
196 PlaySong();
197 }
198 return;
199 }
200
201 if( str == "STOP" )
202 {
203 g_iStop = 1;
204 StopSong();
205 llMessageLinked(1,llGetLinkNumber(),"UNLINK","");
206 }
207
208 if( str == "VOLUME" )
209 {
210 VOLUME = (float)num / 10.0;
211 llAdjustSoundVolume(VOLUME);
212 }
213 }
214
215 timer()
216 {
217 if( g_iPlaying )
218 {
219 if( g_iSound == 1 )
220 {
221 llSetTimerEvent(INTERVAL);
222 }
224 if( g_iSound < (tottrack - 1) )
225 {
227 }
228 g_iSound++;
229 if( g_iSound >= tottrack )
230 {
231 //llSetTimerEvent(INTERVAL + 5.0);
232 // g_iPlaying = 0;
233 PlaySong();
234 }
235 } else {
236 if( llGetLinkNumber() != 0 )
237 {
238 llSetTimerEvent(0.0);
239 if( g_iPod )
240 {
241 llWhisper(SEND_CHAN,"FINISH");
243 } else {
244 llMessageLinked(1,0,"FINISH","");
245 g_iFinished = 1;
246 }
247 }
248 }
249 }
250 }

Back to the Best Free Tools in Second Life and OpenSim.