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

Username:   Password: 
 RegisterRegister   
 mario
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bored_hacker




PostPosted: Thu Jul 14, 2005 10:31 am   Post subject: mario

i'm working on a mario game right now and i wanted to make it old arcade style (including the music). what i've posted is more than just the mario song, it's also a very useful template for writing music in turing. you may use this template in any projects you wish but please give me some kind of credit whether it's a comment in a file or if my screen name moves across the screen. anyway, here's the music.

code:
const tempo := 120 %Tempo is at a quarter base
%Note-Duration (or rests)
%Normal-Notes
const w := round (2000 * (120 / tempo)) %Whole notes
const h := round (1000 * (120 / tempo)) %Half Notes
const q := round (500 * (120 / tempo))  %Quarter Notes
const e := round (250 * (120 / tempo))  %Eighth Notes
const s := round (125 * (120 / tempo))  %Sixteenth Notes
%Dotted-Notes
const w_dot := round (w * 1.5)
const h_dot := round (h * 1.5)
const q_dot := round (q * 1.5)
const e_dot := round (e * 1.5)
const s_dot := round (s * 1.5)
%Triplet-Notes
const w3 := round (w * 2 / 3)
const h3 := round (h * 2 / 3)
const q3 := round (q * 2 / 3)
const e3 := round (e * 2 / 3)
const s3 := round (s * 2 / 3)
%Notes
const G := 392
const Gs := 415
const Ab := 415
const A := 440
const As := 466
const Bb := 466
const B := 494
const C := 523
const Cs := 554
const Db := 554
const D := 587
const Ds := 622
const Eb := 622
const E := 659
const F := 698
const Fs := 740
const Gb := 740
%To raise it by an octave, times it by 2
%To lower it by an octave, divide it by 2
%Mario
Music.Sound (E, s)
Music.Sound (E, e)
Music.Sound (E, s)
delay (s)
Music.Sound (C, s)
Music.Sound (E, e)
Music.Sound (G * 2, q)
Music.Sound (G, q)
for z : 1 .. 2
    Music.Sound (C, q3)
    Music.Sound (G, q3)
    Music.Sound (E div 2, q3)
    delay (s)
    Music.Sound (A, e)
    Music.Sound (B, e)
    Music.Sound (As, s)
    Music.Sound (A, e)
    Music.Sound (G, e3)
    Music.Sound (E, e3)
    Music.Sound (G * 2, e3)
    Music.Sound (A * 2, e)
    Music.Sound (F, s)
    Music.Sound (G * 2, s)
    delay (s)
    Music.Sound (E, e)
    Music.Sound (C, e_dot)
    Music.Sound (D, s)
    Music.Sound (B, s)
end for
for z : 1 .. 2
    delay (e)
    Music.Sound (G * 2, s)
    Music.Sound (Fs, s)
    Music.Sound (F, s)
    Music.Sound (Ds, e)
    Music.Sound (E, s)
    delay (s)
    Music.Sound (Gs, s)
    Music.Sound (A, s)
    Music.Sound (C, e)
    Music.Sound (A, s)
    Music.Sound (C, s)
    Music.Sound (D, s)
    delay (e)
    Music.Sound (G * 2, s)
    Music.Sound (Fs, s)
    Music.Sound (F, s)
    Music.Sound (Ds, e)
    Music.Sound (E, s)
    delay (s)
    Music.Sound (C * 2, e)
    Music.Sound (C * 2, s)
    Music.Sound (C * 2, q)
    delay (e)
    Music.Sound (G * 2, s)
    Music.Sound (Fs, s)
    Music.Sound (F, s)
    Music.Sound (Ds, e)
    Music.Sound (E, s)
    delay (s)
    Music.Sound (Gs, s)
    Music.Sound (A, s)
    Music.Sound (C, e)
    Music.Sound (A, s)
    Music.Sound (C, s)
    Music.Sound (D, s)
    delay (e)
    Music.Sound (Ds, e_dot)
    Music.Sound (D, e_dot)
    Music.Sound (C, q)
    delay (q)
end for
Music.Sound (C, s)
Music.Sound (C, e)
Music.Sound (C, e)
Music.Sound (C, s)
Music.Sound (D, e)
Music.Sound (E, s)
Music.Sound (C, e)
Music.Sound (A, s)
Music.Sound (G, q)
Music.Sound (C, s)
Music.Sound (C, e)
Music.Sound (C, e)
Music.Sound (C, s)
Music.Sound (D, s)
Music.Sound (E, s)
delay (h)
Music.Sound (C, s)
Music.Sound (C, e)
Music.Sound (C, e)
Music.Sound (C, s)
Music.Sound (D, e)
Music.Sound (E, s)
Music.Sound (C, e)
Music.Sound (A, s)
Music.Sound (G, q)
Music.Sound (E, s)
Music.Sound (E, e)
Music.Sound (E, e)
Music.Sound (C, s)
Music.Sound (E, e)
Music.Sound (G * 2, q)
Music.Sound (G, q)
for z : 1 .. 2
    Music.Sound (C, q3)
    Music.Sound (G, q3)
    Music.Sound (E div 2, q3)
    delay (s)
    Music.Sound (A, e)
    Music.Sound (B, e)
    Music.Sound (As, s)
    Music.Sound (A, e)
    Music.Sound (G, e3)
    Music.Sound (E, e3)
    Music.Sound (G * 2, e3)
    Music.Sound (A * 2, e)
    Music.Sound (F, s)
    Music.Sound (G * 2, s)
    delay (s)
    Music.Sound (E, e)
    Music.Sound (C, e_dot)
    Music.Sound (D, s)
    Music.Sound (B, s)
end for
for z : 1 .. 2
    Music.Sound (E, s)
    Music.Sound (C, e)
    Music.Sound (G, e_dot)
    Music.Sound (Gs, e)
    Music.Sound (A, s)
    Music.Sound (F, e)
    Music.Sound (F, s)
    Music.Sound (A, q)
    Music.Sound (B, e3)
    Music.Sound (A * 2, e3)
    Music.Sound (A * 2, e3)
    Music.Sound (A * 2, e3)
    Music.Sound (G * 2, e3)
    Music.Sound (F, e3)
    Music.Sound (E, s)
    Music.Sound (C, e)
    Music.Sound (A, s)
    Music.Sound (G, q)
    Music.Sound (E, s)
    Music.Sound (C, e)
    Music.Sound (G, e_dot)
    Music.Sound (Gs, e)
    Music.Sound (A, s)
    Music.Sound (F, e)
    Music.Sound (F, s)
    Music.Sound (A, q)
    Music.Sound (B, s)
    Music.Sound (F, e)
    Music.Sound (F, s)
    Music.Sound (F, e3)
    Music.Sound (E, e3)
    Music.Sound (D, e3)
    Music.Sound (C, h * z)
end for
[/code]
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Thu Jul 14, 2005 11:07 am   Post subject: (No subject)

Sounding pretty good...just wondering if you had any particular reason for using Sound() instead of play() for this job?
Since this music is transcribable on piano, you should be able to figure out any note used. I can see the problem of having the notes short enough, since Turing doesn't really support notes much shorter than a semi-quaver (or was it quaver at best)? Atop that, you can't even do something as mundane as a dotted-quaver!

[Edit:]
For instance:

Turing:

var mario : array 1 .. 5 of string
mario (1) := ">8e4e e 8c 4e 2g <g>"
mario (2) := "4c<2g 2e 4abb-a g>ega 8e4g 8e<c>d <2b4c"
mario (3) := "4g 2e 4abb-a g>ega 8e4g 8e<c>d <2b"
mario (4) := ">8gf+f4d+4e<g+a>4c<8a>c4d 8gf+f4d+4e>4c8c4c"
mario (5) := "<8gf+f4d+4e <g+a>4c<8a>c2d 2e- d c"

for i : 1 .. 5
    play (mario (i))
end for



I know it sounds a bit off...but there's not much one can do when one has can't really use rests now can one? Sure I could use 'p' as a rest, but that completely screws up the melody. So instead, I just stretch out the notes before the rest!
[Gandalf]




PostPosted: Thu Jul 14, 2005 12:50 pm   Post subject: (No subject)

...Hence he used Music.Sound. It's actually a pretty good idea, making your own little 'instrument' using the frequencies. With this you can add things like sharps/flats, tempo, better duration/pauses and other things like that. Now that I think about it, Turing's Music.Play is just a waste of compiled space, it doesn't have too many things that it should.

Good job, very nice music and great idea Smile.

*edit* It's too bad you can't change this to work with the piano sounds. The high pitched music gets annoying pretty fast Sad.

*edit2* Now to just add everything else that good music requires...
bored_hacker




PostPosted: Thu Jul 14, 2005 4:30 pm   Post subject: (No subject)

Quote:
Sounding pretty good...just wondering if you had any particular reason for using Sound() instead of play() for this job?


I want the music to be old arcade style which is a bunch of beeps instead of a piano or stuff like that.
RscMod




PostPosted: Mon Sep 26, 2005 12:03 pm   Post subject: Good Good

it is quite good but at the end it freezes on slower comps
[Gandalf]




PostPosted: Tue Sep 27, 2005 4:07 pm   Post subject: (No subject)

That is most probably compeltely not related to his programming.

Try not to revive such old topics.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: