Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 concurrency
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jrok311




PostPosted: Fri Apr 01, 2005 10:53 am   Post subject: concurrency

I need to make a program that plays music at the same time as running a process using a fork because when I play music now it disables all other buttons. Here is my code.

code:

import GUI in "%oot/support/lib/GUI"


%procedures
forward proc music

procedure frenchmusic
Music.PlayFile ("ADD .MID FILE HERE")
end frenchmusic

body proc music
    locatexy (50, 400)
    cls
    put "Choose a song to play"
    var frenchsong : int := GUI.CreateButton (50, 200, 120, "french song", frenchmusic)
    var musicbutton : int := GUI.CreateButton (50, 20, 120, "Music", music)
   
end music




%main function
procedure main
    Window.Set (defWinId, "title:J-ROK's Media Centre 2005")
    setscreen ("graphics:700, 500;nobuttonbar")

    colourback (30)
    cls

    var font1 : int
    var font2 : int

    font1 := Font.New ("serif:20")
    font2 := Font.New ("Comic Sans MS:10")       

    Font.Draw ("J-ROK's Media Centre 2005", 200, 450, font1, blue)     
    Font.Draw ("Choose an option to get started", 260, 430, font2, blue)

    var musicbutton : int := GUI.CreateButton (50, 20, 120, "Music", music)
   
end main
%end of main function
   
main
 


loop
    exit when GUI.ProcessEvent
end loop
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Apr 01, 2005 11:01 am   Post subject: (No subject)

Turing:

Music.PlayFileReturn ("ADD .MID FILE HERE")
jrok311




PostPosted: Fri Apr 01, 2005 11:09 pm   Post subject: concurrency

that doesnt work, the first part goes blue so its not one of those turing things.
RaPsCaLLioN




PostPosted: Sat Apr 02, 2005 9:48 am   Post subject: (No subject)

I think ur problem is with that main procedure. Mainline code should just be a loop. And Music.PlayFileReturn is the command u want....

code:
import GUI in "%oot/support/lib/GUI"

%procedures
forward proc music

procedure frenchmusic
    Music.PlayFileReturn ("ADD FILE HERE")
end frenchmusic

body proc music
    locatexy (50, 400)
    cls
    put "Choose a song to play"
    var frenchsong : int := GUI.CreateButton (50, 200, 120, "french song", frenchmusic)
    var musicbutton : int := GUI.CreateButton (50, 20, 120, "Music", music)

end music

%*** MAINLINE ***

Window.Set (defWinId, "title:J-ROK's Media Centre 2005")
setscreen ("graphics:700, 500;nobuttonbar")

colourback (30)
cls

var font1 : int
var font2 : int

font1 := Font.New ("serif:20")
font2 := Font.New ("Comic Sans MS:10")

Font.Draw ("J-ROK's Media Centre 2005", 200, 450, font1, blue)
Font.Draw ("Choose an option to get started", 260, 430, font2, blue)

var musicbutton : int := GUI.CreateButton (50, 20, 120, "Music", music)

loop
    locate (1, 1)
    put Rand.Int (1, 10)
    delay (100)

    exit when GUI.ProcessEvent
end loop
person




PostPosted: Sat Apr 02, 2005 12:50 pm   Post subject: (No subject)

Quote:
that doesnt work, the first part goes blue so its not one of those turing things.


r u sure u typed it rite??

it worx fine for me
Neo




PostPosted: Sat Apr 02, 2005 2:01 pm   Post subject: (No subject)

He must have an earlier version.
lordofall




PostPosted: Sat Apr 02, 2005 11:40 pm   Post subject: (No subject)

y are u using processes they so sloppy instead use GUI.SetNullEventHandler, its really badly documented but basically it works like this

procedure controlMusic
end controlMusic

GUI.SetNullEventHandler(controlMusic)

now whenever no buttons are being clicked it will execute the action procedure control music, though ur gonna havta figure out the code to keep checking the music or playing it from a certain spot (unless it automatically does that) well good luck.
person




PostPosted: Sun Apr 03, 2005 11:06 am   Post subject: (No subject)

y r processes sloppy for music??
Sponsor
Sponsor
Sponsor
sponsor
jrok311




PostPosted: Sun Apr 03, 2005 11:34 am   Post subject: fixed

I found a solution to my problem. I called the procedure with a fork in it for another process, I made that process played the music. Thanks for all your help.
lordofall




PostPosted: Sun Apr 03, 2005 2:09 pm   Post subject: (No subject)

i just thought nullevent handelers better because instead of randomly going back and forth to the music it would play the music whenever nothing is going on with the user tho i guess a human ear wouldn't detect the process.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: