Computer Science Canada [Tutorial]How to use sound and music in Turing |
Author: | Dan [ Thu Dec 19, 2002 8:46 pm ] | ||||||||||
Post subject: | [Tutorial]How to use sound and music in Turing | ||||||||||
How to use sound and music in Turing There are several different methods of adding music and sound to your games and programs. The main methods are using the play command, the Music command and the sound comand. The Code: Play play ("Notes") notes are a b c d e f g > and < will change the octave flats are - ; sharps are + to change the length of the note put a number in front of it. 1 (whole note), 2 (half note), 4 (quarter note), 8 (eight note) and 6 (sixteenth note) p will add rests to the song Music Music.PlayFile ("filename") %play a sound or music file Music.SoundOff %stop playing the file Note: playable file types are wav, snd, mod, and mid (mp3 too in newer turings) Sound sound (frequency, duration) %time is in milliseconds How to use the code: Note: Turing will play the whole file or string of notes before it cautions along with the rest of the code. To run music or sound and run your program at the same time you need to use a fork Play code Simple examples
Use other code the same time as play
Music code
Note: the .mid file or the music file you use must be in the same dir as your Turing file or you must specify the dir where you put the files name. Sound Code Ex 1. sound (440, 1000) % this will play a sound that is 440 herzts for 1 seconed Ex 2.
Ex 3.
this is an old turale form my old site, if you have any comanets about it plzs post and let us know. also if you see anything wrong with it wich is very likey that whode also help if you posted and let us know. Edit - Jay Lo told us of the info below play CD files yes! now you can make your very own CD player in turing! ladies and gentlemen, here is your code: Syntax: Music.PlayFile ("cd") - plays entire cd Music.PlayFile ("cd:x") - where x is the track number |
Author: | cutecotton [ Mon Dec 23, 2002 1:03 am ] |
Post subject: | |
thank you soo much, you are a blessing from god, i was JSUT going to ask around to see how you can do that...ur a lifesaver! thank you! |
Author: | Danger Zone [ Thu Jun 05, 2003 9:55 am ] |
Post subject: | |
I think my school has a older version of turing, all those play note commands work and stuff but when I go to listen to the thing, nothing comes out. Any Idea what may be causing this? I know different frequenceys work like sound(100,100) that works but never the notes like F or D etc none of them work. |
Author: | Tony [ Thu Jun 05, 2003 12:58 pm ] |
Post subject: | |
how old is your "older" version? |
Author: | PaddyLong [ Thu Jun 05, 2003 3:33 pm ] |
Post subject: | |
I know that the play() command works in oot 3.1 |
Author: | BlAcK TuRtLe [ Thu Jun 05, 2003 4:52 pm ] |
Post subject: | |
Wow so that's how you do it. Now I can put sound in my end of year program. Thanks alot. |
Author: | JayLo [ Thu Jun 05, 2003 8:58 pm ] |
Post subject: | |
You forgot CD files yes! now you can make your very own CD player in turing! ladies and gentlemen, here is your code: Syntax: Music.PlayFile ("cd") - plays entire cd Music.PlayFile ("cd:x") - where x is the track number |
Author: | Danger Zone [ Fri Jun 06, 2003 9:01 am ] |
Post subject: | |
my version of turing is 4.0.0 at least that's what help says when I go to "about turing" |
Author: | heythere [ Thu Jun 19, 2003 11:46 am ] |
Post subject: | |
if i use a lot of sound does it lag the program im running? |
Author: | JSBN [ Thu Jun 19, 2003 11:49 am ] |
Post subject: | |
it can on a slower computer. THe computers that i have @ school really are quite bad, so on those computers, if u have sound, the program barley runs. But on my computer the program runs perfectly. |
Author: | Asok [ Thu Jun 19, 2003 3:37 pm ] |
Post subject: | |
JSBN, those computers don't have sound cards. |
Author: | JayLo [ Thu Jun 19, 2003 5:58 pm ] | ||
Post subject: | |||
rawr. cdplayer.
|
Author: | HyperFlexed [ Sat Nov 06, 2004 4:26 pm ] |
Post subject: | |
Jay Lo.... 'ANY' is not in the export list of 'GUI' I got that error when I tried your code. |
Author: | atrain [ Sun Jan 30, 2005 2:00 pm ] |
Post subject: | |
any way to have music run in the background?? it stops the program untill the music is done playing, but i want it as background... |
Author: | atrain [ Sun Jan 30, 2005 2:02 pm ] | ||
Post subject: | |||
nevermind: process DoMusic loop Music.PlayFile ("branden3.wav") end loop end DoMusic fork DoMusic
|
Author: | Cervantes [ Sun Jan 30, 2005 2:56 pm ] |
Post subject: | |
If you have Turing 4.0.5, you can use Music.PlayFileLoop or Music.PlayFileReturn. |
Author: | ssr [ Sun Jan 30, 2005 4:29 pm ] |
Post subject: | |
just speakig of music what music file extensions are supported in Turing I know mp3, wav, and is that it? |
Author: | Cervantes [ Sun Jan 30, 2005 4:38 pm ] |
Post subject: | |
and midi Check the help file for these things. |
Author: | atrain [ Sun Jan 30, 2005 9:27 pm ] |
Post subject: | |
mp3 was introduced in 4.0, i looked through the changelog.... my school uses macs, and the latest version they have is OOT 4.0, so i have to look things up to see if i can use them.... |
Author: | illu45 [ Sun Mar 13, 2005 5:44 pm ] |
Post subject: | |
Hey, I was wondering, in regards to the Sound playing thing, if there was any way to include slurs or ties, or change the tempo, since its a little difficult to do some of the things I'd like to without slurs/ties or doubling note values. |
Author: | [Gandalf] [ Mon Mar 14, 2005 1:39 am ] |
Post subject: | |
No, in the current version of Turing there are no slurs/ties and most other music features. It would improve the music capabilities and allow for more lagless background music - so I hope to see it in future versions too! |
Author: | Klick [ Thu Mar 31, 2005 4:24 pm ] |
Post subject: | |
There should also be a way to get 2 hands in there, so nice harmony can be made, or even the capability to change instruments, then when I am ahead in comp class as usuall, I can write a symphony. Some times I think I really have no life lol. |
Author: | [Gandalf] [ Thu Mar 31, 2005 5:01 pm ] |
Post subject: | |
Can't you just use a process and have two pianos playing at the same time? Ya, more instruments and higher capabilities would be very nice. |
Author: | GlobeTrotter [ Thu Mar 31, 2005 6:01 pm ] |
Post subject: | |
nope, can't just use a process. It simply won't work. It will play the files in between each other, sort of. |
Author: | bolufromthesoo [ Sat May 14, 2005 7:54 pm ] | ||
Post subject: | |||
Quote: Music.SoundOff %stop playing the file
Hi, (first post @ CompSci 8)). I was wondering where and how you use "Music.SoundOff". I have:
but I have no idea how to stop the music when the code is finished. I know the last post was old, but I really need help. |
Author: | bolufromthesoo [ Sat May 14, 2005 9:04 pm ] |
Post subject: | |
Sry. for double post... I figured it out. It was suppose to be : Quote: Music.PlayFileStop Can't blame me.. typo. ...right? |
Author: | [Gandalf] [ Sat May 14, 2005 9:08 pm ] |
Post subject: | |
You could have just edited your previous post... *still waiting for Turing update * |
Author: | n_n [ Mon Sep 19, 2005 2:49 pm ] |
Post subject: | |
I'm just wondering. Is it possible to make a song fade in/out? Specifically a MIDI. Thanks in advanced. |
Author: | Tony [ Mon Sep 19, 2005 3:06 pm ] |
Post subject: | |
I don't think that Turing has such capabilities at the moment. Depending on what you're trying to do, it might be possible to simply hardcode the fade using a 3rd party program such as Sound Forge |
Author: | [Gandalf] [ Mon Sep 19, 2005 3:30 pm ] |
Post subject: | |
Usually, the point of a midi is that it is all computer generated, making editing it quite easy compared to editing wavs, mp3s, etc. Any midi editing program will have a 'volume' feature that you can decrease over time. |
Author: | Tony [ Mon Sep 19, 2005 4:06 pm ] |
Post subject: | |
if you understand the MIDI format, it is possible to open it as text/binary file and edit it with Turing. Though once again, that would be editing the source file, not controlling volume real-time. |
Author: | ZeroPaladn [ Wed Sep 21, 2005 9:20 am ] |
Post subject: | |
nice tutorial (white the rest of you were ranting on about compatiable files, i actually read the tutorial ). regardless, i though .wma was compatiable with turing 4.0.5 |
Author: | DIIST [ Wed Dec 14, 2005 10:17 pm ] |
Post subject: | |
Nice Tutorial! Thought I am wondering, is it possible to seek to a specific time in the music file using Turing! |
Author: | Cervantes [ Thu Dec 15, 2005 1:44 pm ] |
Post subject: | |
thuvs wrote: Nice Tutorial! Thought I am wondering, is it possible to seek to a specific time in the music file using Turing!
Nooope. (But that doesn't stop you from experimenting. You may find a way: you never know) |
Author: | chrispminis [ Thu Dec 15, 2005 10:18 pm ] |
Post subject: | |
Hmmm... this Sound Forge you speak of... Sounds useful. Where might I acquire this Sound Forge? And would it cost any money? If so, how much and are there any alternatives to Sound Forge that are free to use, but perhaps less powerful, but still useful. |
Author: | solblade05 [ Wed Jan 04, 2006 1:41 pm ] |
Post subject: | |
is it possible to keep the music playing for a certain part of the program, then when the user enters another part of the program i can change the music |
Author: | Cervantes [ Wed Jan 04, 2006 3:36 pm ] |
Post subject: | |
Just use Music.Stop I think it is, and play the next file. |
Author: | solblade05 [ Wed Jan 04, 2006 3:52 pm ] |
Post subject: | |
There isn't that command in turing c 4.04 oh, also can i uses processes over and over again? for the music that i need in the different parts of my program (with the fork)? |
Author: | [Gandalf] [ Wed Jan 04, 2006 3:53 pm ] |
Post subject: | |
Or if the files are the same format, iirc you can just play the next song over the current one without using Music.PlayFileStop(). *edit* Don't fork your music, use Music.PlayFileLoop(). If your version doesn't have Music.PlayFileStop() then just use the method I describe. Just make sure all the music is in the same music format (.mp3, .wav, whatever it is). |
Author: | solblade05 [ Wed Jan 04, 2006 3:55 pm ] |
Post subject: | |
How do i do that? |
Author: | [Gandalf] [ Wed Jan 04, 2006 4:21 pm ] | ||
Post subject: | |||
Ok, assuming you have either Music.PlayFile() or Music.PlayFileLoop(), just make sure that in the folder that you have the source code in has your music, all in the same format (with the same extention). An MP3 has a .mp3 extention, so if you want to use that then make sure all your background music is an MP3. Then, just have something like this in your program, this being a highly simple example.
|
Author: | solblade05 [ Wed Jan 04, 2006 6:49 pm ] |
Post subject: | |
Music.PlayFileLoop is not in Turing 4.04 thus i cant use that is it possible that if i use Music.PlayFileStop, then use another process, and Music.PlayFile? |
Author: | stinger4life [ Mon Jan 16, 2006 4:56 pm ] |
Post subject: | |
in my game i want my bg music to run all the way until they die...i have many sound however so if i use Music.PlayFileStop will it only stop my bg music or even the other sounds? |
Author: | siege [ Wed May 31, 2006 1:00 pm ] |
Post subject: | |
can you play mp3 files? or must it be in wav or midi format? |
Author: | Tony [ Wed May 31, 2006 3:13 pm ] |
Post subject: | |
it's part of the tutorial Hacker Dan wrote: Note: playable file types are wav, snd, mod, and mid (mp3 too in newer turings) |
Author: | NE0 [ Fri Jun 02, 2006 3:51 pm ] |
Post subject: | |
i know this might not be the right place to ask but is there a way ( i've already searched ) to load the music files on a loading screen or at another time in my game because i have my music file in a process statement but it has to load the music file before i start to play my game creating atleast a 10 second wait and the music file isnt really that big but im running it of a floopy (i have to because im switching computers alot). if there is a way can you guys help me? regards NE0 |
Author: | Delos [ Fri Jun 02, 2006 3:58 pm ] |
Post subject: | |
I would suspect that this is directly a result of using a floppy. Simply paste its contents onto the harddrive of whatever PC you're at and work from there. Don't forget to resave after. If this doesn't work, repost this question in [Turing Help] and attach some code as well so we get a better idea of your situation. Also, if you're using a process, you might want to look into Music.PlayFileReturn() instead, since that will make your life easier. |
Author: | little_guy9 [ Mon Apr 16, 2007 12:21 am ] |
Post subject: | Re: [Tutorial]How to use sound and music in Turing |
Would there be some coding that could replace Music.PlayFileLoop, for those of us who don't have that version? |
Author: | Clayton [ Mon Apr 16, 2007 10:04 am ] |
Post subject: | Re: [Tutorial]How to use sound and music in Turing |
This sort of question would've been better suited to be posted in [Turing Help]. However, it's here now so I'll answer it. Seeing as you don't have Music.PlayFileLoop() at your disposal, you simply need to loop within a process and have a (global) variable to keep track of whether or not to keep playing or not. This would be accompanied by a Music.Stop() in your mainline that will trigger your boolean to be false, thus exiting your process. |
Author: | MichaelM [ Fri Jan 25, 2008 4:46 pm ] |
Post subject: | Re: [Tutorial]How to use sound and music in Turing |
I was just reading this topic and I thought this link might be helpful for anyone trying to program some music by frequency: http://www.phy.mtu.edu/~suits/notefreqs.html Note you'd have to round the frequencies off. |
Author: | faulkner16 [ Thu Feb 21, 2008 6:39 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
what is the A with the ^ over it? |
Author: | harishmabish [ Sat Mar 29, 2008 5:19 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
do wav and other sound type files work better than mp3? because i encoded in mp3, and the sounds seem delayed, so are other formats faster? |
Author: | angelsz [ Tue May 20, 2008 12:10 am ] |
Post subject: | Re: [Tutorial]How to use sound and music in Turing |
How does Music.Soundoff work ? o.o if i have .. Music.PlayFile ("abc.mp3") code code code delay (1000) Music.SoundOff it continues to play.. |
Author: | Tony [ Tue May 20, 2008 12:59 am ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
You should probably notice that none of your "code code code" executes while the sound file is playing. You likely meant to use Music.PlayFileReturn() |
Author: | angelsz [ Tue May 20, 2008 7:50 am ] |
Post subject: | Re: [Tutorial]How to use sound and music in Turing |
oh okay thanks o.o |
Author: | mrt2323 [ Wed Apr 01, 2009 11:32 pm ] |
Post subject: | Re: [Tutorial]How to use sound and music in Turing |
So umm playing mp.3 files in the background? how do u do that? plz and thank you |
Author: | Krocker [ Sat Dec 04, 2010 8:32 am ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
hey guys, i dont get what the fork command is for. whats does it do? Also, how do u stop the music when there is an input. ex in name = john then % End the music% blah blah end if any one? |
Author: | Insectoid [ Sat Dec 04, 2010 6:26 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
Fork executes a process that runs side-by-side with the rest of your program. More recent versions of Turing have the function Music.PlayFileLoop() built in, so there is no need to use processes or fork() anymore. Music.PlayFileLoop() will play loop a sound file while allowing the rest of your program to execute. Music.PlayFileStop() will halt the sound. |
Author: | Dragon20942 [ Sun Jan 02, 2011 1:23 pm ] | ||
Post subject: | Re: [Tutorial]How to use sound and music in Turing | ||
My music creates a lot of lag in the program. Is there any way to eliminate that? Even something like this:
completely wrecks my program. |
Author: | Insectoid [ Sun Jan 02, 2011 1:27 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
You're calling fork in a loop, so every time your program iterates it creates a new instance of moo. With potentially thousands of instances running at a time, this is going to lag. Try putting the fork call outside the loop. |
Author: | Dragon20942 [ Sun Jan 02, 2011 2:07 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
Ok thanks. O_O |
Author: | SirOwnYourFace [ Tue Jan 18, 2011 7:40 pm ] |
Post subject: | Re: [Tutorial]How to use sound and music in Turing |
Some mp3s wont play on turing D:.. |
Author: | Tony [ Tue Jan 18, 2011 8:06 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
It could be encoded in a way that Turing doesn't understand. It could potentially help to re-encode the file with different settings, or export it into another supported format. |
Author: | Feltie [ Sat Jun 04, 2011 2:07 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
It wont work when i try to play the music straight from my turing folder |
Author: | Feltie [ Sat Jun 04, 2011 2:51 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
im not sure which folder to put the file in. do i put it in turing 4.4.1, Support or Examples? |
Author: | Tony [ Sat Jun 04, 2011 3:01 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
You put it in the same folder as the source-code file that you are working with. |
Author: | Raknarg [ Sat Jun 04, 2011 4:29 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
Sometimes it could just be the length of the song. I'm not quite sure if this is right, but i've found that with songs that are over 4 minutes, a lot of them don't work. |
Author: | danthedevil3 [ Fri Sep 13, 2013 8:28 pm ] | ||
Post subject: | |||
JayLo @ Thu Jun 19, 2003 5:58 pm wrote: rawr. cdplayer.
I get an error of, Illegal picture ID number '0'. (Probable cause: picture was not successfully created.). Can someone tell me what is going on? I'm new to this on my first computer science classes in high school. |
Author: | Insectoid [ Fri Sep 13, 2013 8:35 pm ] |
Post subject: | RE:[Tutorial]How to use sound and music in Turing |
That means the image wasn't loaded. The most likely cause is that you do not have a copy of the image. |