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

Username:   Password: 
 RegisterRegister   
 Need help with Music.Play and Music.Sound
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
PianoGirl




PostPosted: Thu Jan 06, 2005 5:53 pm   Post subject: Need help with Music.Play and Music.Sound

I'm currently trying to make a program that will play certain notes depending on the key you press using Turing. However I don't know how to make it so I can play bass clef notes and treble clef notes at the same time.

In turing, you use < or > to raise or lower the octave, but is there any way to make it so that you can play a note one octave lower than the other at the same time?

I tried using Music.Sound to do this and it does work by specifying the different frequencies, but the forking (used for chords) is not working properly and does not sound good.

Please help me out, thanks a bunch!

- Julie
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Thu Jan 06, 2005 8:10 pm   Post subject: (No subject)

You may be out of luck. Turing's sound capabilities are pretty poor. Though I'm not very experienced with them, so I could easily be wrong.
Bored




PostPosted: Thu Jan 06, 2005 9:22 pm   Post subject: (No subject)

You could always create a couple processes and fork to play all of the. And have htes processes run off of a timer. For eaxample:
code:
var timing : array 1 .. 3 of int
process noteOne
    loop
        timing (1) := Time.Elapsed
        if timing (1) >= 5 then
            Music.Play ( .. ...)
            exit
        end if
    end loop
    loop
        timing (1) := Time.Elapsed
        if timing (1) >= 15 then
            Music.Play ( .. ...)
            exit
        end if
    end loop
end noteOne
process noteTwo
    loop
        timing (2) := Time.Elapsed
        if timing (2) >= 10 then
            Music.Play ( .. ...)
            exit
        end if
    end loop
    loop
        timing (2) := Time.Elapsed
        if timing (2) >= 15 then
            Music.Play ( .. ...)
            exit
        end if
    end loop
end noteTwo
fork noteOne
fork noteTwo
loop
    timing (3) := Time.Elapsed
    if timing (3) >= 20 then
        put "Done"
        exit
    end if
end loop

This code would play a sound at five seconds (noteOne) from starting the program, and another at ten seconds (noteTwo) and finally two at 15 seconds (both notes) and would put "done" on the screen at 20 seconds

P.S. You can copy and paste this as a base to start from if you'd like, just remember to replace the .....'s with the proper notes
Cervantes




PostPosted: Thu Jan 06, 2005 10:17 pm   Post subject: (No subject)

hmm, I was playing around, and, based on Bored's idea, came up with this:
code:

process doNote (note : string, duration : int)
    var timeBegin := Time.Elapsed
    loop
        Music.Play ('\'' + note + '\'')
        exit when Time.Elapsed - timeBegin >= duration
    end loop
end doNote

fork doNote ("c", 3000)
fork doNote ("e", 3000)
fork doNote ("g", 3000)


I think it's a good example of a.) how Turing's Music/Sound capabilities suck and b.) how Turing's processes suck. Razz
Bored




PostPosted: Thu Jan 06, 2005 10:50 pm   Post subject: (No subject)

Crevantes i've expanded a bit on your idea and added my own in heres a working simple code.
code:
var timeBegin : array 1 .. 3 of int
process noteOne (note : string, duration : int)
    timeBegin (1) := Time.Elapsed
    loop
        Music.Play (note)
        exit when Time.Elapsed - timeBegin (1) >= duration
    end loop
    return
end noteOne
process noteTwo (note : string, duration : int)
    timeBegin (2) := Time.Elapsed
    loop
        Music.Play (note)
        exit when Time.Elapsed - timeBegin (2) >= duration
    end loop
    return
end noteTwo
process noteThree (note : string, duration : int)
    timeBegin (3) := Time.Elapsed
    loop
        Music.Play (note)
        exit when Time.Elapsed - timeBegin (3) >= duration
    end loop
    return
end noteThree
loop
    if Time.Elapsed >= 500 then
        fork noteOne ("c", 250)
        fork noteTwo ("e", 250)
        exit
    end if
end loop
loop
    if Time.Elapsed >= 1000 then
        fork noteOne ("c", 250)
        fork noteTwo ("a", 250)
        exit
    end if
end loop
loop
    if Time.Elapsed >= 1500 then
        fork noteOne ("c", 250)
        fork noteTwo ("e", 250)
        fork noteThree ("a", 250)
        exit
    end if
end loop

Even though it's pretty simple right now with more processes and some time to right out all the timing loops you could compose some pretty cool pieces
MihaiG




PostPosted: Thu Jan 06, 2005 10:57 pm   Post subject: (No subject)

he he he
heres a good thing...

code:

loop
%Cantina
play ("4a,>4d,<4a,>4d,<4a,>4d,<4a,8a-,4a,4a,8a-,4a,4g,8g-,4g,4f,4d")
play ("4a,>4d,<4a,>4d,<4a,>4d,<4a,8a-,4a,4a,8a-,4a,>4c,4c,<8b-,4g,4f,4d")
play ("4a,8f,4a,8p,4a,8f,4a,4a,8f,4a-,4a,4f,4d")
play ("4a,8f,4a,8p,4a,8f,4a,4a,8f,4a-,4a,2g,8f,2d")
play ("4a,8f,4a,8p,4a,8f,4a,4a,8f,4a-,4a,4f,4d")
play ("2d,2f,4a-,2a,>2c,2e-,2d,2c,2d,<1a")
%Sonic the hedgehog casino theme(Sonic 2)
play("2c,>4e-,2c,4g-,2f,2e-,4c,<2g,4b-,4a-,2g,4e,4e,2e,4e")
play("4f,4e,4a-,2e,4e,2a,2e,2c,4d,4c,4e-,4d,4c,4d,4c,4e,4e")
play("2e,4e,4f,4e,4a-,2e,4e,2a,2b,>2c,<2a,2g,4e,2c,2d,2a,2g")
play("4e,2c,2d,2a,2g,4e,2c,2d,1e-")
%Sonic the hedgehog boss theme(Sonic 2)
play(">4c,<4a,2a,>4c,<4a,2a")
play(">2f,2e,2d,2e")
play("4c,<4a,2a,>4c,<4a,2a")
play(">2f,2e,4e-,2a-,2e,2a")
play("<4a,4b,>2c,2d,2c,<4b,>2c,<4b,4g,e4,2g")
play("4a,4b,>2c,2d,2c,<4b,>4c,4d,4e-,1e")
play("<4a,4b,>2c,2d,2c,<4b,>2c,<4b,4g,e4,2g")
play("4a,4b,>2c,2d,2c,<4b,>4c,4d,4e-,1e<")
play(">4c,<4a,2a,>4c,<4a,2a")
play("2f,2e,2d,2e")
play("4c,<4a,2a,>4c,<4a,2a")
play("2f,2e,4e-,2a-,2e,2a")
play("<4a,4b,>2c,2d,2c,<4b,>2c,<4b,4g,e4,2g")
play("4a,4b,>2c,2d,2c,<4b,>4c,4d,4e-,1e")
play("<4a,4b,>2c,2d,2c,<4b,>2c,<4b,4g,e4,2g")
play("4a,4b,>2c,2d,2c,<4b,>4c,4d,4e-,1e")
play("<<4c")
end loop

make cool songs...i made them using my musical ear
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  [ 6 Posts ]
Jump to:   


Style:  
Search: