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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
NobleFlame
Prole
Posts: 13
Joined: Wed Jul 06, 2011 4:17 pm

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

Post 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
Last edited by NobleFlame on Wed Jul 06, 2011 8:21 pm, edited 7 times in total.
~{::Noble Flame::}~
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Audio Help

Post 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.
User avatar
NobleFlame
Prole
Posts: 13
Joined: Wed Jul 06, 2011 4:17 pm

Re: Audio Help

Post 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..
Last edited by bartbes on Wed Jul 06, 2011 6:31 pm, edited 1 time in total.
Reason: Edited to remove DISOBEY (I am not happy about this, next time you'll get an official warning!)
~{::Noble Flame::}~
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Audio Help

Post 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
User avatar
NobleFlame
Prole
Posts: 13
Joined: Wed Jul 06, 2011 4:17 pm

Re: Audio Help

Post 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?
~{::Noble Flame::}~
User avatar
NobleFlame
Prole
Posts: 13
Joined: Wed Jul 06, 2011 4:17 pm

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

Post by NobleFlame »

I really need help. Where do I store the pling.wav?
~{::Noble Flame::}~
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

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

Post 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
User avatar
NobleFlame
Prole
Posts: 13
Joined: Wed Jul 06, 2011 4:17 pm

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

Post by NobleFlame »

OH!
Thanks that helps a WHOLE lot.
~{::Noble Flame::}~
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Audio Help

Post 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.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

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

Post 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?
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests