Jump to content


Photo

Sound_add


  • Please log in to reply
6 replies to this topic

#1 vertex67

vertex67

    GMC Member

  • GMC Member
  • 515 posts

Posted 24 November 2009 - 12:18 AM

this gives me an error message

game start:
global.s1=sound_add('s1.wav',0,1)
show_message("sound loaded")
sound_play(global.s1)

this gives me the error message "sound does not exist" after showing my message "sound loaded"

this is really frustrating

Edited by vertex67, 24 November 2009 - 12:51 AM.

  • 0

#2 SenakuJin

SenakuJin

    GMC Member

  • New Member
  • 2765 posts

Posted 24 November 2009 - 12:23 AM

debug should be:

if(global.s1!=-1){show_message("sound loaded")}

The function returns -1 if it was unable to load the sound.
  • 0

#3 vertex67

vertex67

    GMC Member

  • GMC Member
  • 515 posts

Posted 24 November 2009 - 12:28 AM

ah, thanks, I figured it would give an error if the file didnt exist. so thats the problem, but I dont understand why

I have the sound with the file name s1.wav in the same directory as the gmk file.

Edited by vertex67, 24 November 2009 - 12:28 AM.

  • 0

#4 RowanFN

RowanFN

    Mr. Awesome

  • GMC Member
  • 1480 posts

Posted 24 November 2009 - 12:34 AM

yea but is the file called s1, so it would be s1.wav (if its a wave file) or is it called s1.wav then it might be s1.wav.wav

if u get my meaning
  • 0

#5 SenakuJin

SenakuJin

    GMC Member

  • New Member
  • 2765 posts

Posted 24 November 2009 - 12:36 AM

Try:

if(file_exists(working_directory+"\fname")){"show_message("File exists"));

If it returns that it dose not, try loading it through gm (not gml) see if it works okay.

If it dose work, change:

global.s1=sound_add('s1.wav',0,1);
to
global.s1=sound_add(working_directory+"\s1.wav",0,1);
  • 0

#6 vertex67

vertex67

    GMC Member

  • GMC Member
  • 515 posts

Posted 24 November 2009 - 12:39 AM

I will try that, thanks, btw, the sound is called s1 but it is a wav file, so it should be 's1.wav' i believe.
  • 0

#7 vertex67

vertex67

    GMC Member

  • GMC Member
  • 515 posts

Posted 24 November 2009 - 12:50 AM

strange, I got it to work after quitting and reopening, and adding my sounds with execute string like this

global.s[0]=0
for(n=1;n<=36;n+=1){
execute_string("global.s["+string(n)+"]=sound_add('s"+string(n)+".wav',0,1)")}

thanks for the comments and debug help
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users