Page 1 of 2

Audio Help [Where do I put audio file?Please help.]

Posted: Wed Jul 06, 2011 5:29 pm
by NobleFlame
Hia, Ive recently joined LOVE and ive been scripting LUA since 2008. Ive been using the ROBLOX game engine for that and ive been reading the wiki and basicly copy and pasting. I would then edit my scripts and such. The output printed a few errors and I understand this may look like a failed script to you (Trust me I know) but I would appreciate if you would fix this.

Code: Select all

function love.draw()
    love.graphics.print("Hello World", 400, 300)
end

sound = love.audio.newSource("pling.wav", "static") -- the "static" tells LÖVE to load the file into memory, good for short sound effects
music = love.audio.newSource("music.wav") -- if "static" is omitted, LÖVE will stream the file from disk, good for longer music tracks
love.audio.play(sound)
love.audio.play(music)
This is how everything for me is set up...
Folder wich contains the files
  • main.lua
  • pling.wav
  • music.wav

Re: Audio Help

Posted: Wed Jul 06, 2011 6:03 pm
by bartbes
You shouldn't be doing that stuff there, it is bad practice to manipulate the game in the main file, please use love.load (or whatever function is appropriate at the time).
Other than that it should just work (and play both once).

Also, FORMAT. Don't write your posts completely in bold, don't double-post and use the code tag where applicable.

Re: Audio Help

Posted: Wed Jul 06, 2011 6:09 pm
by NobleFlame
Alright thanks for the tip. So let me get this straight...

create a new Lua file.
Input the Audio code...
And on main.lua I run the code from there?
How would I use this function 'love.load'?

Everything is still the same though..

Re: Audio Help

Posted: Wed Jul 06, 2011 6:33 pm
by bartbes
love.load is, like love.draw a callback function, something you define, and the engine calls for you. So in this case it would be:

Code: Select all

function love.load()
    sound = love.audio.newSource("pling.wav", "static")
    music = love.audio.newSource("music.wav")
    love.audio.play(sound)
    love.audio.play(music)
end

function love.draw()
    love.graphics.print("Hello World", 400, 300)
end

Re: Audio Help

Posted: Wed Jul 06, 2011 6:55 pm
by NobleFlame
Alright now output prints, Pling.wav does not exist. Do I have to provide some kind of tag? I thaught love.Audio was a global instance thats gets audio files.

Do I have to place my Audio files in a certain folder?

Re: Audio Help [AudioFile does not exist. ZIP?]

Posted: Wed Jul 06, 2011 8:16 pm
by NobleFlame
I really need help. Where do I store the pling.wav?

Re: Audio Help [AudioFile does not exist. ZIP?]

Posted: Wed Jul 06, 2011 8:36 pm
by nevon
NobleFlame wrote:I really need help. Where do I store the pling.wav?
Wherever you want. If you store pling.wav (you really should be using .ogg though. There are... Issues with some other formats) in a directory called 'audio' you'd load it by doing:

Code: Select all

function love.load()
    pling = love.audio.newSource('audio/pling.wav', 'static')
end

Re: Audio Help [Where do I put audio file?Please help.]

Posted: Wed Jul 06, 2011 8:41 pm
by NobleFlame
OH!
Thanks that helps a WHOLE lot.

Re: Audio Help

Posted: Thu Jul 07, 2011 7:32 am
by BlackBulletIV
NobleFlame wrote:Alright now output prints, Pling.wav does not exist. Do I have to provide some kind of tag? I thaught love.Audio was a global instance thats gets audio files.

Do I have to place my Audio files in a certain folder?
NobleFlame wrote:I really need help. Where do I store the pling.wav?
bartbes wrote:don't double-post
Wait longer than 1:20 hours before double posting. More like a fair few or a day.

Re: Audio Help [Where do I put audio file?Please help.]

Posted: Thu Jul 07, 2011 6:57 pm
by T-Bone
Also, isn't LÖVE case sensitive to filenames? There is a difference between "pling.wav" and "Pling.wav", is it not?