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
Getting audio to work?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- baconhawka7x
- Party member
- Posts: 491
- Joined: Mon Nov 21, 2011 7:05 am
- Location: Oregon, USA
- Contact:
Re: Getting audio to work?
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
Re: Getting audio to work?
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'
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'
- baconhawka7x
- Party member
- Posts: 491
- Joined: Mon Nov 21, 2011 7:05 am
- Location: Oregon, USA
- Contact:
Re: Getting audio to work?
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..
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.
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
Re: Getting audio to work?
Thanks, there is no error now but I can't hear anything.
=(
=(
- baconhawka7x
- Party member
- Posts: 491
- Joined: Mon Nov 21, 2011 7:05 am
- Location: Oregon, USA
- Contact:
Re: Getting audio to work?
Hmm..
love.audio.setVolume(1.0)
maybe, if that doesn't work, then upload a .love
love.audio.setVolume(1.0)
maybe, if that doesn't work, then upload a .love
Re: Getting audio to work?
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
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
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Getting audio to work?
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".
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
Re: Getting audio to work?
Thanks.
I have uploaded it now.
See if you can understand why it isn't working...
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 259 times
- baconhawka7x
- Party member
- Posts: 491
- Joined: Mon Nov 21, 2011 7:05 am
- Location: Oregon, USA
- Contact:
Re: Getting audio to work?
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)))
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)))
Who is online
Users browsing this forum: Bing [Bot] and 4 guests