Computer Science Canada

Import Sound

Author:  Smarteez [ Tue Dec 05, 2006 6:47 pm ]
Post subject:  Import Sound

how do you import sound into a program?

Author:  Dan [ Tue Dec 05, 2006 6:52 pm ]
Post subject: 

Just like in your last post using F10 (the turing refernce) and looking threw the Turing Tutorials on this site would help you out alot. You can also use the search features to find the tutoral you are looking for fast. If you did you whould have found thess tutorials that tell you how to use sound in turing:

Another old one but still should work: http://www.compsci.ca/v2/viewtopic.php?t=190&highlight=sound

A more complicated one about using frequencys:
http://www.compsci.ca/v2/viewtopic.php?t=9524&highlight=sound


Edit: Some of the new versions of Turing add in new music and sound commands witch you might whont to look up in your help files.

Author:  Smarteez [ Tue Dec 05, 2006 7:06 pm ]
Post subject: 

alright, I read that but how do i get it in the background not stopping anything?

Author:  Dan [ Tue Dec 05, 2006 7:09 pm ]
Post subject: 

That is in the 1st tutorial under How to use the code ->Use other code the same time as play , instead of a play use a Music.PlayFile. I am realtive shure that new versons of turing have a non blocking verson of Music.PlayFile but i just formated so i do not have them instaled to check.

Edit: Example:

code:

process playstuff
       Music.PlayFile ("filename")
end playstuff

fork playstuff


This whould play the file once as it runs any code under the fork line.

P.S. if some one rembers the newerverson of the comand that dose not need processes pleases post it.

Author:  Clayton [ Tue Dec 05, 2006 9:37 pm ]
Post subject: 

The new version of the command which is the same as what you have done there is Music.PlayFileReturn(songName : string)

or, if you want it to play continuously (ie over and over again)

Music.PlayFileLoop(songName : string)

Author:  Smarteez [ Wed Dec 06, 2006 4:55 pm ]
Post subject: 

ok, I am really not getting this...here is the code once again and could somebdoy show me where i put the fork or whatever that gets it in the background?

code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TO DO:
% Import sound in background
% Import Game over sound
% Insert Timer
% Change fonts
% Get Background for level
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
setscreen ("graphics:800;600")
setscreen ("offscreenonly")
setscreen ("nocursor")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Declaration for level out lines and players' box                                  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
type Box :
    record
        x1, x2, y1, y2 : int
    end record
var box : array 1 .. 14 of Box
var px1, py1, px2, py2 : int
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Declaration for the pressing down of a button function                            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var chars : array char of boolean
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Setting of the variables for the map layout                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
box (1).x1 := 30
box (1).y1 := 0
box (1).x2 := 30
box (1).y2 := 250
box (2).x1 := 0
box (2).y1 := 0
box (2).x2 := 0
box (2).y2 := 280
box (3).x1 := 0
box (3).y1 := 280
box (3).x2 := 60
box (3).y2 := 280
box (4).x1 := 60
box (4).y1 := 280
box (4).x2 := 60
box (4).y2 := 150
box (5).x1 := 30
box (5).y1 := 120
box (5).x2 := 90
box (5).y2 := 120
box (6).x1 := 90
box (6).y1 := 120
box (6).x2 := 90
box (6).y2 := 250
box (7).x1 := 60
box (7).y1 := 280
box (7).x2 := 500
box (7).y2 := 280
box (8).x1 := 90
box (8).y1 := 250
box (8).x2 := 530
box (8).y2 := 250
box (9).x1 := 530
box (9).y1 := 250
box (9).x2 := 530
box (9).y2 := 500
box (10).x1 := 500
box (10).y1 := 280
box (10).x2 := 500
box (10).y2 := 470
box (11).x1 := 530
box (11).y1 := 500
box (11).x2 := 480
box (11).y2 := 500
box (12).x1 := 500
box (12).y1 := 470
box (12).x2 := 450
box (12).y2 := 470
box (13).x1 := 450
box (13).y1 := 470
box (13).x2 := 450
box (13).y2 := 600
box (14).x1 := 480
box (14).y1 := 500
box (14).x2 := 480
box (14).y2 := 600
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main Menu                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
colorback (14)
put "Welcome to Paul's Maze Game"
put "Use your arrow keys to move the box through the maze in the shortest time.Press any key to continue."
Input.Pause
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Procedure                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure getKey
    var ch : string (1)
    getch (ch)
end getKey

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Starting Position of square                                                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
py1 := 4
px1 := 4
py2 := 24
px2 := 24
drawfillbox (px1, py1, px2, py2, 1)
getKey
loop
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Level 1 Maze Layout                                                                   %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    cls
    drawfillbox (box (1).x1, box (1).y1, box (1).x2, box (1).y2, 1)
    drawfillbox (box (2).x1, box (2).y1, box (2).x2, box (2).y2, 1)
    drawfillbox (box (3).x1, box (3).y1, box (3).x2, box (3).y2, 1)
    drawfillbox (box (4).x1, box (4).y1, box (4).x2, box (4).y2, 1)
    drawfillbox (box (5).x1, box (5).y1, box (5).x2, box (5).y2, 1)
    drawfillbox (box (6).x1, box (6).y1, box (6).x2, box (6).y2, 1)
    drawfillbox (box (7).x1, box (7).y1, box (7).x2, box (7).y2, 1)
    drawfillbox (box (8).x1, box (8).y1, box (8).x2, box (8).y2, 1)
    drawfillbox (box (9).x1, box (9).y1, box (9).x2, box (9).y2, 1)
    drawfillbox (box (10).x1, box (10).y1, box (10).x2, box (10).y2, 1)
    drawfillbox (box (11).x1, box (11).y1, box (11).x2, box (11).y2, 1)
    drawfillbox (box (12).x1, box (12).y1, box (12).x2, box (12).y2, 1)
    drawfillbox (box (13).x1, box (13).y1, box (13).x2, box (13).y2, 1)
    drawfillbox (box (14).x1, box (14).y1, box (14).x2, box (14).y2, 1)
    Input.KeyDown (chars)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %Game over check                                                                      %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    for i : 1 .. upper (box)
        if px2 >= box (i).x1 and px1 <= box (i).x2 and py2 >= box (i).y1 and py1 <= box (i).y2 then
            put "GAME OVER"
            var clown : int
            clown := Pic.FileNew ("pics/clown.jpg")
            Pic.Draw (clown, 0, -100, picCopy)
            Pic.Free (clown)
        end if
    end for
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Movement of the player's square                                                       %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if chars (KEY_UP_ARROW) then
        py1 := py1 + 1
        py2 := py2 + 1
        drawfillbox (px1, py1, px2, py2, 1)
    elsif chars (KEY_DOWN_ARROW) then
        py1 := py1 - 1
        py2 := py2 - 1
        drawfillbox (px1, py1, px2, py2, 1)
    elsif chars (KEY_LEFT_ARROW) then
        px1 := px1 - 1
        px2 := px2 - 1
        drawfillbox (px1, py1, px2, py2, 1)
    elsif chars (KEY_RIGHT_ARROW) then
        px1 := px1 + 1
        px2 := px2 + 1
        drawfillbox (px1, py1, px2, py2, 1)
    end if
    View.Update
    getKey
    cls
end loop

Author:  Smarteez [ Wed Dec 06, 2006 8:03 pm ]
Post subject: 

Alright...i fixed it Very Happy but now once again, i have another problem

i want it so that the background music stops playing and a picture with a noise pop up at the same time...BUT, it says the process cannot be done at that level of the code...wat am i to do?

code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %Game over check                                                                      %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    for i : 1 .. upper (box)
        if px2 >= box (i).x1 and px1 <= box (i).x2 and py2 >= box (i).y1 and py1 <= box (i).y2 then
            put "GAME OVER"
            var clown : int
            clown := Pic.FileNew ("pics/clown.jpg")           
            Pic.Draw (clown, 0, -100, picCopy)
            Pic.Free (clown)
        end if
    end for


That is where I need the music to stop and the other noise to start with the picture...

Author:  Clayton [ Thu Dec 07, 2006 12:15 pm ]
Post subject: 

Use Music.Stop to stop your music, and then draw your picture with some sort of sound right after that. (ie. using the Music.Sound (frequency, durationg : int))


: