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

Username:   Password: 
 RegisterRegister   
 Unknown Turing Music.PlayFile Delay Error
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jmac4646




PostPosted: Thu Feb 05, 2015 4:11 pm   Post subject: Unknown Turing Music.PlayFile Delay Error

What is it you are trying to achieve?
I have a major problem with sound files that I can't seem to fix.


What is the problem you are having?
So when I try to use Music.PlayFile in my Legend of Zelda game, I have an odd error. The music will play; but only after about a 6500 delay, which has not been added.


Describe what you have tried to solve this problem
I had the problem with the background music, in that the music would only begin to play after 6500, despite the actual music file starting immediately. My programming teacher said "IDK, try shortening the file, it might be taking too long to read it", so I did. I cut the music in half, and it starts instantly. Not just in half the time, but instantly. I now have had the same problem when adding a sound effect for when Link grabs the wooden sword. So, I cut the sound file... There's still a delay. So, I put it in a process... There's still a delay.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
My code for the background music is basically
process backgroundmusic
loop
Music.PlayFile "backgroundmusic.mp3"
end loop
end backgroundmusic

My code for the sound effect is basically
if Link is touching the woodsword then
Pic.Draw Linkwithhisarmup (middle of screen)
Pic.Draw woodsword (above link's hand)
Music.PlayFile "ItemGetSoundEffect.mp3"
annnnnnd that's it. The code is much more organized but that's the gist of it.>

Turing:


if link_woodsword_yn = false and linkX + 12 > 45 * 8 + 290 and linkX + 12 < 45 * 8 + 320 and linkY + 31 = 200 and link_dir = "up" then
        Music.PlayFile "LOZ_NES_ItemGet_SFX.mp3"
        link_woodsword_yn := true
        drawfillbox (664, 200, 690, 256, black)
        Pic.Draw (Link_ItemGet, linkX, linkY, picCopy)
        Pic.Draw (WoodSword_Icon, linkX - 6, linkY + 45, picCopy)
        View.Update
        Music.PlayFile "LOZ_NES_ItemGet_SFX.mp3"
        link_rupee_num := link_rupee_num - 1
        DRAW_MENU_BAR
end if


Please specify what version of Turing you are using
I'm using Turing 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Feb 05, 2015 4:47 pm   Post subject: RE:Unknown Turing Music.PlayFile Delay Error

if I recall correctly, Turing has problems playing multiple music files of the same type at the same time. So if you have an mp3 playing in the background, it might not play your sound effects. A typical work around is to mix formats (e.g. using .midi for background music).

You might also be interested to know about Music.PlayFileReturn, which will not pause while playing music file.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
jmac4646




PostPosted: Thu Feb 05, 2015 4:53 pm   Post subject: Re: Unknown Turing Music.PlayFile Delay Error

Thanks, but I actually do stop the background music before I play the ItemGet sound effect. The code for the background music is:

process LOZ_NES_Overworld_Music
loop
Music.PlayFile ("LOZ_NES_Overworld_Music.mp3")
if music_end = true then
exit
end if
end loop
end LOZ_NES_Overworld_Music

Then, before entering the cave that you get the sword in, I use Music.PlayFileStop and set music end to true. It is only after that you get the wood sword.
However, I will look into .midi for now
jmac4646




PostPosted: Thu Feb 05, 2015 5:08 pm   Post subject: Re: Unknown Turing Music.PlayFile Delay Error

So I have implemented Music.PlayFileReturn for background music, so thanks. However, the ItemGet sound effect actually needs to be music.playfile, as I want link to hold the sword in the air while not being able to move as long as the sound is playing. I am now changing file formats for my sound files, but this will likely not work, and if it does, I will probably get the same problem the next time I try to put in sounds, so I would still like to know why this is occurring with certainty, so I can eliminate this problem from ever happening no matter how many sounds I have in the game.

And I will note to not use multiple sounds of the same file at once, thank you.
Tony




PostPosted: Thu Feb 05, 2015 5:47 pm   Post subject: Re: Unknown Turing Music.PlayFile Delay Error

jmac4646 @ Thu Feb 05, 2015 5:08 pm wrote:
So I have implemented Music.PlayFileReturn for background music, so thanks.


I didn't mean for that to be used with background music. Check out the documentation -- I've linked to previously. The music will stop at the end of the file, which is probably not what you want for looping background music. Maybe Music.PlayFileLoop?

Quote:
I use Music.PlayFileStop and set music end to true.

Is there a chance for music to stop and if music_end = true then to run before you "set music end to true"?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
jmac4646




PostPosted: Thu Feb 05, 2015 6:02 pm   Post subject: Re: Unknown Turing Music.PlayFile Delay Error

Sorry, I'll have to fix the background music after this.
But its the GetItem sound effect that won't work automatically, not the background music. The background music is fine. I'm using the simple Music.PlayFile for ItemGet_SFX, and no matter what variation of Music.PlayFile I use, there is a delay before it starts to play. Its that sound effect that needs fixing, but thanks for help with the background music despite.
jmac4646




PostPosted: Fri Feb 06, 2015 10:55 am   Post subject: RE:Unknown Turing Music.PlayFile Delay Error

So I converted the ItemGet_SFX file to a .wav and it works a little faster but not instantly. IDK why this is happening.
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  [ 7 Posts ]
Jump to:   


Style:  
Search: