Getting audio to work?

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.
Yousar
Prole
Posts: 12
Joined: Thu Mar 29, 2012 12:03 am

Getting audio to work?

Post by Yousar » Thu Mar 29, 2012 12:09 am

Sorry, I'm really new to scripting but this is confuzzling.
https://love2d.org/wiki/Tutorial:Audio
I understand the script and all, but where do I put it?
In an audio.lua file, or a main.lua file?
How do I load it?
I wish these tutorials were more helpful.
That or I'm just dumb.

EDIT:
Here is the error:
Error
audio.lua:1:Could not read Ogg bitstream


Traceback

[C]: in function 'newDecoder'
audio.lua:1 in function 'newSource'
music.lua:1: in main chunk
[C]: in function 'require'
main.lua:5: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'

The code is basically copied from https://love2d.org/wiki/Tutorial:Audio and https://love2d.org/wiki/Tutorial:Hamster_Ball.

Audio is in music.lua, hamster ball in main.lua

User avatar
baconhawka7x
Party member
Posts: 484
Joined: Mon Nov 21, 2011 7:05 am
Contact:

Re: Getting audio to work?

Post by baconhawka7x » Thu Mar 29, 2012 1:12 am

I'm not too experienced with love.audio. But Are you requiring all of the files that aren't main.lua or conf.lua?

Code: Select all

--the top of main.lua
require "music.lua"


--everything else below the top of main.lua

Yousar
Prole
Posts: 12
Joined: Thu Mar 29, 2012 12:03 am

Re: Getting audio to work?

Post by Yousar » Thu Mar 29, 2012 1:36 am

I have required the code.
And I have changed the music code to this:

function love.audio()
music = love.audio.newSource("hurricane.ogg") -- if "static" is omitted, LÖVE will stream the file from disk, good for longer music tracks
love.audio.play(music)
end

It's in music.lua

EDIT:
Now that I have changed it, the error is:

Error

Boot.lua:1: attempt to index file 'audio' (a function value)

Traceback

[C]: in function 'xpcall'

User avatar
baconhawka7x
Party member
Posts: 484
Joined: Mon Nov 21, 2011 7:05 am
Contact:

Re: Getting audio to work?

Post by baconhawka7x » Thu Mar 29, 2012 1:44 am

You should but your code inside if the code tags.
But more importantly, your putting all of that inside of function love.audio() which is incorrect.
you're doing..

Code: Select all

function love.audio()
   music = love.audio.newSource("I forgot what this was.ogg")
   love.audio.play(music)
end
but you shouldn't but all of that inside of function love.audio() just put it all inside of love.load() and it should work.

Yousar
Prole
Posts: 12
Joined: Thu Mar 29, 2012 12:03 am

Re: Getting audio to work?

Post by Yousar » Thu Mar 29, 2012 2:22 am

Thanks, there is no error now but I can't hear anything.
=(

User avatar
baconhawka7x
Party member
Posts: 484
Joined: Mon Nov 21, 2011 7:05 am
Contact:

Re: Getting audio to work?

Post by baconhawka7x » Thu Mar 29, 2012 2:43 am

Hmm..
love.audio.setVolume(1.0)
maybe, if that doesn't work, then upload a .love

Yousar
Prole
Posts: 12
Joined: Thu Mar 29, 2012 12:03 am

Re: Getting audio to work?

Post by Yousar » Thu Mar 29, 2012 3:02 am

How do I upload my .love file?
Sorry, I know this sounds really stupid but I don't know about uploading files.
Also, if it helps...
I changed the audio from .mp3 to .ogg

User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Getting audio to work?

Post by tentus » Thu Mar 29, 2012 4:14 am

To upload a .love, select all your files, and zip them up (how to do this depends on your operating system). Then, rename the .zip file to .love (.love == .zip)

Then, click reply. Underneath the reply text area, there are two tabs: Options and Upload Attachment. Click on Upload Attachment and browse to the file, and then click "Add the file".
Kurosuke needs beta testers

Yousar
Prole
Posts: 12
Joined: Thu Mar 29, 2012 12:03 am

Re: Getting audio to work?

Post by Yousar » Thu Mar 29, 2012 5:26 am

Thanks.
I have uploaded it now.
See if you can understand why it isn't working...
Attachments
New WinRAR ZIP archive.zip
This is the file...
(5.22 MiB) Downloaded 125 times

User avatar
baconhawka7x
Party member
Posts: 484
Joined: Mon Nov 21, 2011 7:05 am
Contact:

Re: Getting audio to work?

Post by baconhawka7x » Thu Mar 29, 2012 9:37 am

You should only be using love.load() once, inside of main.lua. The .ogg is making the .love too big to upload:(
But, it still doesn't work. Your .ogg file is broken for some reason:p So try a different .ogg.(My guess, is you got a different type of file, and then tried just renaming it to .ogg(i.e, it was a .mp3, but you just renamed it to a .ogg(that doesn't work)))

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests