
-----------------------------------
gamer
Fri May 28, 2004 3:42 pm

stop a certain fork?
-----------------------------------
hi i just wanna ask if this is possible: lets say i got fork#1 and fork#2 going on at the sametime. let say both are music.playfileloop, is there anyway to stop fork #1 but hav #2 keep going? cuz i kno music.PlayFileStop stops everything

-----------------------------------
guruguru
Fri May 28, 2004 3:46 pm


-----------------------------------
First off... Music.PlayFileLoop is already a process-type, you don't need to put it in another process. But maybe for this you do...

Hmm... thats interesting. I don't find anything regarding stopping a process. If anybody knows, please let us now :p!

-----------------------------------
AsianSensation
Fri May 28, 2004 9:01 pm


-----------------------------------
return

-----------------------------------
guruguru
Fri May 28, 2004 9:53 pm


-----------------------------------
Return? I don't believe that works. That is used for exiting functions/procedures and loops. I just tested it and its a no go.

An idea (not great but meh). If a user decides to stop on song, you stop all the songs, and then you start the songs that havent been stopped again. Just and idea...

-----------------------------------
gamer
Fri May 28, 2004 9:53 pm


-----------------------------------
lol dats no good either guru

-----------------------------------
Dan
Fri May 28, 2004 11:13 pm


-----------------------------------
1st off, what are u using process for? The odds are there is a better way to do it with out them unless you are doing somting realy advaced or odd.

Basilky turnings mutlyterading sucks so i do not know if they even put in a way of stoping a process. 

but what you could do is somting like:

process:
     if flag then
           my code
     end if
end process

where flag is a boolean var that is set to true to start and then u just turn it to flase to stop it. Kind of a cheap way of doing it but not much you can do if there is no stop comand for a fork and return dose not work.

P.S. if you got a loop in the process u whould have to add exit when not flag in the loop

-----------------------------------
AsianSensation
Sat May 29, 2004 9:44 am


-----------------------------------
trust me, return will automatically exit a process or procedure

straight from the turing manual:

A return must not appear as a statement in (the outermost level of) a module, nor can it appear in a function.

so anything such as procedures and processes are fine, because they are not a function, or in the outermost level of a module.

var num := 0
process Crap
    loop
        num += 1
        put num
        if num >= 100 then
            return
        end if
    end loop
end Crap

fork Crap


-----------------------------------
guruguru
Sat May 29, 2004 10:11 am


-----------------------------------
Oh sorry my bad. I thought you meant to use use the fork outside of the process... like you fork it and then return... me so stupide  :lol: . Asians way works well, except you may want a boolean instead of the counter. When the user types exit or something, than the boolean variables is put to true. The process has a little if statement that executes if the boolean is false.

v
var stopProcess : boolean := false

process Crap 
    loop 
        % play the music
        if stopProcess then
            return 
        end if 
    end loop 
end Crap 

fork Crap 

if %test for user to say he wants to exit% then
    stopProcess := true
end if

Just a slight mod of AsianS's ingenious code  :) .

-----------------------------------
gamer
Sat May 29, 2004 4:59 pm


-----------------------------------
ok i think return would be good
btw would it be like:

process play
Music.PlayFileLoop ("nameofsong.mp3")
if flag then
return
end if
end play

would it still work that way?? cuz it seems its just gonna stay at the Music.PlayFileLoop line forever without checking the flag
whereas in:
process play
loop
if flag then
return
end if
Music.PlayFile ("nameofsong.mp3")
end loop

this would work for sure, but then again i cant use music.playfilestop (something like this command)

-----------------------------------
guruguru
Sat May 29, 2004 7:20 pm


-----------------------------------
Dam, I tried many versions and for the life of me I can not get it working  :( . 

I am lost now... I even tried Music.PlayFile and that dint work. Maybe someone else knows...

-----------------------------------
Dan
Sat May 29, 2004 8:21 pm


-----------------------------------
That is b/c Music.PlayFile is a bolcking fuction witch means it will not contion on with the code till it is done playing the song.

If you uses Music.PlayFileLoop insted you will not need a process and could stop it at any time in the programe with Music.PlayFileStop.

-----------------------------------
guruguru
Sat May 29, 2004 9:31 pm


-----------------------------------
We gots that... but he want to play multiple songs at the same time, and then stop a single one.

From Turing documentation... The Music.PlayFileStop procedure is used to to stop all music files currently playing. 

That is where the problem resides...  :wink:

-----------------------------------
gamer
Sat May 29, 2004 10:09 pm


-----------------------------------
yup, guru gets my point

-----------------------------------
Dan
Sat May 29, 2004 11:38 pm


-----------------------------------
We gots that... but he want to play multiple songs at the same time, and then stop a single one.

I dont think that is posable in turing. When i tryed it whould stop playing the 1st song and then play the 2nd.

If you did get that working could u post the code i whould like to see it.

-----------------------------------
guruguru
Sun May 30, 2004 12:07 am


-----------------------------------
Ok its not possible then... even HackerDan couldnt get it! :p
A thought just occured, why do you want two songs going at the same time? Is it just curiosity, or do you want to use it in a program? If the latter, can u explain why!?!?

-----------------------------------
Dan
Sun May 30, 2004 12:14 am


-----------------------------------
Aucaly i think it may be possible just not on my comp, i rember somting about this topic b4 whre popleop manged to do but it did not work on some comps deponding on the sound card.

Also i rember somting about diffrent sound formats wav vs mp3 making a diffrence. I will do some more tests and see what happaens.....


Edit: reslotes of my testing

Playing an mp3 and then trying to paly another one at same time:
Stops the 1st one and plays the 2nd

Playing an mp3 and then trying to play a wav one at same time:
Worked

Playing a wav and then trying to play a wav at same time:
Stops the 1st one and plays the 2nd

Playing a wac then trying to play a mp3 at same time:
Worked


Now on how to stop the ones that worked but not others, hummmm:



Music.PlayFileStop stops them all, thats no good.


But all is not lost, think about what we learn from above.... If we play another wav file or mp3 file it replaces the mp3 or wav file all ready going. So lets say we have an mp3 and wav runing at the same time and now we whont to stop the wav, then juts make a blank wav file and play that. It will replace the wav file that is runing and no one will hear anything but the mp3 one.

This way u need no process and it works with just the PlayFileLoop comands

-----------------------------------
gamer
Sun May 30, 2004 11:03 am


-----------------------------------
o cool idea there hacker dan
ok sry but another question came up to mind, is it possible to pause a song while as it is being played in a fork??

-----------------------------------
Dan
Sun May 30, 2004 7:05 pm


-----------------------------------
I dont think so. I dont know of any comand in turing to pause a song, just start and stop all of them.

-----------------------------------
SuperGenius
Sun May 30, 2004 8:23 pm


-----------------------------------
if there a way to start a song in the middle of a track...? You would say Music.Play (file.mp3, 01:30) to start it 1m30s in or something like that...

-----------------------------------
gamer
Sun May 30, 2004 8:56 pm


-----------------------------------
supergenius dats not possible i dun think

-----------------------------------
SuperGenius
Sun May 30, 2004 8:57 pm


-----------------------------------
hmph. Schools should move to VB in the first year of comp sci.

-----------------------------------
Dan
Tue Jun 01, 2004 12:15 pm


-----------------------------------
You could just edit the mp3 to start then, but it whould not be posable to do it dynicamly.

And i whould rather uses turing then VB. Turing may suck but it is aucaly more protable then VB (since there is turing for mac) and turing is not made by M$. But VB is much more powerfull then turning and if you cosider many schools all ready uses it for grade 11, i whould rather have VB in grade 10 if they put somting better in grade 11 like C++ or Java.
